Bug 1315504: Split up test_ext_cookies_permissions.
authorKris Maglione <maglione.k@gmail.com>
Tue, 15 Nov 2016 12:13:53 -0800
changeset 322758 07fa89dfac8390c8529181cbf818b6e5c1a75bf1
parent 322757 ea07c491499006c6650fbd75431a393c4f4d124d
child 322759 9822e0525b82bcca19078eab6532c8972977a156
push id30961
push userkwierso@gmail.com
push dateThu, 17 Nov 2016 01:08:03 +0000
treeherdermozilla-central@c27117f67fa3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1315504
milestone53.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 1315504: Split up test_ext_cookies_permissions. MozReview-Commit-ID: 1hrEi7mljJB
toolkit/components/extensions/test/mochitest/chrome.ini
toolkit/components/extensions/test/mochitest/head_cookies.js
toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html
--- a/toolkit/components/extensions/test/mochitest/chrome.ini
+++ b/toolkit/components/extensions/test/mochitest/chrome.ini
@@ -1,12 +1,13 @@
 [DEFAULT]
 support-files =
   chrome_head.js
   head.js
+  head_cookies.js
   file_sample.html
   webrequest_chromeworker.js
   webrequest_test.jsm
 tags = webextensions
 
 [test_chrome_ext_background_debug_global.html]
 skip-if = (os == 'android') # android doesn't have devtools
 [test_chrome_ext_background_page.html]
@@ -17,17 +18,18 @@ skip-if = (os == 'android') # browser.ta
 [test_chrome_ext_hybrid_addons.html]
 [test_chrome_ext_trustworthy_origin.html]
 [test_chrome_ext_webnavigation_resolved_urls.html]
 skip-if = (os == 'android') # browser.tabs is undefined. Bug 1258975 on android.
 [test_chrome_ext_shutdown_cleanup.html]
 [test_chrome_native_messaging_paths.html]
 skip-if = os != "mac" && os != "linux"
 [test_ext_cookies_expiry.html]
-[test_ext_cookies_permissions.html]
+[test_ext_cookies_permissions_bad.html]
+[test_ext_cookies_permissions_good.html]
 [test_ext_cookies_containers.html]
 [test_ext_jsversion.html]
 [test_ext_schema.html]
 [test_chrome_ext_storage_cleanup.html]
 [test_chrome_ext_idle.html]
 [test_chrome_ext_downloads_saveAs.html]
 [test_chrome_ext_webrequest_background_events.html]
 skip-if = os == 'android' # webrequest api unsupported (bug 1258975).
rename from toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
rename to toolkit/components/extensions/test/mochitest/head_cookies.js
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
+++ b/toolkit/components/extensions/test/mochitest/head_cookies.js
@@ -1,23 +1,13 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>WebExtension test</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
-  <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
 
