Bug 1369491 - Write reflow tests for the new Photon appmenu and its subviews. r=florian
authorMike Conley <mconley@mozilla.com>
Wed, 31 May 2017 17:10:30 -0400
changeset 361921 2b5bcdc6c93b558108654815201c14774f6218c1
parent 361920 11ba6213be5a745d70e5c6fdcd036bafb1ac2718
child 361922 5ae487045afba6c08bd1310ca597bfe888b0693b
push id31952
push usercbook@mozilla.com
push dateFri, 02 Jun 2017 12:17:25 +0000
treeherdermozilla-central@194c009d6295 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1369491
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 1369491 - Write reflow tests for the new Photon appmenu and its subviews. r=florian MozReview-Commit-ID: FaIf0GXRaUs
browser/base/content/test/performance/browser.ini
browser/base/content/test/performance/browser_appmenu_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_appmenu_reflows.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]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/performance/browser_appmenu_reflows.js
@@ -0,0 +1,130 @@
+"use strict";
+
+/**
+ * WHOA THERE: We should never be adding new things to
+ * EXPECTED_APPMENU_OPEN_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_APPMENU_OPEN_REFLOWS = [
+  [
+    "openPopup@chrome://global/content/bindings/popup.xml",
+    "show/</<@chrome://browser/content/customizableui/panelUI.js",
+  ],
+
+  [
+    "get_alignmentPosition@chrome://global/content/bindings/popup.xml",
+    "adjustArrowPosition@chrome://global/content/bindings/popup.xml",
+    "onxblpopupshowing@chrome://global/content/bindings/popup.xml",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+    "show/</<@chrome://browser/content/customizableui/panelUI.js",
+  ],
+
+  [
+    "get_alignmentPosition@chrome://global/content/bindings/popup.xml",
+    "adjustArrowPosition@chrome://global/content/bindings/popup.xml",
+    "onxblpopupshowing@chrome://global/content/bindings/popup.xml",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+    "show/</<@chrome://browser/content/customizableui/panelUI.js",
+  ],
+
+  [
+    "get_alignmentPosition@chrome://global/content/bindings/popup.xml",
+    "adjustArrowPosition@chrome://global/content/bindings/popup.xml",
+    "onxblpopuppositioned@chrome://global/content/bindings/popup.xml",
+  ],
+
+  [
+    "get_alignmentPosition@chrome://global/content/bindings/popup.xml",
+    "handleEvent@resource:///modules/PanelMultiView.jsm",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+  ],
+
+  [
+    "handleEvent@resource:///modules/PanelMultiView.jsm",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+  ],
+
+  [
+    "handleEvent@resource:///modules/PanelMultiView.jsm",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+  ],
+
+  [
+    "handleEvent@resource:///modules/PanelMultiView.jsm",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+  ],
+
+  [
+    "handleEvent@resource:///modules/PanelMultiView.jsm",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+  ],
+
+  [
+    "handleEvent@resource:///modules/PanelMultiView.jsm",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+  ],
+
+  [
+    "handleEvent@resource:///modules/PanelMultiView.jsm",
+    "openPopup@chrome://global/content/bindings/popup.xml",
+  ],
+];
+
+const EXPECTED_APPMENU_SUBVIEW_REFLOWS = [
+  /**
+   * Nothing here! Please don't add anything new!
+   */
+];
+
+add_task(async function() {
+  await ensureNoPreloadedBrowser();
+
+  await SpecialPowers.pushPrefEnv({
+    set: [["browser.photon.structure.enabled", true]],
+  });
+
+  // First, open the appmenu.
+  await withReflowObserver(async function() {
+    let popupPositioned =
+      BrowserTestUtils.waitForEvent(PanelUI.panel, "popuppositioned");
+    await PanelUI.show();
+    await popupPositioned;
+  }, EXPECTED_APPMENU_OPEN_REFLOWS, window, PanelUI.panel);
+
+  // Now open a series of subviews, and then close the appmenu. We
+  // should not reflow during any of this.
+  await withReflowObserver(async function() {
+    // This recursive function will take the current main or subview,
+    // find all of the buttons that navigate to subviews inside it,
+    // and click each one individually. Upon entering the new view,
+    // we recurse. When the subviews within a view have been
+    // exhausted, we go back up a level.
+    async function openSubViewsRecursively(currentView) {
+      let navButtons = Array.from(currentView.querySelectorAll(".subviewbutton-nav"));
+      if (!navButtons) {
+        return;
+      }
+
+      for (let button of navButtons) {
+        button.click();
+        await BrowserTestUtils.waitForEvent(PanelUI.panel, "ViewShown");
+        // Unfortunately, I can't find a better accessor to the current
+        // subview, so I have to reach the PanelMultiView instance
+        // here.
+        await openSubViewsRecursively(PanelUI.multiView.instance._currentSubView);
+        PanelUI.multiView.goBack();
+        await BrowserTestUtils.waitForEvent(PanelUI.panel, "ViewShown");
+      }
+    }
+
+    await openSubViewsRecursively(PanelUI.mainView);
+
+    let hidden = BrowserTestUtils.waitForEvent(PanelUI.panel, "popuphidden");
+    PanelUI.hide();
+    await hidden;
+  }, EXPECTED_APPMENU_SUBVIEW_REFLOWS, window, PanelUI.panel);
+});