Bug 1446508 - clear runOnce state after every test. r=felipe
authorYuki Hiroshi <yuki@clear-code.com>
Wed, 21 Mar 2018 13:10:23 -0300
changeset 1460147 a4642c1e1d230135a98542f741b4c67536b50901
parent 1460146 e2ddf4dbfa33d0da768cd8a46f2627e6c2aadbc6
child 1460148 a0a1bf2e04d22db4530c715a3f4d06fb46072a06
push id260095
push userecoal95@gmail.com
push dateWed, 21 Mar 2018 17:01:50 +0000
treeherdertry@0c24a9ae2a68 [default view] [failures only]
reviewersfelipe
bugs1446508
milestone61.0a1
Bug 1446508 - clear runOnce state after every test. r=felipe
browser/components/enterprisepolicies/tests/browser/browser_policies_runOnce_helper.js
browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js
browser/components/enterprisepolicies/tests/browser/browser_policy_set_homepage.js
browser/components/enterprisepolicies/tests/browser/head.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policies_runOnce_helper.js
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policies_runOnce_helper.js
@@ -11,12 +11,9 @@ function callback() {
 }
 
 add_task(async function test_runonce_helper() {
   runOnce("test_action", callback);
   is(runCount, 1, "Callback ran for the first time.");
 
   runOnce("test_action", callback);
   is(runCount, 1, "Callback didn't run again.");
-
-  // clean-up
-  Services.prefs.clearUserPref("browser.policies.runonce.test_action");
 });
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js
@@ -1,14 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 add_task(async function setup() {
-  EnterprisePolicyTesting.resetRunOnceState();
   const expiry = Date.now() + 24 * 60 * 60;
   Services.cookies.add("example.com", "/", "secure", "true", true, false, false, expiry, {});
   Services.cookies.add("example.com", "/", "insecure", "true", false, false, false, expiry, {});
   Services.cookies.add("example.org", "/", "secure", "true", true, false, false, expiry, {});
   Services.cookies.add("example.org", "/", "insecure", "true", false, false, false, expiry, {});
   Services.cookies.add("example.net", "/", "secure", "true", true, false, false, expiry, {});
   await setupPolicyEngineWithJson({
     "policies": {
@@ -54,10 +53,9 @@ add_task(async function test_cookies_for
   is(JSON.stringify(cookies), JSON.stringify(expected),
      "All stored cookies for blocked origins should be cleared");
 });
 
 add_task(function teardown() {
   for (let host of ["example.com", "example.org", "example.net"]) {
     Services.cookies.removeCookiesWithOriginAttributes("{}", host);
   }
-  EnterprisePolicyTesting.resetRunOnceState();
 });
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_set_homepage.js
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_set_homepage.js
@@ -5,17 +5,16 @@
 // Prefs that will be touched by the test and need to be reset when the test
 // cleans up.
 const TOUCHED_PREFS = {
   "browser.startup.homepage": "String",
   "browser.startup.page": "Int",
   "pref.browser.homepage.disable_button.current_page": "Bool",
   "pref.browser.homepage.disable_button.bookmark_page": "Bool",
   "pref.browser.homepage.disable_button.restore_default": "Bool",
-  "browser.policies.runOncePerModification.setHomepage": "String",
 };
 let ORIGINAL_PREF_VALUE = {};
 
 add_task(function read_original_pref_values() {
   for (let pref in TOUCHED_PREFS) {
     let prefType = TOUCHED_PREFS[pref];
     ORIGINAL_PREF_VALUE[pref] =
       Services.prefs[`get${prefType}Pref`](pref, undefined);
--- a/browser/components/enterprisepolicies/tests/browser/head.js
+++ b/browser/components/enterprisepolicies/tests/browser/head.js
@@ -21,9 +21,11 @@ add_task(async function policies_headjs_
   is(Services.policies.status, Ci.nsIEnterprisePolicies.INACTIVE, "Engine is inactive at the start of the test");
 });
 
 registerCleanupFunction(async function policies_headjs_finishWithCleanSlate() {
   if (Services.policies.status != Ci.nsIEnterprisePolicies.INACTIVE) {
     await setupPolicyEngineWithJson("");
   }
   is(Services.policies.status, Ci.nsIEnterprisePolicies.INACTIVE, "Engine is inactive at the end of the test");
+
+  EnterprisePolicyTesting.resetRunOnceState();
 });