Bug 1385034 - Add a reflow test for when the tabstrip over and underflows. r?Gijs draft
authorMike Conley <mconley@mozilla.com>
Fri, 12 May 2017 08:34:22 -0400
changeset 642289 3d0d4f50a60ab4f2a9565940e5b7bb61ef88efc6
parent 642204 65507616792c990b1230888612dd7ffc13ed32b4
child 724950 334e2ab0a8c803320387519cf6c2dce98081607a
push id72698
push usermconley@mozilla.com
push dateTue, 08 Aug 2017 01:09:54 +0000
reviewersGijs
bugs1385034
milestone57.0a1
Bug 1385034 - Add a reflow test for when the tabstrip over and underflows. r?Gijs MozReview-Commit-ID: FjwYDd2Frh2
browser/base/content/test/performance/browser.ini
browser/base/content/test/performance/browser_tabstrip_overflow_underflow_reflows.js
--- a/browser/base/content/test/performance/browser.ini
+++ b/browser/base/content/test/performance/browser.ini
@@ -7,15 +7,16 @@ skip-if = asan || debug # Bug 1382809, b
 [browser_startup_content.js]
 skip-if = !e10s
 [browser_startup_images.js]
 skip-if = !debug
 [browser_tabclose_grow_reflows.js]
 [browser_tabclose_reflows.js]
 [browser_tabopen_reflows.js]
 [browser_tabopen_squeeze_reflows.js]
+[browser_tabstrip_overflow_underflow_reflows.js]
 [browser_tabswitch_reflows.js]
 [browser_toolbariconcolor_restyles.js]
 [browser_urlbar_search_reflows.js]
 skip-if = (os == 'linux') || (os == 'mac' && !debug) # Disabled on Linux and OS X opt due to frequent failures. Bug 1385932 and Bug 1384582
 [browser_windowclose_reflows.js]
 [browser_windowopen_reflows.js]
 skip-if = os == 'linux' # Disabled due to frequent failures. Bug 1380465.
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/performance/browser_tabstrip_overflow_underflow_reflows.js
@@ -0,0 +1,76 @@
+"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_OVERFLOW_REFLOWS = [
+  {
+    stack: [
+      "select@chrome://global/content/bindings/textbox.xml",
+      "focusAndSelectUrlBar@chrome://browser/content/browser.js",
+      "_adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml",
+      "updateDisplay/<@chrome://browser/content/tabbrowser.xml",
+      "set_selectedIndex@chrome://browser/content/tabbrowser.xml",
+      "set_selectedPanel@chrome://global/content/bindings/tabbox.xml",
+      "set_selectedIndex@chrome://global/content/bindings/tabbox.xml",
+      "set_selectedItem@chrome://global/content/bindings/tabbox.xml",
+      "set_selectedTab@chrome://global/content/bindings/tabbox.xml",
+      "set_selectedTab@chrome://browser/content/tabbrowser.xml",
+      "loadOneTab@chrome://browser/content/tabbrowser.xml",
+      "openLinkIn@chrome://browser/content/utilityOverlay.js",
+      "openUILinkIn@chrome://browser/content/utilityOverlay.js",
+      "BrowserOpenTab@chrome://browser/content/browser.js",
+    ]
+  },
+];
+
+const EXPECTED_UNDERFLOW_REFLOWS = [
+  /**
+   * Nothing here! Please don't add anything new!
+   */
+];
+
+/**
+ * This test ensures that there are no unexpected uninterruptible reflows when
+ * opening a new tab that will cause the existing tabs to overflow and the tab
+ * strip to become scrollable. It also tests that there are no unexpected
+ * uninterruptible reflows when closing that tab, which causes the tab strip to
+ * underflow.
+ */
+add_task(async function() {
+  await ensureNoPreloadedBrowser();
+
+  const TAB_COUNT_FOR_OVERFLOW = computeMaxTabCount();
+
+  await createTabs(TAB_COUNT_FOR_OVERFLOW);
+
+  await withReflowObserver(async function(dirtyFrame) {
+    let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
+    BrowserOpenTab();
+    await BrowserTestUtils.waitForEvent(gBrowser.selectedTab, "transitionend",
+        false, e => e.propertyName === "max-width");
+    await switchDone;
+    await BrowserTestUtils.waitForCondition(() => {
+      return gBrowser.tabContainer.mTabstrip.hasAttribute("scrolledtoend")
+    });
+  }, EXPECTED_OVERFLOW_REFLOWS, window);
+
+  await withReflowObserver(async function() {
+    let switchDone = BrowserTestUtils.waitForEvent(window, "TabSwitchDone");
+    let transitionPromise =
+      BrowserTestUtils.waitForEvent(gBrowser.selectedTab,
+                                    "transitionend", false,
+                                    e => e.propertyName === "max-width");
+    await BrowserTestUtils.removeTab(gBrowser.selectedTab, { animate: true });
+    await transitionPromise;
+    await switchDone;
+  }, EXPECTED_UNDERFLOW_REFLOWS, window);
+
+  await removeAllButFirstTab();
+});