Bug 1090456: Use the content script to wait for tab load for e10s support. r=mconley
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 29 Oct 2014 12:10:56 -0700
changeset 213102 5a9f63201e5cdb7ff173f64810376f6a6c1b8850
parent 213101 16fe52c3df5f107283e0176096d17606a2682a82
child 213103 2381858cf8cfacdbc3492f17f8e5ec57028722a7
push id51143
push usercbook@mozilla.com
push dateThu, 30 Oct 2014 14:14:04 +0000
treeherdermozilla-inbound@e80345c5bf6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1090456
milestone36.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 1090456: Use the content script to wait for tab load for e10s support. r=mconley
browser/components/tabview/content.js
browser/components/tabview/test/browser_tabview_bug587276.js
browser/components/tabview/ui.js
--- a/browser/components/tabview/content.js
+++ b/browser/components/tabview/content.js
@@ -69,15 +69,22 @@ let WindowMessageHandler = {
 
   // ----------
   // Function: isImageDocument
   // Checks if the currently active document is an image document or not.
   isImageDocument: function WMH_isImageDocument(cx) {
     let isImageDocument = (content.document instanceof Ci.nsIImageDocument);
 
     sendAsyncMessage(cx.name, {isImageDocument: isImageDocument});
-  }
+  },
+
+  waitForDocumentLoad: function WMH_waitForDocumentLoad() {
+    addEventListener("load", function listener() {
+      removeEventListener("load", listener, true);
+      sendAsyncMessage("Panorama:documentLoaded");
+    }, true);
+  },
 };
 
 // add message listeners
 addMessageListener("Panorama:isDocumentLoaded", WindowMessageHandler.isDocumentLoaded);
 addMessageListener("Panorama:isImageDocument", WindowMessageHandler.isImageDocument);
-
+addMessageListener("Panorama:waitForDocumentLoad", WindowMessageHandler.waitForDocumentLoad);
--- a/browser/components/tabview/test/browser_tabview_bug587276.js
+++ b/browser/components/tabview/test/browser_tabview_bug587276.js
@@ -57,19 +57,23 @@ function test4() {
   let onTabClose = function() {
     gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, true);
     executeSoon(function() {
       is(gBrowser.tabs.length, 1, "There is one tab after removing one");
 
       EventUtils.synthesizeKey("t", { accelKey: true, shiftKey: true }, contentWindow);
       is(gBrowser.tabs.length, 2, "There are two tabs after restoring one");
 
-      gBrowser.tabs[0].linkedBrowser.loadURI("about:blank");
-      gBrowser.selectedTab = gBrowser.tabs[0];
-      test8();
+      gBrowser.tabs[1].linkedBrowser.addEventListener("load", function listener() {
+        gBrowser.tabs[1].linkedBrowser.removeEventListener("load", listener, true);
+
+        gBrowser.tabs[0].linkedBrowser.loadURI("about:blank");
+        gBrowser.selectedTab = gBrowser.tabs[0];
+        test8();
+      }, true);
     });
   };
   gBrowser.tabContainer.addEventListener("TabClose", onTabClose, true);
   gBrowser.removeTab(gBrowser.tabs[1]);
 }
 
 // below key combination shouldn't trigger actions in tabview UI
 function test8() {
--- a/browser/components/tabview/ui.js
+++ b/browser/components/tabview/ui.js
@@ -792,20 +792,21 @@ let UI = {
         return;
       }
       if (this._closedLastVisibleTab ||
           (this._closedSelectedTabInTabView && !this.closedLastTabInTabView) ||
           this.restoredClosedTab) {
         if (this.restoredClosedTab) {
           // when the tab view UI is being displayed, update the thumb for the 
           // restored closed tab after the page load
-          tab.linkedBrowser.addEventListener("load", function onLoad(event) {
-            tab.linkedBrowser.removeEventListener("load", onLoad, true);
+          tab.linkedBrowser.messageManager.addMessageListener("Panorama:documentLoaded", function onLoad() {
+            tab.linkedBrowser.messageManager.removeMessageListener("Panorama:documentLoaded", onLoad);
             TabItems._update(tab);
-          }, true);
+          });
+          tab.linkedBrowser.messageManager.sendAsyncMessage("Panorama:waitForDocumentLoad");
         }
         this._closedLastVisibleTab = false;
         this._closedSelectedTabInTabView = false;
         this.closedLastTabInTabView = false;
         this.restoredClosedTab = false;
         return;
       }
     }