Bug 990812 - Restrict sessionstore, tabview, and browser frame scripts to tabbrowser browsers r=adw
authorTim Taubert <ttaubert@mozilla.com>
Fri, 23 May 2014 14:22:36 +0200
changeset 185255 f35d007a22a76b6a7693eafd381f967ed638d86c
parent 185254 c17e7e3cd7294871cc33a107a3973f26ec7c02b5
child 185256 d943461254536df14e6bc1a6160de92347221c33
push id26846
push usercbook@mozilla.com
push dateWed, 28 May 2014 12:22:26 +0000
treeherderautoland@96838c90ebac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs990812
milestone32.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 990812 - Restrict sessionstore, tabview, and browser frame scripts to tabbrowser browsers r=adw
browser/base/content/browser.js
browser/base/content/tabbrowser.xml
browser/components/sessionstore/src/SessionStore.jsm
browser/components/sessionstore/test/browser_privatetabs.js
browser/components/tabview/ui.js
browser/modules/BrowserNewTabPreloader.jsm
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -779,17 +779,18 @@ var gBrowserInit = {
     // These routines add message listeners. They must run before
     // loading the frame script to ensure that we don't miss any
     // message sent between when the frame script is loaded and when
     // the listener is registered.
     DOMLinkHandler.init();
     gPageStyleMenu.init();
     LanguageDetectionListener.init();
 
-    messageManager.loadFrameScript("chrome://browser/content/content.js", true);
+    let mm = window.getGroupMessageManager("browsers");
+    mm.loadFrameScript("chrome://browser/content/content.js", true);
 
     // initialize observers and listeners
     // and give C++ access to gBrowser
     XULBrowserWindow.init();
     window.QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(nsIWebNavigation)
           .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
           .QueryInterface(Ci.nsIInterfaceRequestor)
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -29,17 +29,17 @@
       <xul:tabbox anonid="tabbox" class="tabbrowser-tabbox"
                   flex="1" eventnode="document" xbl:inherits="handleCtrlPageUpDown"
                   onselect="if (event.target.localName == 'tabpanels') this.parentNode.updateCurrentBrowser();">
         <xul:tabpanels flex="1" class="plain" selectedIndex="0" anonid="panelcontainer">
           <xul:notificationbox flex="1">
             <xul:hbox flex="1" class="browserSidebarContainer">
               <xul:vbox flex="1" class="browserContainer">
                 <xul:stack flex="1" class="browserStack" anonid="browserStack">
-                  <xul:browser anonid="initialBrowser" type="content-primary" message="true"
+                  <xul:browser anonid="initialBrowser" type="content-primary" message="true" messagemanagergroup="browsers"
                                xbl:inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu,autocompletepopup,selectpopup"/>
                 </xul:stack>
               </xul:vbox>
             </xul:hbox>
           </xul:notificationbox>
         </xul:tabpanels>
       </xul:tabbox>
       <children/>
@@ -1524,16 +1524,17 @@
             if (aOwner)
               t.owner = aOwner;
 
             var b = document.createElementNS(
               "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                              "browser");
             b.setAttribute("type", "content-targetable");
             b.setAttribute("message", "true");
+            b.setAttribute("messagemanagergroup", "browsers");
             b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
             b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
 
             if (remote)
               b.setAttribute("remote", "true");
 
             if (window.gShowPageResizers && window.windowState == window.STATE_NORMAL) {
               b.setAttribute("showresizer", "true");
--- a/browser/components/sessionstore/src/SessionStore.jsm
+++ b/browser/components/sessionstore/src/SessionStore.jsm
@@ -759,17 +759,17 @@ let SessionStoreInternal = {
     // ignore windows opened while shutting down
     if (this._loadState == STATE_QUITTING)
       return;
 
     // Assign the window a unique identifier we can use to reference
     // internal data about the window.
     aWindow.__SSi = this._generateWindowID();
 
-    let mm = aWindow.messageManager;
+    let mm = aWindow.getGroupMessageManager("browsers");
     MESSAGES.forEach(msg => mm.addMessageListener(msg, this));
 
     // Load the frame script after registering listeners.
     mm.loadFrameScript("chrome://browser/content/content-sessionStore.js", true);
 
     // and create its data object
     this._windows[aWindow.__SSi] = { tabs: [], selected: 0, _closedTabs: [], busy: false };
 
@@ -1088,17 +1088,17 @@ let SessionStoreInternal = {
 
     for (let i = 0; i < tabbrowser.tabs.length; i++) {
       this.onTabRemove(aWindow, tabbrowser.tabs[i], true);
     }
 
     // Cache the window state until it is completely gone.
     DyingWindowCache.set(aWindow, winData);
 
-    let mm = aWindow.messageManager;
+    let mm = aWindow.getGroupMessageManager("browsers");
     MESSAGES.forEach(msg => mm.removeMessageListener(msg, this));
 
     delete aWindow.__SSi;
   },
 
   /**
    * On quit application requested
    */
--- a/browser/components/sessionstore/test/browser_privatetabs.js
+++ b/browser/components/sessionstore/test/browser_privatetabs.js
@@ -71,17 +71,18 @@ add_task(function () {
 
   // Clear the list of closed windows.
   while (ss.getClosedWindowCount()) {
     ss.forgetClosedWindow(0);
   }
 
   // Create a new window to attach our frame script to.
   let win = yield promiseNewWindowLoaded();
-  win.messageManager.loadFrameScript(FRAME_SCRIPT, true);
+  let mm = win.getGroupMessageManager("browsers");
+  mm.loadFrameScript(FRAME_SCRIPT, true);
 
   // Create a new tab in the new window that will load the frame script.
   let tab = win.gBrowser.addTab("about:mozilla");
   let browser = tab.linkedBrowser;
   yield promiseBrowserLoaded(browser);
   SyncHandlers.get(browser).flush();
 
   // Check that we consider the tab as private.
--- a/browser/components/tabview/ui.js
+++ b/browser/components/tabview/ui.js
@@ -169,17 +169,17 @@ let UI = {
         gTabView.firstUseExperienced = true;
       });
 
       iQ(window).bind("unload", function() {
         self.uninit();
       });
 
       // ___ setup DOMWillOpenModalDialog message handler
-      let mm = gWindow.messageManager;
+      let mm = gWindow.getGroupMessageManager("browsers");
       let callback = this._onDOMWillOpenModalDialog.bind(this);
       mm.addMessageListener("Panorama:DOMWillOpenModalDialog", callback);
 
       this._cleanupFunctions.push(function () {
         mm.removeMessageListener("Panorama:DOMWillOpenModalDialog", callback);
       });
 
       // ___ setup key handlers
@@ -230,17 +230,17 @@ let UI = {
 
       gWindow.addEventListener("SSWindowClosing", onWindowClosing);
       this._cleanupFunctions.push(function () {
         gWindow.removeEventListener("SSWindowClosing", onWindowClosing);
       });
 
       // ___ load frame script
       let frameScript = "chrome://browser/content/tabview-content.js";
-      gWindow.messageManager.loadFrameScript(frameScript, true);
+      mm.loadFrameScript(frameScript, true);
 
       // ___ Done
       this._frameInitialized = true;
       this._save();
 
       // fire an iframe initialized event so everyone knows tab view is 
       // initialized.
       let event = document.createEvent("Events");
--- a/browser/modules/BrowserNewTabPreloader.jsm
+++ b/browser/modules/BrowserNewTabPreloader.jsm
@@ -315,19 +315,19 @@ HiddenBrowser.prototype = {
 
     if (!tabbrowser) {
       return false;
     }
 
     // Swap docShells.
     tabbrowser.swapNewTabWithBrowser(aTab, this._browser);
 
-    // Load all default frame scripts attached to the target window.
+    // Load all delayed frame scripts attached to the "browers" message manager.
     let mm = aTab.linkedBrowser.messageManager;
-    let scripts = win.messageManager.getDelayedFrameScripts();
+    let scripts = win.getGroupMessageManager("browsers").getDelayedFrameScripts();
     Array.forEach(scripts, ([script, runGlobal]) => mm.loadFrameScript(script, true, runGlobal));
 
     // Remove the browser, it will be recreated by a timer.
     this._removeBrowser();
 
     // Start a timer that will kick off preloading the next newtab page.
     this._timer = createTimer(this, PRELOADER_INTERVAL_MS);