Bug 1543696 - Fix browser_ext_themes_experiment.js and browser_ext_themes_warnings.js failures due to extensions.legacy.enabled behaving differently on automation. r=kmag
authorTim Nguyen <ntim.bugs@gmail.com>
Wed, 24 Apr 2019 07:25:28 +0000
changeset 470598 352f3ef0d7dfa1f446d92fe870ec7d04d183cbe7
parent 470597 7af03776d85d2a2fd1a9b6e97c84d2e68acb7b0a
child 470599 eea1f01aa27ca7dd81d7f50c1f2075d47093c54a
push id35910
push usercbrindusan@mozilla.com
push dateWed, 24 Apr 2019 21:51:39 +0000
treeherdermozilla-central@b9a625eff9e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1543696
milestone68.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 1543696 - Fix browser_ext_themes_experiment.js and browser_ext_themes_warnings.js failures due to extensions.legacy.enabled behaving differently on automation. r=kmag Differential Revision: https://phabricator.services.mozilla.com/D28187
toolkit/components/extensions/test/browser/browser_ext_themes_experiment.js
toolkit/components/extensions/test/browser/browser_ext_themes_warnings.js
--- a/toolkit/components/extensions/test/browser/browser_ext_themes_experiment.js
+++ b/toolkit/components/extensions/test/browser/browser_ext_themes_experiment.js
@@ -1,18 +1,16 @@
 "use strict";
 
 // This test checks whether the theme experiments work
 
 add_task(async function setup() {
-  if (AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS) {
-    await SpecialPowers.pushPrefEnv({
-      set: [["extensions.legacy.enabled", true]],
-    });
-  }
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.legacy.enabled", AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS]],
+  });
 });
 
 add_task(async function test_experiment_static_theme() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       theme: {
         colors: {
           some_color_property: "#ff00ff",
@@ -266,8 +264,12 @@ add_task(async function test_experiment_
 
   is(root.style.getPropertyValue("--menu-button-background"), "",
      "Variable should be unset");
   isnot(computedStyle.backgroundColor, expectedColor,
         "Menu button should not have custom background");
   isnot(computedStyle.fill, expectedFill,
         "Menu button should not have stylesheet fill");
 });
+
+add_task(async function cleanup() {
+  await SpecialPowers.popPrefEnv();
+});
--- a/toolkit/components/extensions/test/browser/browser_ext_themes_warnings.js
+++ b/toolkit/components/extensions/test/browser/browser_ext_themes_warnings.js
@@ -67,22 +67,24 @@ add_task(async function test_dynamic_the
       () => extension.awaitMessage("theme-updated"),
       `Unrecognized theme property found: ${property}.such_property`
     );
   }
 
   await extension.unload();
 });
 
-add_task(async function test_experiment() {
-  Services.prefs.setBoolPref("extensions.legacy.enabled", true);
+add_task(async function test_experiments_enabled() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.legacy.enabled", AppConstants.MOZ_ALLOW_LEGACY_EXTENSIONS]],
+  });
 
   info("Testing that experiments are handled correctly when legacy pref is enabled");
 
-  let extension = ExtensionTestUtils.loadExtension({
+  const extension = ExtensionTestUtils.loadExtension({
     manifest: {
       theme: {
         properties: {
           such_property: "much_wow",
           unknown_property: "very_unknown",
         },
       },
       theme_experiment: {
@@ -100,21 +102,27 @@ add_task(async function test_experiment(
   } else {
     await waitForConsole(
       extension.startup,
       "Unrecognized theme property found: properties.unknown_property"
     );
   }
   await extension.unload();
 
+  await SpecialPowers.popPrefEnv();
+});
+
+add_task(async function test_experiments_disabled() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["extensions.legacy.enabled", false]],
+  });
+
   info("Testing that experiments are handled correctly when legacy pref is disabled");
 
-  Services.prefs.setBoolPref("extensions.legacy.enabled", false);
-
-  extension = ExtensionTestUtils.loadExtension({
+  const extension = ExtensionTestUtils.loadExtension({
     manifest: {
       theme: {
         properties: {
           such_property: "much_wow",
         },
       },
       theme_experiment: {
         properties: {
@@ -123,9 +131,10 @@ add_task(async function test_experiment(
       },
     },
   });
   await waitForConsole(
     extension.startup,
     "This extension is not allowed to run theme experiments"
   );
   await extension.unload();
+  await SpecialPowers.popPrefEnv();
 });