Bug 1429169 - Fix test to prevent it from interfering with the new test added draft
authorKirk Steuber <ksteuber@mozilla.com>
Fri, 30 Mar 2018 13:32:48 -0700
changeset 775298 dbe54bec827a80902d28a1d8198991c0eb2ea659
parent 775297 bbba03890a6062526c20e854c9a0d23e8ea81549
push id104688
push userksteuber@mozilla.com
push dateFri, 30 Mar 2018 20:38:45 +0000
bugs1429169
milestone61.0a1
Bug 1429169 - Fix test to prevent it from interfering with the new test added MozReview-Commit-ID: 3qNfigDXibO
browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js
--- 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,25 +1,28 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
+const HOSTNAME_DOMAIN = "browser_policy_clear_blocked_cookies.com";
+const ORIGIN_DOMAIN = "browser_policy_clear_blocked_cookies.org";
+
 add_task(async function setup() {
   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(HOSTNAME_DOMAIN, "/", "secure", "true", true, false, false, expiry, {});
+  Services.cookies.add(HOSTNAME_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {});
+  Services.cookies.add(ORIGIN_DOMAIN, "/", "secure", "true", true, false, false, expiry, {});
+  Services.cookies.add(ORIGIN_DOMAIN, "/", "insecure", "true", false, false, false, expiry, {});
   Services.cookies.add("example.net", "/", "secure", "true", true, false, false, expiry, {});
   await setupPolicyEngineWithJson({
     "policies": {
       "Cookies": {
         "Block": [
-          "http://example.com",
-          "https://example.org:8080"
+          `http://${HOSTNAME_DOMAIN}`,
+          `https://${ORIGIN_DOMAIN}:8080`
         ]
       }
     }
   });
 });
 
 function retrieve_all_cookies(host) {
   const values = [];
@@ -32,30 +35,30 @@ function retrieve_all_cookies(host) {
       path: cookie.path
     });
   }
   return values;
 }
 
 add_task(async function test_cookies_for_blocked_sites_cleared() {
   const cookies = {
-    hostname: retrieve_all_cookies("example.com"),
-    origin: retrieve_all_cookies("example.org"),
+    hostname: retrieve_all_cookies(HOSTNAME_DOMAIN),
+    origin: retrieve_all_cookies(ORIGIN_DOMAIN),
     keep: retrieve_all_cookies("example.net")
   };
   const expected = {
     hostname: [],
     origin: [],
     keep: [
       {host: "example.net",
        name: "secure",
        path: "/"}
     ]
   };
   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"]) {
+  for (let host of [HOSTNAME_DOMAIN, ORIGIN_DOMAIN, "example.net"]) {
     Services.cookies.removeCookiesWithOriginAttributes("{}", host);
   }
 });