Bug 1369750 - Get window from event.target.defaultView inside load event to make r=mossop
authorFischer.json <fischer.json@gmail.com>
Mon, 05 Jun 2017 11:03:09 +0800
changeset 410908 57187d8e14337441e40c2ca33c2997e95bc7cdd0
parent 410907 b9b5c00e6352a396d0e72dd90aa1c843c30bb871
child 410909 6175f32bed68450cf039f42399802243f0e4898d
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1369750
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1369750 - Get window from event.target.defaultView inside load event to make r=mossop sure getting the right target window, r?mossop MozReview-Commit-ID: HwHSwvCrXh7
browser/extensions/onboarding/content/onboarding.js
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -97,19 +97,25 @@ class Onboarding {
       link.type = "text/css";
       link.href = ONBOARDING_CSS_URL;
       link.addEventListener("load", resolve);
       doc.head.appendChild(link);
     });
   }
 }
 
-addEventListener("load", function(evt) {
+addEventListener("load", function onLoad(evt) {
+  if (!content || evt.target != content.document) {
+    return;
+  }
+  removeEventListener("load", onLoad);
+
+  let window = evt.target.defaultView;
   // Load onboarding module only when we enable it.
-  if ((content.location.href == ABOUT_NEWTAB_URL ||
-       content.location.href == ABOUT_HOME_URL) &&
+  if ((window.location.href == ABOUT_NEWTAB_URL ||
+       window.location.href == ABOUT_HOME_URL) &&
       Services.prefs.getBoolPref("browser.onboarding.enabled", false)) {
 
-    content.requestIdleCallback(() => {
-      new Onboarding(content);
+    window.requestIdleCallback(() => {
+      new Onboarding(window);
     });
   }
 }, true);