Bug 1363505 - Add tab growth reflow test. r=florian
authorMike Conley <mconley@mozilla.com>
Thu, 25 May 2017 15:49:37 -0400
changeset 361872 1ae492c2da06f838a2ebe6a639068fbe6b080d8c
parent 361871 5e037ab2ee52aa9d1e26a8143f7967fa2dac0e25
child 361873 8bd3380db77f9c6cc5e3ee8f7adc84b939d6076a
push id31946
push userryanvm@gmail.com
push dateThu, 01 Jun 2017 20:43:38 +0000
treeherdermozilla-central@b138d2f271fd [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 growth reflow test. r=florian MozReview-Commit-ID: 8Qes9Srkskm
browser/base/content/test/performance/browser.ini
browser/base/content/test/performance/browser_tabclose_grow_reflows.js
--- a/browser/base/content/test/performance/browser.ini
+++ b/browser/base/content/test/performance/browser.ini
@@ -1,10 +1,11 @@
 [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_toolbariconcolor_restyles.js]
 [browser_windowclose_reflows.js]
 [browser_windowopen_reflows.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/performance/browser_tabclose_grow_reflows.js
@@ -0,0 +1,58 @@
+"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 = [
+  /**
+   * Nothing here! Please don't add anything new!
+   */
+];
+
+/*
+ * This test ensures that there are no unexpected
+ * uninterruptible reflows when closing a tab that will
+ * cause the existing tabs to grow bigger.
+ */
+add_task(async function() {
+  await ensureNoPreloadedBrowser();
+
+  // At the time of writing, there are no reflows on tab closing with
+  // tab growth. Mochitest will fail if we have no assertions, so we
+  // add one here to make sure nobody adds any new ones.
+  Assert.equal(EXPECTED_REFLOWS.length, 0,
+    "We shouldn't have added any new expected reflows.");
+
+  // Compute the number of tabs we can put into the strip without
+  // overflowing. If we remove one of the tabs, we know that the
+  // remaining tabs will grow to fill the remaining space in the
+  // tabstrip.
+  const TAB_COUNT_FOR_GROWTH = computeMaxTabCount();
+  await createTabs(TAB_COUNT_FOR_GROWTH);
+
+  // 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 lastTab = gBrowser.tabs[gBrowser.tabs.length - 1];
+  await BrowserTestUtils.switchTab(gBrowser, lastTab);
+
+  await withReflowObserver(async function() {
+    let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
+    let tab = gBrowser.tabs[gBrowser.tabs.length - 1];
+    gBrowser.removeTab(tab, { animate: true });
+    await BrowserTestUtils.waitForEvent(tab, "transitionend",
+      false, e => e.propertyName === "max-width");
+    await switchDone;
+  }, EXPECTED_REFLOWS, window, origTab);
+
+  await removeAllButFirstTab();
+});