Bug 1602054 - add cold open DAMP test for the accessibility panel. r=perftest-reviewers,jdescottes,Bebe
authorYura Zenevich <yura.zenevich@gmail.com>
Tue, 30 Jun 2020 10:26:19 +0000
changeset 538124 cbaf158426baa46078e81c0b104fe204984ea369
parent 538123 8042b7b369435bf8c17d0b2d9af65aabb0a966ac
child 538125 8512ad60ed767d6634ddb41430c7d50ac8fe20c9
push id37558
push userdluca@mozilla.com
push dateWed, 01 Jul 2020 09:30:12 +0000
treeherdermozilla-central@e950bdd669d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersperftest-reviewers, jdescottes, Bebe
bugs1602054
milestone80.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 1602054 - add cold open DAMP test for the accessibility panel. r=perftest-reviewers,jdescottes,Bebe This is a brand new (and first) DAMP talos test for accessibility panel. "accessibility.cold-open" is similar to other cold open tests such as inspector one. It opens accessibility panel, waits for its UI to render and then closes the toolbox. Differential Revision: https://phabricator.services.mozilla.com/D80512
devtools/client/accessibility/accessibility-view.js
devtools/client/accessibility/components/Accessible.js
devtools/client/accessibility/panel.js
testing/talos/talos/tests/devtools/addon/content/damp-tests.js
testing/talos/talos/tests/devtools/addon/content/tests/accessibility/accessibility-helpers.js
testing/talos/talos/tests/devtools/addon/content/tests/accessibility/cold-open.js
--- a/devtools/client/accessibility/accessibility-view.js
+++ b/devtools/client/accessibility/accessibility-view.js
@@ -142,16 +142,19 @@ AccessibilityView.prototype = {
       stopListeningForLifecycleEvents,
       startListeningForParentLifecycleEvents,
       stopListeningForParentLifecycleEvents,
       highlightAccessible,
       unhighlightAccessible,
     });
     // Render top level component
     const provider = createElement(Provider, { store: this.store }, mainFrame);
+    window.once(EVENTS.PROPERTIES_UPDATED).then(() => {
+      window.emit(EVENTS.INITIALIZED);
+    });
     this.mainFrame = ReactDOM.render(provider, container);
   },
 
   destroy() {
     const container = document.getElementById("content");
     ReactDOM.unmountComponentAtNode(container);
   },
 
--- a/devtools/client/accessibility/components/Accessible.js
+++ b/devtools/client/accessibility/components/Accessible.js
@@ -161,16 +161,25 @@ class Accessible extends Component {
 
     if (accessibleFront) {
       ACCESSIBLE_EVENTS.forEach(event =>
         accessibleFront.on(event, this.update)
       );
     }
   }
 
+  componentDidUpdate(prevProps) {
+    if (
+      this.props?.accessibleFront?.actorID &&
+      this.props.accessibleFront !== prevProps.accessibleFront
+    ) {
+      window.emit(EVENTS.PROPERTIES_UPDATED);
+    }
+  }
+
   componentWillUnmount() {
     window.off(
       EVENTS.NEW_ACCESSIBLE_FRONT_INSPECTED,
       this.onAccessibleInspected
     );
 
     const { accessibleFront } = this.props;
     if (accessibleFront) {
--- a/devtools/client/accessibility/panel.js
+++ b/devtools/client/accessibility/panel.js
@@ -22,16 +22,21 @@ const EVENTS = {
   // When the accessibility inspector has a new accessible front highlighted.
   NEW_ACCESSIBLE_FRONT_HIGHLIGHTED:
     "Accessibility:NewAccessibleFrontHighlighted",
   // When the accessibility inspector has a new accessible front inspected.
   NEW_ACCESSIBLE_FRONT_INSPECTED: "Accessibility:NewAccessibleFrontInspected",
   // When the accessibility inspector is updated.
   ACCESSIBILITY_INSPECTOR_UPDATED:
     "Accessibility:AccessibilityInspectorUpdated",
+  // When accessibility panel UI is initialized (rendered).
+  INITIALIZED: "Accessibility:Initialized",
+  // When accessibile object properties are updated in the panel sidebar for a
+  // new accessible object.
+  PROPERTIES_UPDATED: "Accessibility:PropertiesUpdated",
 };
 
 /**
  * This object represents Accessibility panel. It's responsibility is to
  * render Accessibility Tree of the current debugger target and the sidebar that
  * displays current relevant accessible details.
  */
 function AccessibilityPanel(iframeWindow, toolbox, startup) {
--- a/testing/talos/talos/tests/devtools/addon/content/damp-tests.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp-tests.js
@@ -45,16 +45,22 @@ module.exports = [
     cold: true,
   },
   {
     name: "netmonitor.cold-open",
     path: "netmonitor/cold-open.js",
     description: "Measure first open toolbox on netmonitor panel",
     cold: true,
   },
+  {
+    name: "accessibility.cold-open",
+    path: "accessibility/cold-open.js",
+    description: "Measure first open toolbox on accessibility panel",
+    cold: true,
+  },
   // Run all tests against "simple" document
   {
     name: "simple.webconsole",
     path: "webconsole/simple.js",
     description:
       "Measure open/close toolbox on webconsole panel against simple document",
   },
   {
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/tests/accessibility/accessibility-helpers.js
@@ -0,0 +1,33 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const Services = require("Services");
+const { openToolboxAndLog } = require("../head");
+
+const INITIALIZED_EVENT = "Accessibility:Initialized";
+
+const PREF_ACCESSIBILITY_FORCE_DISABLED = "accessibility.force_disabled";
+
+exports.shutdownAccessibilityService = function() {
+  // Set PREF_ACCESSIBILITY_FORCE_DISABLED to 1 to force disable
+  // accessibility service. This is the only way to guarantee an immediate
+  // accessibility service shutdown in all processes. This also prevents
+  // accessibility service from starting up in the future.
+  Services.prefs.setIntPref(PREF_ACCESSIBILITY_FORCE_DISABLED, 1);
+  // Set PREF_ACCESSIBILITY_FORCE_DISABLED back to default value. This will
+  // not start accessibility service until the user activates it again. It
+  // simply ensures that accessibility service can start again (when value is
+  // below 1).
+  Services.prefs.clearUserPref(PREF_ACCESSIBILITY_FORCE_DISABLED);
+};
+
+exports.openAccessibilityAndLog = async function(label) {
+  await openToolboxAndLog(
+    `${label}.accessibility`,
+    "accessibility",
+    (toolbox, panel) => panel.panelWin.once(INITIALIZED_EVENT)
+  );
+};
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/tests/accessibility/cold-open.js
@@ -0,0 +1,25 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {
+  openAccessibilityAndLog,
+  shutdownAccessibilityService,
+} = require("./accessibility-helpers");
+
+const {
+  closeToolbox,
+  testSetup,
+  testTeardown,
+  SIMPLE_URL,
+} = require("../head");
+
+module.exports = async function() {
+  await testSetup(SIMPLE_URL);
+  await openAccessibilityAndLog("cold");
+  await closeToolbox();
+  shutdownAccessibilityService();
+  await testTeardown();
+};