Bug 827976 - Test that the hidden window is not loaded before first paint. r=florian
authorFelipe Gomes <felipc@gmail.com>
Mon, 04 Mar 2019 18:53:38 +0000
changeset 520357 cd731fe8a50f93d96d36698d84a838d382df458b
parent 520356 5f4cebc62cbd61b5062724f78dfb9cfadaf84a3f
child 520358 6013e1f3b6486837ce4ec98678afb6a39f37b10c
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs827976
milestone67.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 827976 - Test that the hidden window is not loaded before first paint. r=florian Differential Revision: https://phabricator.services.mozilla.com/D21087
browser/base/content/test/performance/browser.ini
browser/base/content/test/performance/browser_startup_hiddenwindow.js
browser/components/tests/startupRecorder.js
--- a/browser/base/content/test/performance/browser.ini
+++ b/browser/base/content/test/performance/browser.ini
@@ -20,16 +20,18 @@ support-files =
 skip-if = asan || debug || (os == 'win' && bits == 32) # Bug 1382809, bug 1369959, Win32 because of intermittent OOM failures
 [browser_preferences_usage.js]
 skip-if = !debug
 [browser_startup.js]
 [browser_startup_content.js]
 skip-if = !e10s
 [browser_startup_flicker.js]
 run-if = debug || devedition || nightly_build # Requires startupRecorder.js, which isn't shipped everywhere by default
+[browser_startup_hiddenwindow.js]
+skip-if = os == 'mac'
 [browser_tabclose_grow.js]
 [browser_tabclose.js]
 skip-if = (os == 'win') || (os == 'mac') # Bug 1488537, Bug 1531417, Bug 1497713
 [browser_tabdetach.js]
 [browser_tabopen.js]
 skip-if = (verify && (os == 'mac'))
 [browser_tabopen_squeeze.js]
 [browser_tabstrip_overflow_underflow.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/performance/browser_startup_hiddenwindow.js
@@ -0,0 +1,38 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+add_task(async function() {
+  if (!AppConstants.NIGHTLY_BUILD && !AppConstants.MOZ_DEV_EDITION && !AppConstants.DEBUG) {
+    ok(!("@mozilla.org/test/startuprecorder;1" in Cc),
+       "the startup recorder component shouldn't exist in this non-nightly/non-devedition/" +
+       "non-debug build.");
+    return;
+  }
+
+  let startupRecorder = Cc["@mozilla.org/test/startuprecorder;1"].getService().wrappedJSObject;
+  await startupRecorder.done;
+
+  let extras = Cu.cloneInto(startupRecorder.data.extras, {});
+
+  let phasesExpectations = {
+    "before profile selection": false,
+    "before opening first browser window": false,
+    "before first paint": !Services.prefs.getBoolPref("toolkit.lazyHiddenWindow"),
+
+    // Bug 1531854
+    "before handling user events": true,
+    "before becoming idle": true,
+  };
+
+  for (let phase in extras) {
+    if (!(phase in phasesExpectations)) {
+      ok(false, `Startup phase '${phase}' should be specified.`);
+      continue;
+    }
+
+    is(extras[phase].hiddenWindowLoaded, phasesExpectations[phase],
+       `Hidden window loaded at '${phase}': ${phasesExpectations[phase]}`);
+  }
+});
--- a/browser/components/tests/startupRecorder.js
+++ b/browser/components/tests/startupRecorder.js
@@ -44,16 +44,17 @@ let afterPaintListener = () => {
 function startupRecorder() {
   this.wrappedJSObject = this;
   this.data = {
     images: {
       "image-drawing": new Set(),
       "image-loading": new Set(),
     },
     code: {},
+    extras: {},
     prefStats: {},
   };
   this.done = new Promise(resolve => { this._resolve = resolve; });
 }
 startupRecorder.prototype = {
   classID: Components.ID("{11c095b2-e42e-4bdf-9dd0-aed87595f6a4}"),
 
   QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
@@ -68,16 +69,19 @@ startupRecorder.prototype = {
       services: Object.keys(Cc).filter(c => {
         try {
           return Cm.isServiceInstantiatedByContractID(c, Ci.nsISupports);
         } catch (e) {
           return false;
         }
       }),
     };
+    this.data.extras[name] = {
+      hiddenWindowLoaded: Services.appShell.hasHiddenWindow,
+    };
   },
 
   observe(subject, topic, data) {
     if (topic == "app-startup") {
       // We can't ensure our observer will be called first or last, so the list of
       // topics we observe here should avoid the topics used to trigger things
       // during startup (eg. the topics observed by BrowserGlue.jsm).
       let topics = [