-<script type="text/javascript">
-"use strict";
+/* exported testCookies */
 
 function* testCookies(options) {
   // Changing the options object is a bit of a hack, but it allows us to easily
   // pass an expiration date to the background script.
   options.expiry = Date.now() / 1000 + 3600;
 
   async function background(backgroundOptions) {
     // Ask the parent scope to change some cookies we may or may not have
@@ -170,161 +160,8 @@ function* testCookies(options) {
   }
 
   for (let cookie of cookies) {
     cookieSvc.remove(cookie.host, cookie.name, "/", false, {});
   }
   // Make sure we don't silently poison subsequent tests if something goes wrong.
   is(getCookies(options.domain).length, 0, "cookies cleared");
 }
-
-
-add_task(function* init() {
-  // We need to trigger a cookie eviction in order to test our batch delete
-  // observer.
-  SpecialPowers.setIntPref("network.cookie.maxPerHost", 3);
-  SimpleTest.registerCleanupFunction(() => {
-    SpecialPowers.clearUserPref("network.cookie.maxPerHost");
-  });
-});
-
-add_task(function* test_good_cookie_permissions() {
-  info("Test matching, non-secure domain with non-secure cookie");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "http://example.com/",
-    domain: "example.com",
-    secure: false,
-    shouldPass: true,
-  });
-
-  info("Test matching, secure domain with non-secure cookie");
-  yield testCookies({
-    permissions: ["https://example.com/", "cookies"],
-    url: "https://example.com/",
-    domain: "example.com",
-    secure: false,
-    shouldPass: true,
-  });
-
-  info("Test matching, secure domain with secure cookie");
-  yield testCookies({
-    permissions: ["https://example.com/", "cookies"],
-    url: "https://example.com/",
-    domain: "example.com",
-    secure: true,
-    shouldPass: true,
-  });
-
-  info("Test matching subdomain with superdomain privileges, secure cookie (https)");
-  yield testCookies({
-    permissions: ["https://foo.bar.example.com/", "cookies"],
-    url: "https://foo.bar.example.com/",
-    domain: ".example.com",
-    secure: true,
-    shouldPass: true,
-  });
-
-  info("Test matching subdomain with superdomain privileges, non-secure cookie (https)");
-  yield testCookies({
-    permissions: ["https://foo.bar.example.com/", "cookies"],
-    url: "https://foo.bar.example.com/",
-    domain: ".example.com",
-    secure: false,
-    shouldPass: true,
-  });
-
-  info("Test matching subdomain with superdomain privileges, non-secure cookie  (http)");
-  yield testCookies({
-    permissions: ["http://foo.bar.example.com/", "cookies"],
-    url: "http://foo.bar.example.com/",
-    domain: ".example.com",
-    secure: false,
-    shouldPass: true,
-  });
-});
-
-add_task(function* test_bad_cookie_permissions() {
-  info("Test non-matching, non-secure domain with non-secure cookie");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "http://example.net/",
-    domain: "example.net",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test non-matching, secure domain with non-secure cookie");
-  yield testCookies({
-    permissions: ["https://example.com/", "cookies"],
-    url: "https://example.net/",
-    domain: "example.net",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test non-matching, secure domain with secure cookie");
-  yield testCookies({
-    permissions: ["https://example.com/", "cookies"],
-    url: "https://example.net/",
-    domain: "example.net",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test matching subdomain with superdomain privileges, secure cookie (http)");
-  yield testCookies({
-    permissions: ["http://foo.bar.example.com/", "cookies"],
-    url: "http://foo.bar.example.com/",
-    domain: ".example.com",
-    secure: true,
-    shouldPass: false,
-    shouldWrite: true,
-  });
-
-  info("Test matching, non-secure domain with secure cookie");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "http://example.com/",
-    domain: "example.com",
-    secure: true,
-    shouldPass: false,
-    shouldWrite: true,
-  });
-
-  info("Test matching, non-secure host, secure URL");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "https://example.com/",
-    domain: "example.com",
-    secure: true,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test non-matching domain");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "http://example.com/",
-    domain: "example.net",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test invalid scheme");
-  yield testCookies({
-    permissions: ["ftp://example.com/", "cookies"],
-    url: "ftp://example.com/",
-    domain: "example.com",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-});
-
-</script>
-
-</body>
-</html>
copy from toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
copy to toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html
@@ -2,251 +2,33 @@
 <html>
 <head>
   <title>WebExtension test</title>
   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="chrome_head.js"></script>
   <script type="text/javascript" src="head.js"></script>
+  <script type="text/javascript" src="head_cookies.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
-function* testCookies(options) {
-  // Changing the options object is a bit of a hack, but it allows us to easily
-  // pass an expiration date to the background script.
-  options.expiry = Date.now() / 1000 + 3600;
-
-  async function background(backgroundOptions) {
-    // Ask the parent scope to change some cookies we may or may not have
-    // permission for.
-    let awaitChanges = new Promise(resolve => {
-      browser.test.onMessage.addListener(msg => {
-        browser.test.assertEq("cookies-changed", msg, "browser.test.onMessage");
-        resolve();
-      });
-    });
-
-    let changed = [];
-    browser.cookies.onChanged.addListener(event => {
-      changed.push(`${event.cookie.name}:${event.cause}`);
-    });
-    browser.test.sendMessage("change-cookies");
-
-
-    // Try to access some cookies in various ways.
-    let {url, domain, secure} = backgroundOptions;
-
-    let failures = 0;
-    let tallyFailure = error => {
-      failures++;
-    };
-
-    try {
-      await awaitChanges;
-
-      let cookie = await browser.cookies.get({url, name: "foo"});
-      browser.test.assertEq(backgroundOptions.shouldPass, cookie != null, "should pass == get cookie");
-
-      let cookies = await browser.cookies.getAll({domain});
-      if (backgroundOptions.shouldPass) {
-        browser.test.assertEq(2, cookies.length, "expected number of cookies");
-      } else {
-        browser.test.assertEq(0, cookies.length, "expected number of cookies");
-      }
-
-      await Promise.all([
-        browser.cookies.set({url, domain, secure, name: "foo", "value": "baz", expirationDate: backgroundOptions.expiry}).catch(tallyFailure),
-        browser.cookies.set({url, domain, secure, name: "bar", "value": "quux", expirationDate: backgroundOptions.expiry}).catch(tallyFailure),
-        browser.cookies.remove({url, name: "deleted"}),
-      ]);
-
-      if (backgroundOptions.shouldPass) {
-        // The order of eviction events isn't guaranteed, so just check that
-        // it's there somewhere.
-        let evicted = changed.indexOf("evicted:evicted");
-        if (evicted < 0) {
-          browser.test.fail("got no eviction event");
-        } else {
-          browser.test.succeed("got eviction event");
-          changed.splice(evicted, 1);
-        }
-
-        browser.test.assertEq("x:explicit,x:overwrite,x:explicit,x:explicit,foo:overwrite,foo:explicit,bar:explicit,deleted:explicit",
-                              changed.join(","), "expected changes");
-      } else {
-        browser.test.assertEq("", changed.join(","), "expected no changes");
-      }
-
-      if (!(backgroundOptions.shouldPass || backgroundOptions.shouldWrite)) {
-        browser.test.assertEq(2, failures, "Expected failures");
-      } else {
-        browser.test.assertEq(0, failures, "Expected no failures");
-      }
-
-      browser.test.notifyPass("cookie-permissions");
-    } catch (error) {
-      browser.test.fail(`Error: ${error} :: ${error.stack}`);
-      browser.test.notifyFail("cookie-permissions");
-    }
-  }
-
-  let extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "permissions": options.permissions,
-    },
-
-    background: `(${background})(${JSON.stringify(options)})`,
-  });
-
-
-  let cookieSvc = SpecialPowers.Services.cookies;
-
-  let domain = options.domain.replace(/^\.?/, ".");
-
-  // This will be evicted after we add a fourth cookie.
-  cookieSvc.add(domain, "/", "evicted", "bar", options.secure, false, false, options.expiry);
-  // This will be modified by the background script.
-  cookieSvc.add(domain, "/", "foo", "bar", options.secure, false, false, options.expiry);
-  // This will be deleted by the background script.
-  cookieSvc.add(domain, "/", "deleted", "bar", options.secure, false, false, options.expiry);
-
-
-  yield extension.startup();
-
-  yield extension.awaitMessage("change-cookies");
-  cookieSvc.add(domain, "/", "x", "y", options.secure, false, false, options.expiry);
-  cookieSvc.add(domain, "/", "x", "z", options.secure, false, false, options.expiry);
-  cookieSvc.remove(domain, "x", "/", false, {});
-  extension.sendMessage("cookies-changed");
-
-  yield extension.awaitFinish("cookie-permissions");
-  yield extension.unload();
-
-
-  function getCookies(host) {
-    let cookies = [];
-    let enum_ = cookieSvc.getCookiesFromHost(host, {});
-    while (enum_.hasMoreElements()) {
-      cookies.push(enum_.getNext().QueryInterface(SpecialPowers.Ci.nsICookie2));
-    }
-    return cookies.sort((a, b) => String.localeCompare(a.name, b.name));
-  }
-
-  let cookies = getCookies(options.domain);
-  info(`Cookies: ${cookies.map(c => `${c.name}=${c.value}`)}`);
-
-  if (options.shouldPass) {
-    is(cookies.length, 2, "expected two cookies for host");
-
-    is(cookies[0].name, "bar", "correct cookie name");
-    is(cookies[0].value, "quux", "correct cookie value");
-
-    is(cookies[1].name, "foo", "correct cookie name");
-    is(cookies[1].value, "baz", "correct cookie value");
-  } else if (options.shouldWrite) {
-    // Note: |shouldWrite| applies only when |shouldPass| is false.
-    // This is necessary because, unfortunately, websites (and therefore web
-    // extensions) are allowed to write some cookies which they're not allowed
-    // to read.
-    is(cookies.length, 3, "expected three cookies for host");
-
-    is(cookies[0].name, "bar", "correct cookie name");
-    is(cookies[0].value, "quux", "correct cookie value");
-
-    is(cookies[1].name, "deleted", "correct cookie name");
-
-    is(cookies[2].name, "foo", "correct cookie name");
-    is(cookies[2].value, "baz", "correct cookie value");
-  } else {
-    is(cookies.length, 2, "expected two cookies for host");
-
-    is(cookies[0].name, "deleted", "correct second cookie name");
-
-    is(cookies[1].name, "foo", "correct cookie name");
-    is(cookies[1].value, "bar", "correct cookie value");
-  }
-
-  for (let cookie of cookies) {
-    cookieSvc.remove(cookie.host, cookie.name, "/", false, {});
-  }
-  // Make sure we don't silently poison subsequent tests if something goes wrong.
-  is(getCookies(options.domain).length, 0, "cookies cleared");
-}
-
-
 add_task(function* init() {
   // We need to trigger a cookie eviction in order to test our batch delete
   // observer.
   SpecialPowers.setIntPref("network.cookie.maxPerHost", 3);
   SimpleTest.registerCleanupFunction(() => {
     SpecialPowers.clearUserPref("network.cookie.maxPerHost");
   });
 });
 
-add_task(function* test_good_cookie_permissions() {
-  info("Test matching, non-secure domain with non-secure cookie");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "http://example.com/",
-    domain: "example.com",
-    secure: false,
-    shouldPass: true,
-  });
-
-  info("Test matching, secure domain with non-secure cookie");
-  yield testCookies({
-    permissions: ["https://example.com/", "cookies"],
-    url: "https://example.com/",
-    domain: "example.com",
-    secure: false,
-    shouldPass: true,
-  });
-
-  info("Test matching, secure domain with secure cookie");
-  yield testCookies({
-    permissions: ["https://example.com/", "cookies"],
-    url: "https://example.com/",
-    domain: "example.com",
-    secure: true,
-    shouldPass: true,
-  });
-
-  info("Test matching subdomain with superdomain privileges, secure cookie (https)");
-  yield testCookies({
-    permissions: ["https://foo.bar.example.com/", "cookies"],
-    url: "https://foo.bar.example.com/",
-    domain: ".example.com",
-    secure: true,
-    shouldPass: true,
-  });
-
-  info("Test matching subdomain with superdomain privileges, non-secure cookie (https)");
-  yield testCookies({
-    permissions: ["https://foo.bar.example.com/", "cookies"],
-    url: "https://foo.bar.example.com/",
-    domain: ".example.com",
-    secure: false,
-    shouldPass: true,
-  });
-
-  info("Test matching subdomain with superdomain privileges, non-secure cookie  (http)");
-  yield testCookies({
-    permissions: ["http://foo.bar.example.com/", "cookies"],
-    url: "http://foo.bar.example.com/",
-    domain: ".example.com",
-    secure: false,
-    shouldPass: true,
-  });
-});
-
 add_task(function* test_bad_cookie_permissions() {
   info("Test non-matching, non-secure domain with non-secure cookie");
   yield testCookies({
     permissions: ["http://example.com/", "cookies"],
     url: "http://example.net/",
     domain: "example.net",
     secure: false,
     shouldPass: false,
copy from toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
copy to toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html
@@ -2,186 +2,24 @@
 <html>
 <head>
   <title>WebExtension test</title>
   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="chrome_head.js"></script>
   <script type="text/javascript" src="head.js"></script>
+  <script type="text/javascript" src="head_cookies.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
-function* testCookies(options) {
-  // Changing the options object is a bit of a hack, but it allows us to easily
-  // pass an expiration date to the background script.
-  options.expiry = Date.now() / 1000 + 3600;
-
-  async function background(backgroundOptions) {
-    // Ask the parent scope to change some cookies we may or may not have
-    // permission for.
-    let awaitChanges = new Promise(resolve => {
-      browser.test.onMessage.addListener(msg => {
-        browser.test.assertEq("cookies-changed", msg, "browser.test.onMessage");
-        resolve();
-      });
-    });
-
-    let changed = [];
-    browser.cookies.onChanged.addListener(event => {
-      changed.push(`${event.cookie.name}:${event.cause}`);
-    });
-    browser.test.sendMessage("change-cookies");
-
-
-    // Try to access some cookies in various ways.
-    let {url, domain, secure} = backgroundOptions;
-
-    let failures = 0;
-    let tallyFailure = error => {
-      failures++;
-    };
-
-    try {
-      await awaitChanges;
-
-      let cookie = await browser.cookies.get({url, name: "foo"});
-      browser.test.assertEq(backgroundOptions.shouldPass, cookie != null, "should pass == get cookie");
-
-      let cookies = await browser.cookies.getAll({domain});
-      if (backgroundOptions.shouldPass) {
-        browser.test.assertEq(2, cookies.length, "expected number of cookies");
-      } else {
-        browser.test.assertEq(0, cookies.length, "expected number of cookies");
-      }
-
-      await Promise.all([
-        browser.cookies.set({url, domain, secure, name: "foo", "value": "baz", expirationDate: backgroundOptions.expiry}).catch(tallyFailure),
-        browser.cookies.set({url, domain, secure, name: "bar", "value": "quux", expirationDate: backgroundOptions.expiry}).catch(tallyFailure),
-        browser.cookies.remove({url, name: "deleted"}),
-      ]);
-
-      if (backgroundOptions.shouldPass) {
-        // The order of eviction events isn't guaranteed, so just check that
-        // it's there somewhere.
-        let evicted = changed.indexOf("evicted:evicted");
-        if (evicted < 0) {
-          browser.test.fail("got no eviction event");
-        } else {
-          browser.test.succeed("got eviction event");
-          changed.splice(evicted, 1);
-        }
-
-        browser.test.assertEq("x:explicit,x:overwrite,x:explicit,x:explicit,foo:overwrite,foo:explicit,bar:explicit,deleted:explicit",
-                              changed.join(","), "expected changes");
-      } else {
-        browser.test.assertEq("", changed.join(","), "expected no changes");
-      }
-
-      if (!(backgroundOptions.shouldPass || backgroundOptions.shouldWrite)) {
-        browser.test.assertEq(2, failures, "Expected failures");
-      } else {
-        browser.test.assertEq(0, failures, "Expected no failures");
-      }
-
-      browser.test.notifyPass("cookie-permissions");
-    } catch (error) {
-      browser.test.fail(`Error: ${error} :: ${error.stack}`);
-      browser.test.notifyFail("cookie-permissions");
-    }
-  }
-
-  let extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "permissions": options.permissions,
-    },
-
-    background: `(${background})(${JSON.stringify(options)})`,
-  });
-
-
-  let cookieSvc = SpecialPowers.Services.cookies;
-
-  let domain = options.domain.replace(/^\.?/, ".");
-
-  // This will be evicted after we add a fourth cookie.
-  cookieSvc.add(domain, "/", "evicted", "bar", options.secure, false, false, options.expiry);
-  // This will be modified by the background script.
-  cookieSvc.add(domain, "/", "foo", "bar", options.secure, false, false, options.expiry);
-  // This will be deleted by the background script.
-  cookieSvc.add(domain, "/", "deleted", "bar", options.secure, false, false, options.expiry);
-
-
-  yield extension.startup();
-
-  yield extension.awaitMessage("change-cookies");
-  cookieSvc.add(domain, "/", "x", "y", options.secure, false, false, options.expiry);
-  cookieSvc.add(domain, "/", "x", "z", options.secure, false, false, options.expiry);
-  cookieSvc.remove(domain, "x", "/", false, {});
-  extension.sendMessage("cookies-changed");
-
-  yield extension.awaitFinish("cookie-permissions");
-  yield extension.unload();
-
-
-  function getCookies(host) {
-    let cookies = [];
-    let enum_ = cookieSvc.getCookiesFromHost(host, {});
-    while (enum_.hasMoreElements()) {
-      cookies.push(enum_.getNext().QueryInterface(SpecialPowers.Ci.nsICookie2));
-    }
-    return cookies.sort((a, b) => String.localeCompare(a.name, b.name));
-  }
-
-  let cookies = getCookies(options.domain);
-  info(`Cookies: ${cookies.map(c => `${c.name}=${c.value}`)}`);
-
-  if (options.shouldPass) {
-    is(cookies.length, 2, "expected two cookies for host");
-
-    is(cookies[0].name, "bar", "correct cookie name");
-    is(cookies[0].value, "quux", "correct cookie value");
-
-    is(cookies[1].name, "foo", "correct cookie name");
-    is(cookies[1].value, "baz", "correct cookie value");
-  } else if (options.shouldWrite) {
-    // Note: |shouldWrite| applies only when |shouldPass| is false.
-    // This is necessary because, unfortunately, websites (and therefore web
-    // extensions) are allowed to write some cookies which they're not allowed
-    // to read.
-    is(cookies.length, 3, "expected three cookies for host");
-
-    is(cookies[0].name, "bar", "correct cookie name");
-    is(cookies[0].value, "quux", "correct cookie value");
-
-    is(cookies[1].name, "deleted", "correct cookie name");
-
-    is(cookies[2].name, "foo", "correct cookie name");
-    is(cookies[2].value, "baz", "correct cookie value");
-  } else {
-    is(cookies.length, 2, "expected two cookies for host");
-
-    is(cookies[0].name, "deleted", "correct second cookie name");
-
-    is(cookies[1].name, "foo", "correct cookie name");
-    is(cookies[1].value, "bar", "correct cookie value");
-  }
-
-  for (let cookie of cookies) {
-    cookieSvc.remove(cookie.host, cookie.name, "/", false, {});
-  }
-  // Make sure we don't silently poison subsequent tests if something goes wrong.
-  is(getCookies(options.domain).length, 0, "cookies cleared");
-}
-
-
 add_task(function* init() {
   // We need to trigger a cookie eviction in order to test our batch delete
   // observer.
   SpecialPowers.setIntPref("network.cookie.maxPerHost", 3);
   SimpleTest.registerCleanupFunction(() => {
     SpecialPowers.clearUserPref("network.cookie.maxPerHost");
   });
 });
@@ -237,94 +75,12 @@ add_task(function* test_good_cookie_perm
     permissions: ["http://foo.bar.example.com/", "cookies"],
     url: "http://foo.bar.example.com/",
     domain: ".example.com",
     secure: false,
     shouldPass: true,
   });
 });
 
