Bug 1034036 - Part 2: Rename and shorten `getMostRecentBrowserWindow` to `getTopWindow` and modernize the style used in BrowserWindowTracker.jsm. r?dao draft
authorMike de Boer <mdeboer@mozilla.com>
Tue, 27 Feb 2018 11:27:42 +0100
changeset 760380 eeca669657ede62733dc0cd5df5e22a046732e89
parent 760379 91f5acf88ea8599e499a4b09374f69ef1ca878cb
child 760381 fb0d76f55a20463856c168a8dcd7ab43b33a5a71
push id100621
push usermdeboer@mozilla.com
push dateTue, 27 Feb 2018 13:59:55 +0000
reviewersdao
bugs1034036
milestone60.0a1
Bug 1034036 - Part 2: Rename and shorten `getMostRecentBrowserWindow` to `getTopWindow` and modernize the style used in BrowserWindowTracker.jsm. r?dao MozReview-Commit-ID: HUjcfXoTYrL
browser/base/content/browser-captivePortal.js
browser/base/content/browser.js
browser/base/content/nsContextMenu.js
browser/base/content/test/captivePortal/head.js
browser/base/content/utilityOverlay.js
browser/components/downloads/DownloadsCommon.jsm
browser/components/downloads/DownloadsTaskbar.jsm
browser/components/downloads/DownloadsViewUI.jsm
browser/components/downloads/content/allDownloadsViewOverlay.js
browser/components/extensions/ext-browser.js
browser/components/nsBrowserContentHandler.js
browser/components/nsBrowserGlue.js
browser/components/places/PlacesUIUtils.jsm
browser/components/places/tests/browser/browser_bookmarksProperties.js
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/test/browser_354894_perwindowpb.js
browser/components/translation/Translation.jsm
browser/extensions/formautofill/FormAutofillParent.jsm
browser/modules/BrowserUITelemetry.jsm
browser/modules/BrowserWindowTracker.jsm
browser/modules/ContentCrashHandlers.jsm
browser/modules/ExtensionsUI.jsm
browser/modules/Feeds.jsm
toolkit/components/telemetry/TelemetryReportingPolicy.jsm
toolkit/modules/addons/WebNavigation.jsm
--- a/browser/base/content/browser-captivePortal.js
+++ b/browser/base/content/browser-captivePortal.js
@@ -107,17 +107,17 @@ var CaptivePortalWatcher = {
     }
   },
 
   _captivePortalDetected() {
     if (this._delayedCaptivePortalDetectedInProgress) {
       return;
     }
 
-    let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let win = BrowserWindowTracker.getTopWindow();
     // If no browser window has focus, open and show the tab when we regain focus.
     // This is so that if a different application was focused, when the user
     // (re-)focuses a browser window, we open the tab immediately in that window
     // so they can log in before continuing to browse.
     if (win != Services.ww.activeWindow) {
       this._delayedCaptivePortalDetectedInProgress = true;
       Services.obs.addObserver(this, "xul-window-visible");
     }
@@ -130,17 +130,17 @@ var CaptivePortalWatcher = {
    * doesn't have focus. Triggers a portal recheck to reaffirm state, and adds
    * the tab if needed after a short delay to allow the recheck to complete.
    */
   _delayedCaptivePortalDetected() {
     if (!this._delayedCaptivePortalDetectedInProgress) {
       return;
     }
 
-    let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let win = BrowserWindowTracker.getTopWindow();
     if (win != Services.ww.activeWindow) {
       // The window that got focused was not a browser window.
       return;
     }
     Services.obs.removeObserver(this, "xul-window-visible");
     this._delayedCaptivePortalDetectedInProgress = false;
 
     if (win != window) {
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2619,17 +2619,17 @@ function BrowserViewSourceOfDocument(aAr
       // URL.
       preferredRemoteType =
         E10SUtils.getRemoteTypeForURI(args.URL, gMultiProcessBrowser);
     }
 
     // In the case of popups, we need to find a non-popup browser window.
     if (!tabBrowser || !window.toolbar.visible) {
       // This returns only non-popup browser windows by default.
-      let browserWindow = BrowserWindowTracker.getMostRecentBrowserWindow();
+      let browserWindow = BrowserWindowTracker.getTopWindow();
       tabBrowser = browserWindow.gBrowser;
     }
 
     // `viewSourceInBrowser` will load the source content from the page
     // descriptor for the tab (when possible) or fallback to the network if
     // that fails.  Either way, the view source module will manage the tab's
     // location, so use "about:blank" here to avoid unnecessary redundant
     // requests.
@@ -5140,17 +5140,17 @@ nsBrowserAccess.prototype = {
                    aOpenerWindow = null, aOpenerBrowser = null,
                    aTriggeringPrincipal = null, aNextTabParentId = 0, aName = "") {
     let win, needToFocusWin;
 
     // try the current window.  if we're in a popup, fall back on the most recent browser window
     if (window.toolbar.visible)
       win = window;
     else {
-      win = BrowserWindowTracker.getMostRecentBrowserWindow({private: aIsPrivate});
+      win = BrowserWindowTracker.getTopWindow({private: aIsPrivate});
       needToFocusWin = true;
     }
 
     if (!win) {
       // we couldn't find a suitable window, a new one needs to be opened.
       return null;
     }
 
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -870,17 +870,17 @@ nsContextMenu.prototype = {
     let openSelectionFn = function() {
       let tabBrowser = gBrowser;
       // In the case of popups, we need to find a non-popup browser window.
       // We might also not have a tabBrowser reference (if this isn't in a
       // a tabbrowser scope) or might have a fake/stub tabbrowser reference
       // (in the sidebar). Deal with those cases:
       if (!tabBrowser || !tabBrowser.loadOneTab || !window.toolbar.visible) {
         // This returns only non-popup browser windows by default.
-        let browserWindow = BrowserWindowTracker.getMostRecentBrowserWindow();
+        let browserWindow = BrowserWindowTracker.getTopWindow();
         tabBrowser = browserWindow.gBrowser;
       }
       let relatedToCurrent = gBrowser && gBrowser.selectedBrowser == browser;
       let tab = tabBrowser.loadOneTab("about:blank", {
         relatedToCurrent,
         inBackground: false,
         triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
       });
--- a/browser/base/content/test/captivePortal/head.js
+++ b/browser/base/content/test/captivePortal/head.js
@@ -15,31 +15,31 @@ const PORTAL_NOTIFICATION_VALUE = "capti
 async function setupPrefsAndRecentWindowBehavior() {
   await SpecialPowers.pushPrefEnv({
     set: [["captivedetect.canonicalURL", CANONICAL_URL],
           ["captivedetect.canonicalContent", CANONICAL_CONTENT]],
   });
   // We need to test behavior when a portal is detected when there is no browser
   // window, but we can't close the default window opened by the test harness.
   // Instead, we deactivate CaptivePortalWatcher in the default window and
-  // exclude it from BrowserWindowTracker.getMostRecentBrowserWindow in an attempt to
+  // exclude it from BrowserWindowTracker.getTopWindow in an attempt to
   // mask its presence.
   window.CaptivePortalWatcher.uninit();
-  let getMostRecentBrowserWindowCopy = BrowserWindowTracker.getMostRecentBrowserWindow;
+  let getTopWindowCopy = BrowserWindowTracker.getTopWindow;
   let defaultWindow = window;
-  BrowserWindowTracker.getMostRecentBrowserWindow = () => {
-    let win = getMostRecentBrowserWindowCopy();
+  BrowserWindowTracker.getTopWindow = () => {
+    let win = getTopWindowCopy();
     if (win == defaultWindow) {
       return null;
     }
     return win;
   };
 
   registerCleanupFunction(function cleanUp() {
-    BrowserWindowTracker.getMostRecentBrowserWindow = getMostRecentBrowserWindowCopy;
+    BrowserWindowTracker.getTopWindow = getTopWindowCopy;
     window.CaptivePortalWatcher.init();
   });
 }
 
 async function portalDetected() {
   Services.obs.notifyObservers(null, "captive-portal-login");
   await BrowserTestUtils.waitForCondition(() => {
     return cps.state == cps.LOCKED_PORTAL;
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -51,19 +51,20 @@ function getBrowserURL() {
 function getTopWin(skipPopups) {
   // If this is called in a browser window, use that window regardless of
   // whether it's the frontmost window, since commands can be executed in
   // background windows (bug 626148).
   if (top.document.documentElement.getAttribute("windowtype") == "navigator:browser" &&
       (!skipPopups || top.toolbar.visible))
     return top;
 
-  let isPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
-  return BrowserWindowTracker.getMostRecentBrowserWindow({private: isPrivate,
-                                                         allowPopups: !skipPopups});
+  return BrowserWindowTracker.getTopWindow({
+    private: PrivateBrowsingUtils.isWindowPrivate(window),
+    allowPopups: !skipPopups
+  });
 }
 
 function getBoolPref(prefname, def) {
   try {
     return Services.prefs.getBoolPref(prefname);
   } catch (er) {
     return def;
   }
--- a/browser/components/downloads/DownloadsCommon.jsm
+++ b/browser/components/downloads/DownloadsCommon.jsm
@@ -823,17 +823,17 @@ DownloadsDataCtor.prototype = {
    *
    * @param aType
    *        Set to "start" for new downloads, "finish" for completed downloads.
    */
   _notifyDownloadEvent(aType) {
     DownloadsCommon.log("Attempting to notify that a new download has started or finished.");
 
     // Show the panel in the most recent browser window, if present.
-    let browserWin = BrowserWindowTracker.getMostRecentBrowserWindow({ private: this._isPrivate });
+    let browserWin = BrowserWindowTracker.getTopWindow({ private: this._isPrivate });
     if (!browserWin) {
       return;
     }
 
     if (this.panelHasShownBefore) {
       // For new downloads after the first one, don't show the panel
       // automatically, but provide a visible notification in the topmost
       // browser window, if the status indicator is already visible.
--- a/browser/components/downloads/DownloadsTaskbar.jsm
+++ b/browser/components/downloads/DownloadsTaskbar.jsm
@@ -123,17 +123,17 @@ var DownloadsTaskbar = {
     // the state of the new indicator, otherwise it will be updated as soon as
     // the DownloadSummary view is registered.
     if (this._summary) {
       this.onSummaryChanged();
     }
 
     aWindow.addEventListener("unload", () => {
       // Locate another browser window, excluding the one being closed.
-      let browserWindow = BrowserWindowTracker.getMostRecentBrowserWindow();
+      let browserWindow = BrowserWindowTracker.getTopWindow();
       if (browserWindow) {
         // Move the progress indicator to the other browser window.
         this._attachIndicator(browserWindow);
       } else {
         // The last browser window has been closed.  We remove the reference to
         // the taskbar progress object so that the indicator will be registered
         // again on the next browser window that is opened.
         this._taskbarProgress = null;
--- a/browser/components/downloads/DownloadsViewUI.jsm
+++ b/browser/components/downloads/DownloadsViewUI.jsm
@@ -100,17 +100,17 @@ this.DownloadsViewUI.DownloadElementShel
   get displayName() {
     if (!this.download.target.path) {
       return this.download.source.url;
     }
     return OS.Path.basename(this.download.target.path);
   },
 
   get browserWindow() {
-    return BrowserWindowTracker.getMostRecentBrowserWindow();
+    return BrowserWindowTracker.getTopWindow();
   },
 
   /**
    * The progress element for the download, or undefined in case the XBL binding
    * has not been applied yet.
    */
   get _progressElement() {
     if (!this.__progressElement) {
--- a/browser/components/downloads/content/allDownloadsViewOverlay.js
+++ b/browser/components/downloads/content/allDownloadsViewOverlay.js
@@ -561,17 +561,17 @@ DownloadsPlacesView.prototype = {
 
   _canDownloadClipboardURL() {
     let [url /* ,name */] = this._getURLFromClipboardData();
     return url != "";
   },
 
   _downloadURLFromClipboard() {
     let [url, name] = this._getURLFromClipboardData();
-    let browserWin = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let browserWin = BrowserWindowTracker.getTopWindow();
     let initiatingDoc = browserWin ? browserWin.document : document;
     DownloadURL(url, name, initiatingDoc);
   },
 
   // nsIController
   doCommand(aCommand) {
     // Commands may be invoked with keyboard shortcuts even if disabled.
     if (!this.isCommandEnabled(aCommand)) {
@@ -741,17 +741,17 @@ DownloadsPlacesView.prototype = {
     // redownload already downloaded file.
     if (dt.mozGetDataAt("application/x-moz-file", 0)) {
       return;
     }
 
     let links = Services.droppedLinkHandler.dropLinks(aEvent);
     if (!links.length)
       return;
-    let browserWin = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let browserWin = BrowserWindowTracker.getTopWindow();
     let initiatingDoc = browserWin ? browserWin.document : document;
     for (let link of links) {
       if (link.url.startsWith("about:"))
         continue;
       DownloadURL(link.url, link.name, initiatingDoc);
     }
   },
 };
--- a/browser/components/extensions/ext-browser.js
+++ b/browser/components/extensions/ext-browser.js
@@ -168,17 +168,17 @@ class WindowTracker extends WindowTracke
   /**
    * @property {DOMWindow|null} topNormalWindow
    *        The currently active, or topmost, browser window, or null if no
    *        browser window is currently open.
    *        Will return the topmost "normal" (i.e., not popup) window.
    *        @readonly
    */
   get topNormalWindow() {
-    return BrowserWindowTracker.getMostRecentBrowserWindow({allowPopups: false});
+    return BrowserWindowTracker.getTopWindow({allowPopups: false});
   }
 }
 
 /**
  * An event manager API provider which listens for a DOM event in any browser
  * window, and calls the given listener function whenever an event is received.
  * That listener function receives a `fire` object, which it can use to dispatch
  * events to the extension, and a DOM event object.
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -665,17 +665,17 @@ var gBrowserContentHandler = new nsBrows
 
 function handURIToExistingBrowser(uri, location, cmdLine, forcePrivate, triggeringPrincipal) {
   if (!shouldLoadURI(uri))
     return;
 
   // Unless using a private window is forced, open external links in private
   // windows only if we're in perma-private mode.
   var allowPrivate = forcePrivate || PrivateBrowsingUtils.permanentPrivateBrowsing;
-  var navWin = BrowserWindowTracker.getMostRecentBrowserWindow({private: allowPrivate});
+  var navWin = BrowserWindowTracker.getTopWindow({private: allowPrivate});
   if (!navWin) {
     // if we couldn't load it in an existing window, open a new one
     var features = "chrome,dialog=no,all" + gBrowserContentHandler.getFeatures(cmdLine);
     if (forcePrivate) {
       features += ",private";
     }
     openWindow(null, gBrowserContentHandler.chromeURL, "_blank", features, uri.spec);
     return;
@@ -782,17 +782,17 @@ nsDefaultCommandLineHandler.prototype = 
                    URLlist);
       }
 
     } else if (!cmdLine.preventDefault) {
       if (AppConstants.isPlatformAndVersionAtLeast("win", "10") &&
           cmdLine.state != nsICommandLine.STATE_INITIAL_LAUNCH &&
           WindowsUIUtils.inTabletMode) {
         // In windows 10 tablet mode, do not create a new window, but reuse the existing one.
-        let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+        let win = BrowserWindowTracker.getTopWindow();
         if (win) {
           win.focus();
           return;
         }
       }
       if (cmdLine.state == nsICommandLine.STATE_INITIAL_LAUNCH) {
         let win = Services.wm.getMostRecentWindow("navigator:blank");
         if (win) {
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -494,17 +494,17 @@ BrowserGlue.prototype = {
         this._migrationImportsDefaultBookmarks = true;
         break;
       case "initial-migration-did-import-default-bookmarks":
         this._initPlaces(true);
         break;
       case "handle-xul-text-link":
         let linkHandled = subject.QueryInterface(Ci.nsISupportsPRBool);
         if (!linkHandled.data) {
-          let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+          let win = BrowserWindowTracker.getTopWindow();
           if (win) {
             data = JSON.parse(data);
             let where = win.whereToOpenLink(data);
             // Preserve legacy behavior of non-modifier left-clicks
             // opening in a new selected tab.
             if (where == "current") {
               where = "tab";
             }
@@ -523,17 +523,17 @@ BrowserGlue.prototype = {
         // This notification is broadcast by the docshell when it "fixes up" a
         // URI that it's been asked to load into a keyword search.
         let engine = null;
         try {
           engine = subject.QueryInterface(Ci.nsISearchEngine);
         } catch (ex) {
           Cu.reportError(ex);
         }
-        let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+        let win = BrowserWindowTracker.getTopWindow();
         win.BrowserSearch.recordSearchInTelemetry(engine, "urlbar");
         break;
       case "browser-search-engine-modified":
         // Ensure we cleanup the hiddenOneOffs pref when removing
         // an engine, and that newly added engines are visible.
         if (data == "engine-added" || data == "engine-removed") {
           let engineName = subject.QueryInterface(Ci.nsISearchEngine).name;
           let pref = Services.prefs.getStringPref("browser.search.hiddenOneOffs");
@@ -816,17 +816,17 @@ BrowserGlue.prototype = {
     const ONE_DAY = 24 * 60 * 60 * 1000;
     return (Date.now() - profileDate) / ONE_DAY;
   },
 
   _showSlowStartupNotification(profileAge) {
     if (profileAge < 90) // 3 months
       return;
 
-    let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let win = BrowserWindowTracker.getTopWindow();
     if (!win)
       return;
 
     let productName = gBrandBundle.GetStringFromName("brandFullName");
     let message = win.gNavigatorBundle.getFormattedString("slowStartup.message", [productName]);
 
     let buttons = [
       {
@@ -854,17 +854,17 @@ BrowserGlue.prototype = {
   /**
    * Show a notification bar offering a reset.
    *
    * @param reason
    *        String of either "unused" or "uninstall", specifying the reason
    *        why a profile reset is offered.
    */
   _resetProfileNotification(reason) {
-    let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let win = BrowserWindowTracker.getTopWindow();
     if (!win)
       return;
 
     ChromeUtils.import("resource://gre/modules/ResetProfile.jsm");
     if (!ResetProfile.resetSupported())
       return;
 
     let productName = gBrandBundle.GetStringFromName("brandShortName");
@@ -891,17 +891,17 @@ BrowserGlue.prototype = {
 
     let nb = win.document.getElementById("global-notificationbox");
     nb.appendNotification(message, "reset-profile-notification",
                           "chrome://global/skin/icons/question-16.png",
                           nb.PRIORITY_INFO_LOW, buttons);
   },
 
   _notifyUnsignedAddonsDisabled() {
-    let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let win = BrowserWindowTracker.getTopWindow();
     if (!win)
       return;
 
     let message = win.gNavigatorBundle.getString("unsignedAddonsDisabled.message");
     let buttons = [
       {
         label:     win.gNavigatorBundle.getString("unsignedAddonsDisabled.learnMore.label"),
         accessKey: win.gNavigatorBundle.getString("unsignedAddonsDisabled.learnMore.accesskey"),
@@ -1461,17 +1461,17 @@ BrowserGlue.prototype = {
                                   stringParams: [appName]});
       let url = getNotifyString({propName: "notificationURL",
                                  prefName: "startup.homepage_override_url"});
       let label = getNotifyString({propName: "notificationButtonLabel",
                                    stringName: "pu.notifyButton.label"});
       let key = getNotifyString({propName: "notificationButtonAccessKey",
                                  stringName: "pu.notifyButton.accesskey"});
 
-      let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+      let win = BrowserWindowTracker.getTopWindow();
       let notifyBox = win.document.getElementById("high-priority-global-notificationbox");
 
       let buttons = [
                       {
                         label,
                         accessKey: key,
                         popup:     null,
                         callback(aNotificationBar, aButton) {
@@ -1496,17 +1496,17 @@ BrowserGlue.prototype = {
                                 stringParams: [appName]});
     let url = getNotifyString({propName: "alertURL",
                                prefName: "startup.homepage_override_url"});
 
     function clickCallback(subject, topic, data) {
       // This callback will be called twice but only once with this topic
       if (topic != "alertclickcallback")
         return;
-      let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+      let win = BrowserWindowTracker.getTopWindow();
       win.openUILinkIn(data, "tab");
     }
 
     try {
       // This will throw NS_ERROR_NOT_AVAILABLE if the notification cannot
       // be displayed per the idl.
       this.AlertsService.showAlertNotification(null, title, text,
                                           true, url, clickCallback);
@@ -1749,17 +1749,17 @@ BrowserGlue.prototype = {
     var text = placesBundle.formatStringFromName("lockPrompt.text", [applicationName], 1);
     var buttonText = placesBundle.GetStringFromName("lockPromptInfoButton.label");
     var accessKey = placesBundle.GetStringFromName("lockPromptInfoButton.accessKey");
 
     var helpTopic = "places-locked";
     var url = Services.urlFormatter.formatURLPref("app.support.baseURL");
     url += helpTopic;
 
-    var win = BrowserWindowTracker.getMostRecentBrowserWindow();
+    var win = BrowserWindowTracker.getTopWindow();
 
     var buttons = [
                     {
                       label:     buttonText,
                       accessKey,
                       popup:     null,
                       callback(aNotificationBar, aButton) {
                         win.openUILinkIn(url, "tab");
@@ -2388,17 +2388,17 @@ BrowserGlue.prototype = {
                         .add(isDefaultError);
       Services.telemetry.getHistogramById("BROWSER_SET_DEFAULT_ALWAYS_CHECK")
                         .add(shouldCheck);
       Services.telemetry.getHistogramById("BROWSER_SET_DEFAULT_DIALOG_PROMPT_RAWCOUNT")
                         .add(promptCount);
     } catch (ex) { /* Don't break the default prompt if telemetry is broken. */ }
 
     if (willPrompt) {
-      DefaultBrowserCheck.prompt(BrowserWindowTracker.getMostRecentBrowserWindow());
+      DefaultBrowserCheck.prompt(BrowserWindowTracker.getTopWindow());
     }
   },
 
   _migrateMatchBucketsPrefForUIVersion60(forceCheck = false) {
     function check() {
       if (CustomizableUI.getPlacementOfWidget("search-container")) {
         Services.prefs.setCharPref(prefName,
                                    "general:5,suggestion:Infinity");
@@ -2568,17 +2568,17 @@ BrowserGlue.prototype = {
    * Open preferences even if there are no open windows.
    */
   _openPreferences(...args) {
     if (Services.appShell.hiddenDOMWindow.openPreferences) {
       Services.appShell.hiddenDOMWindow.openPreferences(...args);
       return;
     }
 
-    let chromeWindow = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let chromeWindow = BrowserWindowTracker.getTopWindow();
     chromeWindow.openPreferences(...args);
   },
 
   _openURLInNewWindow(url) {
     let urlString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
     urlString.data = url;
     return new Promise(resolve => {
       let win = Services.ww.openWindow(null, Services.prefs.getCharPref("browser.chromeURL"),
@@ -2593,17 +2593,17 @@ BrowserGlue.prototype = {
    * We open the received URIs in background tabs.
    */
   async _onDisplaySyncURIs(data) {
     try {
       // The payload is wrapped weirdly because of how Sync does notifications.
       const URIs = data.wrappedJSObject.object;
 
       // win can be null, but it's ok, we'll assign it later in openTab()
-      let win = BrowserWindowTracker.getMostRecentBrowserWindow({private: false});
+      let win = BrowserWindowTracker.getTopWindow({private: false});
 
       const openTab = async (URI) => {
         let tab;
         if (!win) {
           win = await this._openURLInNewWindow(URI.uri);
           let tabs = win.gBrowser.tabs;
           tab = tabs[tabs.length - 1];
         } else {
@@ -2676,17 +2676,17 @@ BrowserGlue.prototype = {
   },
 
   async _onVerifyLoginNotification({body, title, url}) {
     let tab;
     let imageURL;
     if (AppConstants.platform == "win") {
       imageURL = "chrome://branding/content/icon64.png";
     }
-    let win = BrowserWindowTracker.getMostRecentBrowserWindow({private: false});
+    let win = BrowserWindowTracker.getTopWindow({private: false});
     if (!win) {
       win = await this._openURLInNewWindow(url);
       let tabs = win.gBrowser.tabs;
       tab = tabs[tabs.length - 1];
     } else {
       tab = win.gBrowser.addTab(url);
     }
     tab.setAttribute("attention", true);
@@ -2711,17 +2711,17 @@ BrowserGlue.prototype = {
     let body = accountsBundle.formatStringFromName("deviceConnectedBody" +
                                                    (deviceName ? "" : ".noDeviceName"),
                                                    [deviceName], 1);
 
     let clickCallback = async (subject, topic, data) => {
       if (topic != "alertclickcallback")
         return;
       let url = await FxAccounts.config.promiseManageDevicesURI("device-connected-notification");
-      let win = BrowserWindowTracker.getMostRecentBrowserWindow({private: false});
+      let win = BrowserWindowTracker.getTopWindow({private: false});
       if (!win) {
         this._openURLInNewWindow(url);
       } else {
         win.gBrowser.addTab(url);
       }
     };
 
     try {
@@ -2761,17 +2761,17 @@ BrowserGlue.prototype = {
       return;
     }
     if (Services.prefs.getBoolPref("browser.flash-protected-mode-flip.done")) {
       return;
     }
     Services.prefs.setBoolPref("dom.ipc.plugins.flash.disable-protected-mode", true);
     Services.prefs.setBoolPref("browser.flash-protected-mode-flip.done", true);
 
-    let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let win = BrowserWindowTracker.getTopWindow();
     if (!win) {
       return;
     }
     let productName = gBrandBundle.GetStringFromName("brandShortName");
     let message = win.gNavigatorBundle.
       getFormattedString("flashHang.message", [productName]);
     let buttons = [{
       label: win.gNavigatorBundle.getString("flashHang.helpButton.label"),
@@ -3130,17 +3130,17 @@ var JawsScreenReaderVersionCheck = {
     // support and never prompt if e10s is disabled or if we're on
     // nightly.
     if (!Services.appinfo.shouldBlockIncompatJaws ||
         !Services.appinfo.browserTabsRemoteAutostart ||
         AppConstants.NIGHTLY_BUILD) {
       return;
     }
 
-    let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let win = BrowserWindowTracker.getTopWindow();
     if (!win || !win.gBrowser || !win.gBrowser.selectedBrowser) {
       Services.console.logStringMessage(
           "Content access support for older versions of JAWS is disabled " +
           "due to compatibility issues with this version of Firefox.");
       this._prompted = false;
       return;
     }
 
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -638,17 +638,17 @@ var PlacesUIUtils = {
     if (!aItemsToOpen.length)
       return;
 
     // Prefer the caller window if it's a browser window, otherwise use
     // the top browser window.
     var browserWindow = null;
     browserWindow =
       aWindow && aWindow.document.documentElement.getAttribute("windowtype") == "navigator:browser" ?
-      aWindow : BrowserWindowTracker.getMostRecentBrowserWindow();
+      aWindow : BrowserWindowTracker.getTopWindow();
 
     var urls = [];
     let skipMarking = browserWindow && PrivateBrowsingUtils.isWindowPrivate(browserWindow);
     for (let item of aItemsToOpen) {
       urls.push(item.uri);
       if (skipMarking) {
         continue;
       }
@@ -776,17 +776,17 @@ var PlacesUIUtils = {
           this.markPageAsTyped(aNode.uri);
       }
 
       // Check whether the node is a bookmark which should be opened as
       // a web panel
       if (aWhere == "current" && isBookmark) {
         if (PlacesUtils.annotations
                        .itemHasAnnotation(aNode.itemId, this.LOAD_IN_SIDEBAR_ANNO)) {
-          let browserWin = BrowserWindowTracker.getMostRecentBrowserWindow();
+          let browserWin = BrowserWindowTracker.getTopWindow();
           if (browserWin) {
             browserWin.openWebPanel(aNode.title, aNode.uri);
             return;
           }
         }
       }
 
       aWindow.openUILinkIn(aNode.uri, aWhere, {
--- a/browser/components/places/tests/browser/browser_bookmarksProperties.js
+++ b/browser/components/places/tests/browser/browser_bookmarksProperties.js
@@ -30,17 +30,17 @@ const TYPE_FOLDER = 0;
 const TYPE_BOOKMARK = 1;
 
 const TEST_URL = "http://www.example.com/";
 
 const DIALOG_URL = "chrome://browser/content/places/bookmarkProperties.xul";
 const DIALOG_URL_MINIMAL_UI = "chrome://browser/content/places/bookmarkProperties2.xul";
 
 ChromeUtils.import("resource:///modules/BrowserWindowTracker.jsm");
-var win = BrowserWindowTracker.getMostRecentBrowserWindow();
+var win = BrowserWindowTracker.getTopWindow();
 
 function add_bookmark(url) {
   return PlacesUtils.bookmarks.insert({
     parentGuid: PlacesUtils.bookmarks.unfiledGuid,
     url,
     title: `bookmark/${url}`
   });
 }
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -1688,19 +1688,19 @@ var SessionStoreInternal = {
     // We'll iterate through the Promise array, yielding each one, so as to
     // provide useful progress information to AsyncShutdown.
     for (let [win, promise] of windowPromises) {
       await promise;
       this._collectWindowData(win);
       progress.current++;
     }
 
-    // We must cache this because _getMostRecentBrowserWindow will always
+    // We must cache this because _getTopWindow will always
     // return null by the time quit-application occurs.
-    var activeWindow = this._getMostRecentBrowserWindow();
+    var activeWindow = this._getTopWindow();
     if (activeWindow)
       this.activeWindowSSiCache = activeWindow.__SSi || "";
     DirtyWindows.clear();
   },
 
   /**
    * On last browser window close
    */
@@ -1768,17 +1768,17 @@ var SessionStoreInternal = {
       }
     }
     // also clear all data about closed windows
     if (this._closedWindows.length) {
       this._closedWindows = [];
       this._closedObjectsChanged = true;
     }
     // give the tabbrowsers a chance to clear their histories first
-    var win = this._getMostRecentBrowserWindow();
+    var win = this._getTopWindow();
     if (win) {
       win.setTimeout(() => SessionSaver.run(), 0);
     } else if (RunState.isRunning) {
       SessionSaver.run();
     }
 
     this._clearRestoringWindows();
     this._saveableClosedWindowData = new WeakSet();
@@ -2267,17 +2267,17 @@ var SessionStoreInternal = {
       throw Components.Exception("No windows", Cr.NS_ERROR_INVALID_ARG);
     }
 
     this._browserSetState = true;
 
     // Make sure the priority queue is emptied out
     this._resetRestoringState();
 
-    var window = this._getMostRecentBrowserWindow();
+    var window = this._getTopWindow();
     if (!window) {
       this._restoreCount = 1;
       this._openWindowWithState(state);
       return;
     }
 
     // close all other browser windows
     this._forEachBrowserWindow(function(aWindow) {
@@ -2795,17 +2795,17 @@ var SessionStoreInternal = {
     // notification when we're done. We want to send "sessionstore-browser-state-restored".
     this._restoreCount = lastSessionState.windows.length;
     this._browserSetState = true;
 
     // We want to re-use the last opened window instead of opening a new one in
     // the case where it's "empty" and not associated with a window in the session.
     // We will do more processing via _prepWindowToRestoreInto if we need to use
     // the lastWindow.
-    let lastWindow = this._getMostRecentBrowserWindow();
+    let lastWindow = this._getTopWindow();
     let canUseLastWindow = lastWindow &&
                            !lastWindow.__SS_lastSessionWindowID;
 
     // global data must be restored before restoreWindow is called so that
     // it happens before observers are notified
     this._globalState.setFromState(lastSessionState);
 
     // Restore session cookies.
@@ -3134,17 +3134,17 @@ var SessionStoreInternal = {
    *        Bool update all windows
    * @returns object
    */
   getCurrentState(aUpdateAll) {
     this._handleClosedWindows().then(() => {
       this._notifyOfClosedObjectsChange();
     });
 
-    var activeWindow = this._getMostRecentBrowserWindow();
+    var activeWindow = this._getTopWindow();
 
     TelemetryStopwatch.start("FX_SESSION_RESTORE_COLLECT_ALL_WINDOWS_DATA_MS");
     if (RunState.isRunning) {
       // update the data for all windows with activities since the last save operation
       this._forEachBrowserWindow(function(aWindow) {
         if (!this._isWindowLoaded(aWindow)) // window data is still in _statesToRestore
           return;
         if (aUpdateAll || DirtyWindows.has(aWindow) || aWindow == activeWindow) {
@@ -4223,18 +4223,18 @@ var SessionStoreInternal = {
       }
     }
   },
 
   /**
    * Returns most recent window
    * @returns Window reference
    */
-  _getMostRecentBrowserWindow: function ssi_getMostRecentBrowserWindow() {
-    return BrowserWindowTracker.getMostRecentBrowserWindow({ allowPopups: true });
+  _getTopWindow: function ssi_getTopWindow() {
+    return BrowserWindowTracker.getTopWindow({ allowPopups: true });
   },
 
   /**
    * Calls onClose for windows that are determined to be closed but aren't
    * destroyed yet, which would otherwise cause getBrowserState and
    * setBrowserState to treat them as open windows.
    */
   _handleClosedWindows: function ssi_handleClosedWindows() {
--- a/browser/components/sessionstore/test/browser_354894_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_354894_perwindowpb.js
@@ -19,24 +19,24 @@
  * not enabled on that platform (platform shim; the application is kept running
  * although there are no windows left)
  * @note There is a difference when closing a browser window with
  * BrowserTryToCloseWindow() as opposed to close(). The former will make
  * nsSessionStore restore a window next time it gets a chance and will post
  * notifications. The latter won't.
  */
 
-// The rejection "BrowserWindowTracker.getMostRecentBrowserWindow(...) is null" is left
+// The rejection "BrowserWindowTracker.getTopWindow(...) is null" is left
 // unhandled in some cases. This bug should be fixed, but for the moment this
 // file is whitelisted.
 //
 // NOTE: Whitelisting a class of rejections should be limited. Normally you
 //       should use "expectUncaughtRejection" to flag individual failures.
 ChromeUtils.import("resource://testing-common/PromiseTestUtils.jsm", this);
-PromiseTestUtils.whitelistRejectionsGlobally(/getMostRecentBrowserWindow/);
+PromiseTestUtils.whitelistRejectionsGlobally(/getTopWindow/);
 
 // Some urls that might be opened in tabs and/or popups
 // Do not use about:blank:
 // That one is reserved for special purposes in the tests
 const TEST_URLS = ["about:mozilla", "about:buildconfig"];
 
 // Number of -request notifications to except
 // remember to adjust when adding new tests
--- a/browser/components/translation/Translation.jsm
+++ b/browser/components/translation/Translation.jsm
@@ -70,17 +70,17 @@ var Translation = {
 
     if (trUI.shouldShowInfoBar(aBrowser.currentURI))
       trUI.showTranslationInfoBar();
   },
 
   openProviderAttribution() {
     let attribution = this.supportedEngines[this.translationEngine];
     ChromeUtils.import("resource:///modules/BrowserWindowTracker.jsm");
-    BrowserWindowTracker.getMostRecentBrowserWindow().openUILinkIn(attribution, "tab");
+    BrowserWindowTracker.getTopWindow().openUILinkIn(attribution, "tab");
   },
 
   /**
    * The list of translation engines and their attributions.
    */
   supportedEngines: {
     "bing": "http://aka.ms/MicrosoftTranslatorAttribution",
     "yandex": "http://translate.yandex.com/"
--- a/browser/extensions/formautofill/FormAutofillParent.jsm
+++ b/browser/extensions/formautofill/FormAutofillParent.jsm
@@ -236,17 +236,17 @@ FormAutofillParent.prototype = {
         data.guids.forEach(guid => this.profileStorage.creditCards.remove(guid));
         break;
       }
       case "FormAutofill:OnFormSubmit": {
         this._onFormSubmit(data, target);
         break;
       }
       case "FormAutofill:OpenPreferences": {
-        const win = BrowserWindowTracker.getMostRecentBrowserWindow();
+        const win = BrowserWindowTracker.getTopWindow();
         win.openPreferences("panePrivacy", {origin: "autofillFooter"});
         break;
       }
       case "FormAutofill:GetDecryptedString": {
         let {cipherText, reauth} = data;
         let string;
         try {
           string = await MasterPassword.decrypt(cipherText, reauth);
--- a/browser/modules/BrowserUITelemetry.jsm
+++ b/browser/modules/BrowserUITelemetry.jsm
@@ -273,17 +273,17 @@ var BrowserUITelemetry = {
   _firstWindowMeasurements: null,
   _gatherFirstWindowMeasurements() {
     // We'll gather measurements as soon as the session has restored.
     // We do this here instead of waiting for UITelemetry to ask for
     // our measurements because at that point all browser windows have
     // probably been closed, since the vast majority of saved-session
     // pings are gathered during shutdown.
     Services.search.init(rv => {
-      let win = BrowserWindowTracker.getMostRecentBrowserWindow({
+      let win = BrowserWindowTracker.getTopWindow({
         private: false,
         allowPopups: false,
       });
       // If there are no such windows, we're out of luck. :(
       this._firstWindowMeasurements = win ? this._getWindowMeasurements(win, rv)
                                           : {};
     });
   },
--- a/browser/modules/BrowserWindowTracker.jsm
+++ b/browser/modules/BrowserWindowTracker.jsm
@@ -32,26 +32,26 @@ var _lastTopLevelWindowID = 0;
 
 // Global methods
 function debug(s) {
   if (DEBUG) {
     dump("-*- UpdateTopLevelContentWindowIDHelper: " + s + "\n");
   }
 }
 
-function _updateCurrentContentOuterWindowID(aBrowser) {
-  if (!aBrowser.outerWindowID ||
-      aBrowser.outerWindowID === _lastTopLevelWindowID) {
+function _updateCurrentContentOuterWindowID(browser) {
+  if (!browser.outerWindowID ||
+      browser.outerWindowID === _lastTopLevelWindowID) {
     return;
   }
 
-  debug("Current window uri=" + aBrowser.currentURI.spec +
-        " id=" + aBrowser.outerWindowID);
+  debug("Current window uri=" + browser.currentURI.spec +
+        " id=" + browser.outerWindowID);
 
-  _lastTopLevelWindowID = aBrowser.outerWindowID;
+  _lastTopLevelWindowID = browser.outerWindowID;
   let windowIDWrapper = Components.classes["@mozilla.org/supports-PRUint64;1"]
                           .createInstance(Ci.nsISupportsPRUint64);
   windowIDWrapper.data = _lastTopLevelWindowID;
   Services.obs.notifyObservers(windowIDWrapper,
                                "net:current-toplevel-outer-content-windowid");
 }
 
 function _handleEvent(aEvent) {
@@ -68,90 +68,90 @@ function _handleEvent(aEvent) {
       WindowHelper.onActivate(aEvent.target);
       break;
     case "unload":
       WindowHelper.removeWindow(aEvent.currentTarget);
       break;
   }
 }
 
-function _handleMessage(aMessage) {
-  let browser = aMessage.target;
-  if (aMessage.name === "Browser:Init" &&
+function _handleMessage(message) {
+  let browser = message.target;
+  if (message.name === "Browser:Init" &&
       browser === browser.ownerGlobal.gBrowser.selectedBrowser) {
     _updateCurrentContentOuterWindowID(browser);
   }
 }
 
 // Methods that impact a window. Put into single object for organization.
 var WindowHelper = {
-  addWindow: function NP_WH_addWindow(aWindow) {
+  addWindow(window) {
     // Add event listeners
     TAB_EVENTS.forEach(function(event) {
-      aWindow.gBrowser.tabContainer.addEventListener(event, _handleEvent);
+      window.gBrowser.tabContainer.addEventListener(event, _handleEvent);
     });
     WINDOW_EVENTS.forEach(function(event) {
-      aWindow.addEventListener(event, _handleEvent);
+      window.addEventListener(event, _handleEvent);
     });
 
-    let messageManager = aWindow.getGroupMessageManager("browsers");
+    let messageManager = window.getGroupMessageManager("browsers");
     messageManager.addMessageListener("Browser:Init", _handleMessage);
 
     // This gets called AFTER activate event, so if this is the focused window
     // we want to activate it.
-    if (aWindow == _focusManager.activeWindow)
-      this.handleFocusedWindow(aWindow);
+    if (window == _focusManager.activeWindow)
+      this.handleFocusedWindow(window);
 
     // Update the selected tab's content outer window ID.
-    _updateCurrentContentOuterWindowID(aWindow.gBrowser.selectedBrowser);
+    _updateCurrentContentOuterWindowID(window.gBrowser.selectedBrowser);
   },
 
-  removeWindow: function NP_WH_removeWindow(aWindow) {
-    if (aWindow == _lastFocusedWindow)
+  removeWindow(window) {
+    if (window == _lastFocusedWindow)
       _lastFocusedWindow = null;
 
     // Remove the event listeners
     TAB_EVENTS.forEach(function(event) {
-      aWindow.gBrowser.tabContainer.removeEventListener(event, _handleEvent);
+      window.gBrowser.tabContainer.removeEventListener(event, _handleEvent);
     });
     WINDOW_EVENTS.forEach(function(event) {
-      aWindow.removeEventListener(event, _handleEvent);
+      window.removeEventListener(event, _handleEvent);
     });
 
-    let messageManager = aWindow.getGroupMessageManager("browsers");
+    let messageManager = window.getGroupMessageManager("browsers");
     messageManager.removeMessageListener("Browser:Init", _handleMessage);
   },
 
-  onActivate: function NP_WH_onActivate(aWindow, aHasFocus) {
+  onActivate(window, hasFocus) {
     // If this window was the last focused window, we don't need to do anything
-    if (aWindow == _lastFocusedWindow)
+    if (window == _lastFocusedWindow)
       return;
 
-    this.handleFocusedWindow(aWindow);
+    this.handleFocusedWindow(window);
 
-    _updateCurrentContentOuterWindowID(aWindow.gBrowser.selectedBrowser);
+    _updateCurrentContentOuterWindowID(window.gBrowser.selectedBrowser);
   },
 
-  handleFocusedWindow: function NP_WH_handleFocusedWindow(aWindow) {
-    // aWindow is now focused
-    _lastFocusedWindow = aWindow;
+  handleFocusedWindow(window) {
+    // window is now focused
+    _lastFocusedWindow = window;
   },
 
-  getMostRecentBrowserWindow: function RW_getMostRecentBrowserWindow(aOptions) {
-    let checkPrivacy = typeof aOptions == "object" &&
-                       "private" in aOptions;
+  getTopWindow(options) {
+    let checkPrivacy = typeof options == "object" &&
+                       "private" in options;
 
-    let allowPopups = typeof aOptions == "object" && !!aOptions.allowPopups;
+    let allowPopups = typeof options == "object" && !!options.allowPopups;
 
     function isSuitableBrowserWindow(win) {
       return (!win.closed &&
               (allowPopups || win.toolbar.visible) &&
               (!checkPrivacy ||
                PrivateBrowsingUtils.permanentPrivateBrowsing ||
-               PrivateBrowsingUtils.isWindowPrivate(win) == aOptions.private));
+               PrivateBrowsingUtils.isWindowPrivate(win) == options.private));
     }
 
     let broken_wm_z_order =
       AppConstants.platform != "macosx" && AppConstants.platform != "win";
 
     if (broken_wm_z_order) {
       let win = Services.wm.getMostRecentWindow("navigator:browser");
 
@@ -177,22 +177,22 @@ var WindowHelper = {
     return null;
   }
 };
 
 this.BrowserWindowTracker = {
   /**
    * Get the most recent browser window.
    *
-   * @param aOptions an object accepting the arguments for the search.
+   * @param options an object accepting the arguments for the search.
    *        * private: true to restrict the search to private windows
    *            only, false to restrict the search to non-private only.
    *            Omit the property to search in both groups.
    *        * allowPopups: true if popup windows are permissable.
    */
-  getMostRecentBrowserWindow(options) {
-    return WindowHelper.getMostRecentBrowserWindow(options);
+  getTopWindow(options) {
+    return WindowHelper.getTopWindow(options);
   },
 
   track(window) {
     return WindowHelper.addWindow(window);
   }
 };
--- a/browser/modules/ContentCrashHandlers.jsm
+++ b/browser/modules/ContentCrashHandlers.jsm
@@ -829,17 +829,17 @@ var UnsubmittedCrashHandler = {
    *        onAction (function, optional)
    *          A callback to fire once the user performs an
    *          action on the notification bar (this includes
    *          dismissing the notification).
    *
    * @returns The <xul:notification> if one is shown. null otherwise.
    */
   show({ notificationID, message, reportIDs, onAction }) {
-    let chromeWin = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let chromeWin = BrowserWindowTracker.getTopWindow();
     if (!chromeWin) {
       // Can't show a notification in this case. We'll hopefully
       // get another opportunity to have the user submit their
       // crash reports later.
       return null;
     }
 
     let nb =  chromeWin.document.getElementById("global-notificationbox");
--- a/browser/modules/ExtensionsUI.jsm
+++ b/browser/modules/ExtensionsUI.jsm
@@ -81,17 +81,17 @@ var ExtensionsUI = {
 
       for (let addon of sideloaded) {
         this.sideloaded.add(addon);
       }
         this._updateNotifications();
     } else {
       // This and all the accompanying about:newaddon code can eventually
       // be removed.  See bug 1331521.
-      let win = BrowserWindowTracker.getMostRecentBrowserWindow();
+      let win = BrowserWindowTracker.getTopWindow();
       for (let addon of sideloaded) {
         win.openUILinkIn(`about:newaddon?id=${addon.id}`, "tab");
       }
     }
   },
 
   _updateNotifications() {
     if (this.sideloaded.size + this.updates.size == 0) {
--- a/browser/modules/Feeds.jsm
+++ b/browser/modules/Feeds.jsm
@@ -38,17 +38,17 @@ var Feeds = {
       case "WCCR:setAutoHandler": {
         let registrar = Cc["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"].
                           getService(Ci.nsIWebContentConverterService);
         registrar.setAutoHandler(data.contentType, data.handler);
         break;
       }
 
       case "FeedConverter:addLiveBookmark": {
-        let topWindow = BrowserWindowTracker.getMostRecentBrowserWindow();
+        let topWindow = BrowserWindowTracker.getTopWindow();
         topWindow.PlacesCommandHook.addLiveBookmark(data.spec, data.title, data.subtitle)
                                    .catch(Components.utils.reportError);
         break;
       }
     }
   },
 
   /**
--- a/toolkit/components/telemetry/TelemetryReportingPolicy.jsm
+++ b/toolkit/components/telemetry/TelemetryReportingPolicy.jsm
@@ -432,17 +432,17 @@ var TelemetryReportingPolicyImpl = {
     if (!firstRunPolicyURL) {
       return false;
     }
     firstRunPolicyURL = Services.urlFormatter.formatURL(firstRunPolicyURL);
 
     let win;
     try {
       const { BrowserWindowTracker } = ChromeUtils.import("resource:///modules/BrowserWindowTracker.jsm", {});
-      win = BrowserWindowTracker.getMostRecentBrowserWindow();
+      win = BrowserWindowTracker.getTopWindow();
     } catch (e) {}
 
     if (!win) {
       this._log.info("Couldn't find browser window to open first-run page. Falling back to infobar.");
       return false;
     }
 
     // We'll consider the user notified once the privacy policy has been loaded
--- a/toolkit/modules/addons/WebNavigation.jsm
+++ b/toolkit/modules/addons/WebNavigation.jsm
@@ -211,17 +211,17 @@ var Manager = {
    * @param {boolean} [tabTransitionData.auto_bookmark]
    * @param {boolean} [tabTransitionData.from_address_bar]
    * @param {boolean} [tabTransitionData.generated]
    * @param {boolean} [tabTransitionData.keyword]
    * @param {boolean} [tabTransitionData.link]
    * @param {boolean} [tabTransitionData.typed]
    */
   setRecentTabTransitionData(tabTransitionData) {
-    let window = BrowserWindowTracker.getMostRecentBrowserWindow();
+    let window = BrowserWindowTracker.getTopWindow();
     if (window && window.gBrowser && window.gBrowser.selectedTab &&
         window.gBrowser.selectedTab.linkedBrowser) {
       let browser = window.gBrowser.selectedTab.linkedBrowser;
 
       // Get recent tab transition data to update if any.
       let prevData = this.getAndForgetRecentTabTransitionData(browser);
 
       let newData = Object.assign(