Bug 1367585 - Add the 'load' event listener before adding the new tab in sync's TPS tests r?markh draft
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Wed, 24 May 2017 17:58:55 -0400
changeset 584082 88dad4b5be2530aa34405ffa6d3f0f2abe2ba66d
parent 583952 8547e166d6d0fefa4edfe5bea4bf2e40c612c901
child 630277 8f527017024416c421041d71825faca57a2bcab0
push id60625
push userbmo:tchiovoloni@mozilla.com
push dateWed, 24 May 2017 21:59:09 +0000
reviewersmarkh
bugs1367585
milestone55.0a1
Bug 1367585 - Add the 'load' event listener before adding the new tab in sync's TPS tests r?markh MozReview-Commit-ID: HUUHYnLf4m8
services/sync/tps/extensions/tps/resource/modules/tabs.jsm
--- a/services/sync/tps/extensions/tps/resource/modules/tabs.jsm
+++ b/services/sync/tps/extensions/tps/resource/modules/tabs.jsm
@@ -24,20 +24,20 @@ var BrowserTabs = {
    * @return nothing
    */
   Add(uri, fn) {
     // Open the uri in a new tab in the current browser window, and calls
     // the callback fn from the tab's onload handler.
     let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
                .getService(Ci.nsIWindowMediator);
     let mainWindow = wm.getMostRecentWindow("navigator:browser");
-    let newtab = mainWindow.getBrowser().addTab(uri);
-    mainWindow.getBrowser().selectedTab = newtab;
-    let win = mainWindow.getBrowser().getBrowserForTab(newtab);
-    win.addEventListener("load", function() { fn.call(); }, true);
+    let browser = mainWindow.getBrowser();
+    browser.addEventListener("load", fn, { once: true });
+    let newtab = browser.addTab(uri);
+    browser.selectedTab = newtab;
   },
 
   /**
    * Find
    *
    * Finds the specified uri and title in Weave's list of remote tabs
    * for the specified profile.
    *