-add_task(function* test_bad_cookie_permissions() {
-  info("Test non-matching, non-secure domain with non-secure cookie");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "http://example.net/",
-    domain: "example.net",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test non-matching, secure domain with non-secure cookie");
-  yield testCookies({
-    permissions: ["https://example.com/", "cookies"],
-    url: "https://example.net/",
-    domain: "example.net",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test non-matching, secure domain with secure cookie");
-  yield testCookies({
-    permissions: ["https://example.com/", "cookies"],
-    url: "https://example.net/",
-    domain: "example.net",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test matching subdomain with superdomain privileges, secure cookie (http)");
-  yield testCookies({
-    permissions: ["http://foo.bar.example.com/", "cookies"],
-    url: "http://foo.bar.example.com/",
-    domain: ".example.com",
-    secure: true,
-    shouldPass: false,
-    shouldWrite: true,
-  });
-
-  info("Test matching, non-secure domain with secure cookie");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "http://example.com/",
-    domain: "example.com",
-    secure: true,
-    shouldPass: false,
-    shouldWrite: true,
-  });
-
-  info("Test matching, non-secure host, secure URL");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "https://example.com/",
-    domain: "example.com",
-    secure: true,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test non-matching domain");
-  yield testCookies({
-    permissions: ["http://example.com/", "cookies"],
-    url: "http://example.com/",
-    domain: "example.net",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-
-  info("Test invalid scheme");
-  yield testCookies({
-    permissions: ["ftp://example.com/", "cookies"],
-    url: "ftp://example.com/",
-    domain: "example.com",
-    secure: false,
-    shouldPass: false,
-    shouldWrite: false,
-  });
-});
-
 </script>
 
 </body>
 </html>