Backed out changeset 8ee18c517127 (bug 881590)
authorTim Taubert <ttaubert@mozilla.com>
Mon, 17 Jun 2013 20:46:25 +0200
changeset 135242 716233c37b180233675fc98bf147c2522775b083
parent 135241 801ada6caf7cd1676be96e619c682c922390a2ed
child 135333 70f7e8cded0cbcf91e78870b36e29fc47e7f3e43
push id1751
push userttaubert@mozilla.com
push dateMon, 17 Jun 2013 18:46:37 +0000
treeherderfx-team@716233c37b18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs881590
milestone24.0a1
backs out8ee18c5171278f7b679125f17639e021f0770596
Backed out changeset 8ee18c517127 (bug 881590)
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,16 +328,26 @@ 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";
@@ -378,32 +388,30 @@ let HostFrame = {
       this._loading = true;
     } else {
       Services.tm.currentThread.dispatch(() => HostFrame.get(callback),
                                          Ci.nsIThread.DISPATCH_NORMAL);
     }
   },
 
   destroy: function () {
-    if (this._frame) {
-      this._frame.remove();
-      this._frame = null;
-    }
+    this._frame = null;
   },
 
   _create: function (callback) {
     let doc = this.hiddenDOMDocument;
     let iframe = doc.createElementNS(HTML_NS, "iframe");
     doc.documentElement.appendChild(iframe);
 
-    iframe.addEventListener("load", function onload() {
-      iframe.removeEventListener("load", onload, true);
-
-      let frame = iframe.contentWindow;
-      frame.location = XUL_PAGE;
+    let frame = iframe.contentWindow;
+    let docShell = frame.QueryInterface(Ci.nsIInterfaceRequestor)
+                        .getInterface(Ci.nsIDocShell);
 
-      iframe.addEventListener("load", function onload() {
-        iframe.removeEventListener("load", onload, true);
-        callback(HostFrame._frame = frame);
-      }, true);
-    }, true);
+    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);
   }
 };