Bug 1071638 - Add test to ensure there are no uninterruptible reflows when loading about:newtab r=adw
authorTim Taubert <ttaubert@mozilla.com>
Tue, 23 Sep 2014 17:48:38 +0200
changeset 230454 77ae1deb677a891e5a6bec2648e1fd5383cd981a
parent 230453 f191b431571c54d96c8ba73ea51ac02c14095e7f
child 230455 f26dcd7a38ac765124b1ccf84ff80de22a458466
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1071638
milestone35.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 1071638 - Add test to ensure there are no uninterruptible reflows when loading about:newtab r=adw
browser/base/content/test/general/browser_tabopen_reflows.js
browser/base/content/test/newtab/browser.ini
browser/base/content/test/newtab/browser_newtab_reflow_load.js
browser/base/content/test/newtab/content-reflows.js
--- a/browser/base/content/test/general/browser_tabopen_reflows.js
+++ b/browser/base/content/test/general/browser_tabopen_reflows.js
@@ -18,19 +18,16 @@ const EXPECTED_REFLOWS = [
     "updateCurrentBrowser@chrome://browser/content/tabbrowser.xml|" +
     "onselect@chrome://browser/content/browser.xul|",
 
   // switching focus in openLinkIn() causes reflows
   "openLinkIn@chrome://browser/content/utilityOverlay.js|" +
     "openUILinkIn@chrome://browser/content/utilityOverlay.js|" +
     "BrowserOpenTab@chrome://browser/content/browser.js|",
 
-  // unpreloaded newtab pages explicitly waits for reflows for sizing
-  "gPage.onPageFirstVisible/checkSizing/<@chrome://browser/content/newtab/newTab.js|",
-
   // accessing element.scrollPosition in _fillTrailingGap() flushes layout
   "get_scrollPosition@chrome://global/content/bindings/scrollbox.xml|" +
     "_fillTrailingGap@chrome://browser/content/tabbrowser.xml|" +
     "_handleNewTab@chrome://browser/content/tabbrowser.xml|" +
     "onxbltransitionend@chrome://browser/content/tabbrowser.xml|",
 
   // The TabView iframe causes reflows in the parent document.
   "iQClass_height@chrome://browser/content/tabview.js|" +
--- a/browser/base/content/test/newtab/browser.ini
+++ b/browser/base/content/test/newtab/browser.ini
@@ -23,16 +23,19 @@ skip-if = os == "mac" # Intermittent fai
 [browser_newtab_drag_drop.js]
 [browser_newtab_drag_drop_ext.js]
 [browser_newtab_drop_preview.js]
 [browser_newtab_enhanced.js]
 [browser_newtab_focus.js]
 [browser_newtab_intro.js]
 [browser_newtab_perwindow_private_browsing.js]
 [browser_newtab_reportLinkAction.js]
+[browser_newtab_reflow_load.js]
+support-files =
+  content-reflows.js
 [browser_newtab_reset.js]
 [browser_newtab_search.js]
 support-files =
   searchEngineNoLogo.xml
   searchEngine1xLogo.xml
   searchEngine2xLogo.xml
   searchEngine1x2xLogo.xml
   ../general/searchSuggestionEngine.xml
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/newtab/browser_newtab_reflow_load.js
@@ -0,0 +1,38 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const FRAME_SCRIPT = getRootDirectory(gTestPath) + "content-reflows.js";
+const ADDITIONAL_WAIT_MS = 2000;
+
+/*
+ * Ensure that loading about:newtab doesn't cause uninterruptible reflows.
+ */
+function runTests() {
+  gBrowser.selectedTab = gBrowser.addTab("about:blank", {animate: false});
+  let browser = gBrowser.selectedBrowser;
+  yield whenBrowserLoaded(browser);
+
+  let mm = browser.messageManager;
+  mm.loadFrameScript(FRAME_SCRIPT, true);
+  mm.addMessageListener("newtab-reflow", ({data: stack}) => {
+    ok(false, `unexpected uninterruptible reflow ${stack}`);
+  });
+
+  browser.loadURI("about:newtab");
+  yield whenBrowserLoaded(browser);
+
+  // Wait some more to catch sync reflows after the page has loaded.
+  yield setTimeout(TestRunner.next, ADDITIONAL_WAIT_MS);
+
+  // Clean up.
+  gBrowser.removeCurrentTab({animate: false});
+}
+
+function whenBrowserLoaded(browser) {
+  browser.addEventListener("load", function onLoad() {
+    browser.removeEventListener("load", onLoad, true);
+    executeSoon(TestRunner.next);
+  }, true);
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/newtab/content-reflows.js
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+(function () {
+  "use strict";
+
+  const Ci = Components.interfaces;
+
+  docShell.addWeakReflowObserver({
+    reflow() {
+      // Gather information about the current code path.
+      let path = (new Error().stack).split("\n").slice(1).join("\n");
+      if (path) {
+        sendSyncMessage("newtab-reflow", path);
+      }
+    },
+
+    reflowInterruptible() {
+      // We're not interested in interruptible reflows.
+    },
+
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver,
+                                           Ci.nsISupportsWeakReference])
+  });
+})();