Bug 1446508 - clear runOnce state after every test. r=felipe
MozReview-Commit-ID: D8cQlN6mz42
--- 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();
});