Bug 1455040 - Enable tab hiding API by default. r=mixedpuppy, a=RyanVM DEVEDITION_61_0b3_BUILD1 DEVEDITION_61_0b3_RELEASE FENNEC_61_0b3_BUILD1 FENNEC_61_0b3_RELEASE FIREFOX_61_0b3_BUILD1 FIREFOX_61_0b3_RELEASE
authorMark Striemer <mstriemer@mozilla.com>
Mon, 07 May 2018 12:27:41 -0500
changeset 797059 22c0edf133aacee21a87c69b46f17ef13fddc2d7
parent 797058 bc7c1b5ff63debf03ca129a4772bb4ab847ed176
child 797060 be193b32a5b61e71420607748097faadd0e71bc4
push id110422
push userbmo:khudson@mozilla.com
push dateFri, 18 May 2018 18:23:40 +0000
reviewersmixedpuppy, RyanVM
bugs1455040
milestone61.0
Bug 1455040 - Enable tab hiding API by default. r=mixedpuppy, a=RyanVM MozReview-Commit-ID: HtzpV7bySeY
browser/components/extensions/test/browser/browser_ext_tabs_hide.js
browser/components/extensions/test/browser/browser_ext_tabs_hide_update.js
modules/libpref/init/all.js
--- a/browser/components/extensions/test/browser/browser_ext_tabs_hide.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_hide.js
@@ -2,44 +2,16 @@
 
 ChromeUtils.defineModuleGetter(this, "SessionStore",
                                "resource:///modules/sessionstore/SessionStore.jsm");
 ChromeUtils.defineModuleGetter(this, "TabStateFlusher",
                                "resource:///modules/sessionstore/TabStateFlusher.jsm");
 const {Utils} = ChromeUtils.import("resource://gre/modules/sessionstore/Utils.jsm", {});
 const triggeringPrincipal_base64 = Utils.SERIALIZED_SYSTEMPRINCIPAL;
 
