Bug 1363505 - Add tab switch reflow test. r=florian
☠☠ backed out by e603b83ca395 ☠ ☠
authorMike Conley <mconley@mozilla.com>
Thu, 25 May 2017 16:05:53 -0400
changeset 361827 c6b6bc96e99c2b78a97a812cdac687802decb4c3
parent 361826 494590d4307a1a06e5388c66ba23119f33a25b64
child 361828 617099302c92ebfe8fc2a34dffb0dd8d9755fc9f
push id31945
push userryanvm@gmail.com
push dateThu, 01 Jun 2017 20:42:17 +0000
treeherdermozilla-central@15e32469eb04 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1363505
milestone55.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 1363505 - Add tab switch reflow test. r=florian MozReview-Commit-ID: 9A77Fi6Kroi
browser/base/content/test/performance/browser.ini
browser/base/content/test/performance/browser_tabswitch_reflows.js
--- a/browser/base/content/test/performance/browser.ini
+++ b/browser/base/content/test/performance/browser.ini
@@ -1,11 +1,12 @@
 [DEFAULT]
 support-files =
   head.js
 [browser_startup.js]
 [browser_tabclose_grow_reflows.js]
 [browser_tabclose_reflows.js]
 [browser_tabopen_reflows.js]
 [browser_tabopen_squeeze_reflows.js]
+[browser_tabswitch_reflows.js]
 [browser_toolbariconcolor_restyles.js]
 [browser_windowclose_reflows.js]
 [browser_windowopen_reflows.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/performance/browser_tabswitch_reflows.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * WHOA THERE: We should never be adding new things to EXPECTED_REFLOWS. This
+ * is a whitelist that should slowly go away as we improve the performance of
+ * the front-end. Instead of adding more reflows to the whitelist, you should
+ * be modifying your code to avoid the reflow.
+ *
+ * See https://developer.mozilla.org/en-US/Firefox/Performance_best_practices_for_Firefox_fe_engineers
+ * for tips on how to do that.
+ */
+const EXPECTED_REFLOWS = [
+  [
+    "_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml",
+  ],
+];
+
+if (gMultiProcessBrowser) {
+  EXPECTED_REFLOWS.push(
+    [
+      "_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml",
+    ]
+  );
+}
+
+/*
+ * This test ensures that there are no unexpected
+ * uninterruptible reflows when switching between two
+ * tabs that are both fully visible.
+ */
+add_task(async function() {
+  await ensureNoPreloadedBrowser();
+
+  // Because the tab strip is a scrollable frame, we can't use the
+  // default dirtying function from withReflowObserver and reliably
+  // get reflows for the strip. Instead, we provide a node that's
+  // already in the scrollable frame to dirty - in this case, the
+  // original tab.
+  let origTab = gBrowser.selectedTab;
+
+  let firstSwitchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
+  let otherTab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
+  await firstSwitchDone;
+
+  await withReflowObserver(async function() {
+    let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
+    gBrowser.selectedTab = origTab;
+    await switchDone;
+  }, EXPECTED_REFLOWS, window, origTab);
+
+  await BrowserTestUtils.removeTab(otherTab);
+});