diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 5dc313db31af..1095baf23dbb 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -2135,6 +2135,11 @@ pref("devtools.dom.enabled", false); // Enable the Accessibility panel. pref("devtools.accessibility.enabled", true); +#if defined(NIGHTLY_BUILD) + pref("devtools.accessibility.auto-init.enabled", true); +#else + pref("devtools.accessibility.auto-init.enabled", false); +#endif // Web console filters pref("devtools.webconsole.filter.error", true); diff --git a/devtools/client/accessibility/accessibility-proxy.js b/devtools/client/accessibility/accessibility-proxy.js index 14d9a27ab6ea..8b4d29ecc90c 100644 --- a/devtools/client/accessibility/accessibility-proxy.js +++ b/devtools/client/accessibility/accessibility-proxy.js @@ -14,6 +14,12 @@ const PARENT_ACCESSIBILITY_EVENTS = [ "can-be-enabled-change", ]; +loader.lazyImporter( + this, + "FeatureGate", + "resource://featuregates/FeatureGate.jsm" +); + /** * Component responsible for tracking all Accessibility fronts in parent and * content processes. @@ -24,6 +30,7 @@ class AccessibilityProxy { this.accessibilityEventsMap = new Map(); this.accessibleWalkerEventsMap = new Map(); + this.supports = {}; this.audit = this.audit.bind(this); this.disableAccessibility = this.disableAccessibility.bind(this); @@ -250,12 +257,23 @@ class AccessibilityProxy { } } + async onChange(isEnabled) { + this.supports.autoInit = isEnabled; + } + async initialize() { try { await this.toolbox.targetList.watchTargets( [this.toolbox.targetList.TYPES.FRAME], this._onTargetAvailable ); + // Bug 1602075: auto init feature definition is used for an experiment to + // determine if we can automatically enable accessibility panel when it + // opens. + this.supports.autoInit = await FeatureGate.addObserver( + "accessibility-panel-auto-init", + this + ); return true; } catch (e) { // toolbox may be destroyed during this step. @@ -263,12 +281,14 @@ class AccessibilityProxy { } } - destroy() { + async destroy() { this.toolbox.targetList.unwatchTargets( [this.toolbox.targetList.TYPES.FRAME], this._onTargetAvailable ); + await FeatureGate.removeObserver("accessibility-panel-auto-init", this); + this.accessibilityEventsMap = null; this.accessibleWalkerEventsMap = null; @@ -342,7 +362,6 @@ class AccessibilityProxy { // Finalize accessibility front initialization. See accessibility front // bootstrap method description. await this.accessibilityFront.bootstrap(); - this.supports = {}; // To add a check for backward compatibility add something similar to the // example below: // diff --git a/devtools/client/accessibility/accessibility-startup.js b/devtools/client/accessibility/accessibility-startup.js index 8dc7164b5f87..a1f29b4cc71e 100644 --- a/devtools/client/accessibility/accessibility-startup.js +++ b/devtools/client/accessibility/accessibility-startup.js @@ -85,7 +85,7 @@ class AccessibilityStartup { shutdown: this._updateToolHighlight, }); - this.accessibilityProxy.destroy(); + await this.accessibilityProxy.destroy(); this.accessibilityProxy = null; }.bind(this)(); return this._destroyingAccessibility; diff --git a/toolkit/components/featuregates/Features.toml b/toolkit/components/featuregates/Features.toml index 81d852bd7a1b..18d69cc5fd36 100644 --- a/toolkit/components/featuregates/Features.toml +++ b/toolkit/components/featuregates/Features.toml @@ -1,4 +1,3 @@ -# there are currently no feature gates [demo-feature] title = "Demo Feature" description = "A no-op feature to demo the feature gate system." @@ -8,3 +7,12 @@ type = "boolean" bug-numbers = [1479127] is-public = true default-value = false + +[accessibility-panel-auto-init] +title = "Accessibility Panel Automatic Initialization" +description = "Automatically enables accessibility panel when it is opened." +restart-required = false +preference = "devtools.accessibility.auto-init.enabled" +bug-numbers = [1602075] +type = "boolean" +default-value = {default = false, nightly = true}