Bug 1363505 - Add reflow test for window closing. r=florian
☠☠ backed out by e603b83ca395 ☠ ☠
authorMike Conley <mconley@mozilla.com>
Tue, 09 May 2017 17:10:14 -0400
changeset 361824 0c50bc93a3dc0c78eae2c3599912b86c03509aea
parent 361823 167cd75cfda764e5ddce73d6b026363dbb1c2adc
child 361825 6f6b73f4f305a649c503ff9bba3d1d1ca0b1aedd
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 reflow test for window closing. r=florian MozReview-Commit-ID: AmjNIldSQIz
browser/base/content/test/performance/browser.ini
browser/base/content/test/performance/browser_windowclose_reflows.js
--- a/browser/base/content/test/performance/browser.ini
+++ b/browser/base/content/test/performance/browser.ini
@@ -1,8 +1,9 @@
 [DEFAULT]
 support-files =
   head.js
 [browser_startup.js]
 [browser_tabclose_reflows.js]
 [browser_tabopen_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_windowclose_reflows.js
@@ -0,0 +1,50 @@
+"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 windows. When the
+ * window is closed, the test waits until the original window
+ * has activated.
+ */
+add_task(function*() {
+  // Ensure that this browser window starts focused. This seems to be
+  // necessary to avoid intermittent failures when running this test
+  // on repeat.
+  yield new Promise(resolve => {
+    waitForFocus(resolve, window);
+  });
+
+  let win = yield BrowserTestUtils.openNewBrowserWindow();
+  yield new Promise(resolve => {
+    waitForFocus(resolve, win);
+  });
+
+  // At the time of writing, there are no reflows on window closing.
+  // 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 for window close.");
+
+  yield withReflowObserver(async function() {
+    let promiseOrigBrowserFocused = BrowserTestUtils.waitForCondition(() => {
+      return Services.focus.activeWindow == window;
+    });
+    await BrowserTestUtils.closeWindow(win);
+    await promiseOrigBrowserFocused;
+  }, EXPECTED_REFLOWS, win);
+});