Bug 1367585 - Add the 'load' event listener before adding the new tab in sync's TPS tests r?markh
MozReview-Commit-ID: HUUHYnLf4m8
--- 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.
*