Bug 1671579 - Granting the devtools optional permission should also enabled the extension devtools page from a toolbox perspective r=rpl
authorankushduacodes <61025943+ankushduacodes@users.noreply.github.com>
Wed, 09 Dec 2020 17:35:58 +0000
changeset 560033 351f9ecd353e87fda9a4868ba9658d3fedd58269
parent 560032 7d9e2c3c24139766362769c7a70dad50d439e5a3
child 560034 e877ac6e3caa2486d500ca26d87708ce45672600
push id38016
push usermalexandru@mozilla.com
push dateWed, 09 Dec 2020 21:35:04 +0000
treeherdermozilla-central@7765d979d044 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl
bugs1671579
milestone85.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 1671579 - Granting the devtools optional permission should also enabled the extension devtools page from a toolbox perspective r=rpl Differential Revision: https://phabricator.services.mozilla.com/D98841
browser/components/extensions/parent/ext-devtools.js
browser/components/extensions/test/browser/browser_ext_devtools_optional.js
--- a/browser/components/extensions/parent/ext-devtools.js
+++ b/browser/components/extensions/parent/ext-devtools.js
@@ -315,20 +315,25 @@ this.devtools = class extends ExtensionA
     // DevToolsPageDefinition instance (created in onManifestEntry).
     this.pageDefinition = null;
 
     this.onToolboxCreated = this.onToolboxCreated.bind(this);
     this.onToolboxDestroy = this.onToolboxDestroy.bind(this);
 
     /* eslint-disable mozilla/balanced-listeners */
     extension.on("add-permissions", (ignoreEvent, permissions) => {
+      Services.prefs.setBoolPref(
+        `${getDevToolsPrefBranchName(extension.id)}.enabled`,
+        true
+      );
       if (permissions.permissions.includes("devtools")) {
         this._initialize();
       }
     });
+
     extension.on("remove-permissions", (ignoreEvent, permissions) => {
       Services.prefs.setBoolPref(
         `${getDevToolsPrefBranchName(extension.id)}.enabled`,
         false
       );
       if (permissions.permissions.includes("devtools")) {
         this._uninitialize();
       }
--- a/browser/components/extensions/test/browser/browser_ext_devtools_optional.js
+++ b/browser/components/extensions/test/browser/browser_ext_devtools_optional.js
@@ -102,13 +102,27 @@ add_task(async function test_devtools_pa
 
   extension.sendMessage("revoke");
   await extension.awaitMessage("done");
 
   await closed;
   checkEnabled(false);
   assertDevToolsExtensionEnabled(extension.uuid, false);
 
+  info("Close the developer toolbox");
+  await closeToolboxForTab(tab);
+
+  extension.sendMessage("request");
+  await extension.awaitMessage("done");
+
+  info("Open the developer toolbox");
+  openToolboxForTab(tab);
+
+  checkEnabled(true);
+
+  info("Wait the devtools page load");
+  await extension.awaitMessage("devtools_page_loaded");
+  assertDevToolsExtensionEnabled(extension.uuid, true);
   await extension.unload();
 
   await closeToolboxForTab(tab);
   BrowserTestUtils.removeTab(tab);
 });