-// Ensure the pref prevents API use when the extension has the tabHide permission.
-add_task(async function test_pref_disabled() {
-  async function background() {
-    let tabs = await browser.tabs.query({hidden: false});
-    let ids = tabs.map(tab => tab.id);
-
-    await browser.test.assertRejects(
-      browser.tabs.hide(ids),
-      /tabs.hide is currently experimental/,
-      "Got the expected error when pref not enabled"
-    ).catch(err => {
-      browser.test.notifyFail("pref-test");
-      throw err;
-    });
-
-    browser.test.notifyPass("pref-test");
-  }
-
-  let extdata = {
-    manifest: {permissions: ["tabs", "tabHide"]},
-    background,
-  };
-  let extension = ExtensionTestUtils.loadExtension(extdata);
-  await extension.startup();
-  await extension.awaitFinish("pref-test");
-  await extension.unload();
-});
-
 async function doorhangerTest(testFn) {
   await SpecialPowers.pushPrefEnv({
     set: [["extensions.webextensions.tabhide.enabled", true]],
   });
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["tabs", "tabHide"],
@@ -143,20 +115,16 @@ add_task(function test_doorhanger_disabl
     await popupHidden;
 
     is(gBrowser.visibleTabs.length, 3, "There are 3 visible tabs again");
     is(addon.userDisabled, true, "The extension is now disabled");
   });
 });
 
 add_task(async function test_tabs_showhide() {
-  await SpecialPowers.pushPrefEnv({
-    set: [["extensions.webextensions.tabhide.enabled", true]],
-  });
-
   async function background() {
     browser.test.onMessage.addListener(async (msg, data) => {
       switch (msg) {
         case "hideall": {
           let tabs = await browser.tabs.query({hidden: false});
           browser.test.assertEq(tabs.length, 5, "got 5 tabs");
           let ids = tabs.map(tab => tab.id);
           browser.test.log(`working with ids ${JSON.stringify(ids)}`);
@@ -289,20 +257,16 @@ add_task(async function test_tabs_showhi
   SessionStore.setBrowserState(oldState);
   await restored;
 });
 
 // Test our shutdown handling.  Currently this means any hidden tabs will be
 // shown when a tabHide extension is shutdown.  We additionally test the
 // tabs.onUpdated listener gets called with hidden state changes.
 add_task(async function test_tabs_shutdown() {
-  await SpecialPowers.pushPrefEnv({
-    set: [["extensions.webextensions.tabhide.enabled", true]],
-  });
-
   let tabs = [
     await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/", true, true),
     await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/", true, true),
   ];
 
   async function background() {
     let tabs = await browser.tabs.query({url: "http://example.com/"});
     let testTab = tabs[0];
@@ -338,8 +302,42 @@ add_task(async function test_tabs_shutdo
   Assert.ok(tabs[0].hidden, "Tab is hidden by extension");
 
   await extension.unload();
 
   Assert.ok(!tabs[0].hidden, "Tab is not hidden after unloading extension");
   BrowserTestUtils.removeTab(tabs[0]);
   BrowserTestUtils.removeTab(tabs[1]);
 });
+
+// Ensure the pref prevents API use when the extension has the tabHide permission.
+add_task(async function test_pref_disabled() {
+  // This should run last since SpecialPowers.pushPrefEnv won't cleanup until
+  // this file finishes executing.
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.webextensions.tabhide.enabled", false]],
+  });
+
+  async function background() {
+    let tabs = await browser.tabs.query({hidden: false});
+    let ids = tabs.map(tab => tab.id);
+
+    await browser.test.assertRejects(
+      browser.tabs.hide(ids),
+      /tabs.hide is currently experimental/,
+      "Got the expected error when pref not enabled"
+    ).catch(err => {
+      browser.test.notifyFail("pref-test");
+      throw err;
+    });
+
+    browser.test.notifyPass("pref-test");
+  }
+
+  let extdata = {
+    manifest: {permissions: ["tabs", "tabHide"]},
+    background,
+  };
+  let extension = ExtensionTestUtils.loadExtension(extdata);
+  await extension.startup();
+  await extension.awaitFinish("pref-test");
+  await extension.unload();
+});
--- a/browser/components/extensions/test/browser/browser_ext_tabs_hide_update.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_hide_update.js
@@ -56,20 +56,16 @@ function getExtension() {
   };
   return ExtensionTestUtils.loadExtension(extdata);
 }
 
 // Test our update handling.  Currently this means any hidden tabs will be
 // shown when a tabHide extension is shutdown.  We additionally test the
 // tabs.onUpdated listener gets called with hidden state changes.
 add_task(async function test_tabs_update() {
-  await SpecialPowers.pushPrefEnv({
-    set: [["extensions.webextensions.tabhide.enabled", true]],
-  });
-
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
   await BrowserTestUtils.switchTab(gBrowser, gBrowser.tabs[0]);
 
   const extension = getExtension();
   await extension.startup();
 
   // test onUpdated
   await Promise.all([
@@ -111,20 +107,16 @@ add_task(async function test_tabs_update
   BrowserTestUtils.removeTab(tab);
 });
 
 
 // Test our update handling.  Currently this means any hidden tabs will be
 // shown when a tabHide extension is shutdown.  We additionally test the
 // tabs.onUpdated listener gets called with hidden state changes.
 add_task(async function test_tabs_disable() {
-  await SpecialPowers.pushPrefEnv({
-    set: [["extensions.webextensions.tabhide.enabled", true]],
-  });
-
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
   await BrowserTestUtils.switchTab(gBrowser, gBrowser.tabs[0]);
 
   const extension = getExtension();
   await extension.startup();
 
   // test onUpdated
   await Promise.all([
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4929,18 +4929,18 @@ pref("extensions.webextensions.restricte
 pref("extensions.webextensions.themes.enabled", false);
 pref("extensions.webextensions.themes.icons.enabled", false);
 pref("extensions.webextensions.remote", false);
 // Whether or not the moz-extension resource loads are remoted. For debugging
 // purposes only. Setting this to false will break moz-extension URI loading
 // unless other process sandboxing and extension remoting prefs are changed.
 pref("extensions.webextensions.protocol.remote", true);
 
-// Disable tab hiding API by default.
-pref("extensions.webextensions.tabhide.enabled", false);
+// Enable tab hiding API by default.
+pref("extensions.webextensions.tabhide.enabled", true);
 
 pref("extensions.webextensions.background-delayed-startup", false);
 
 // Report Site Issue button
 pref("extensions.webcompat-reporter.newIssueEndpoint", "https://webcompat.com/issues/new");
 #if defined(MOZ_DEV_EDITION) || defined(NIGHTLY_BUILD)
 pref("extensions.webcompat-reporter.enabled", true);
 #else