Bug 881590 - Don't cancel loads when preloading in the hiddenWindow; r=jaws
☠☠ backed out by 716233c37b18 ☠ ☠
authorTim Taubert <ttaubert@mozilla.com>
Mon, 17 Jun 2013 19:46:55 +0200
changeset 135333 8ee18c5171278f7b679125f17639e021f0770596
parent 135332 3893f49e70b0330210257808ddcd36ce21890357
child 135334 825e5d09c5ecf032142e94b53d8958727f83ca12
push id24838
push userttaubert@mozilla.com
push dateTue, 18 Jun 2013 10:32:18 +0000
treeherderautoland@bd9a40076aa6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs881590
milestone24.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 881590 - Don't cancel loads when preloading in the hiddenWindow; r=jaws
browser/modules/BrowserNewTabPreloader.jsm
--- a/browser/modules/BrowserNewTabPreloader.jsm
+++ b/browser/modules/BrowserNewTabPreloader.jsm
@@ -289,18 +289,18 @@ let HiddenBrowsers = {
 
 function HiddenBrowser(width, height) {
   this.resize(width, height);
 
   HostFrame.get(aFrame => {
     let doc = aFrame.document;
     this._browser = doc.createElementNS(XUL_NS, "browser");
     this._browser.setAttribute("type", "content");
+    this._browser.setAttribute("src", NEWTAB_URL);
     doc.getElementById("win").appendChild(this._browser);
-    this.preload();
   });
 }
 
 HiddenBrowser.prototype = {
   _width: null,
   _height: null,
   _timer: null,
 
@@ -328,26 +328,16 @@ HiddenBrowser.prototype = {
     this._timer = createTimer(this, PRELOADER_INTERVAL_MS);
 
     // Signal that we swapped docShells.
     return true;
   },
 
   observe: function () {
     this._timer = null;
-    this.preload();
-  },
-
-  preload: function () {
-    if (!this._browser) {
-      return;
-    }
-
-    // Make sure the browser has the right size.
-    this.resize(this._width, this._height);
 
     // Start pre-loading the new tab page.
     this._browser.loadURI(NEWTAB_URL);
   },
 
   resize: function (width, height) {
     if (this._browser) {
       this._browser.style.width = width + "px";
@@ -388,30 +378,32 @@ let HostFrame = {
       this._loading = true;
     } else {
       Services.tm.currentThread.dispatch(() => HostFrame.get(callback),
                                          Ci.nsIThread.DISPATCH_NORMAL);
     }
   },
 
   destroy: function () {
-    this._frame = null;
+    if (this._frame) {
+      this._frame.remove();
+      this._frame = null;
+    }
   },
 
   _create: function (callback) {
     let doc = this.hiddenDOMDocument;
     let iframe = doc.createElementNS(HTML_NS, "iframe");
     doc.documentElement.appendChild(iframe);
 
-    let frame = iframe.contentWindow;
-    let docShell = frame.QueryInterface(Ci.nsIInterfaceRequestor)
-                        .getInterface(Ci.nsIDocShell);
+    iframe.addEventListener("load", function onload() {
+      iframe.removeEventListener("load", onload, true);
+
+      let frame = iframe.contentWindow;
+      frame.location = XUL_PAGE;
 
-    docShell.createAboutBlankContentViewer(null);
-    frame.location = XUL_PAGE;
-
-    let eventHandler = docShell.chromeEventHandler;
-    eventHandler.addEventListener("DOMContentLoaded", function onLoad() {
-      eventHandler.removeEventListener("DOMContentLoaded", onLoad, false);
-      callback(HostFrame._frame = frame);
-    }, false);
+      iframe.addEventListener("load", function onload() {
+        iframe.removeEventListener("load", onload, true);
+        callback(HostFrame._frame = frame);
+      }, true);
+    }, true);
   }
 };