diff options
Diffstat (limited to 'toolkit/components/webextensions/test/mochitest/test_ext_cookies_containers.html')
-rw-r--r-- | toolkit/components/webextensions/test/mochitest/test_ext_cookies_containers.html | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/toolkit/components/webextensions/test/mochitest/test_ext_cookies_containers.html b/toolkit/components/webextensions/test/mochitest/test_ext_cookies_containers.html deleted file mode 100644 index bc4994eec..000000000 --- a/toolkit/components/webextensions/test/mochitest/test_ext_cookies_containers.html +++ /dev/null @@ -1,93 +0,0 @@ -<!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> - -<script type="text/javascript"> -"use strict"; - -add_task(function* setup() { - // make sure userContext is enabled. - return SpecialPowers.pushPrefEnv({"set": [ - ["privacy.userContext.enabled", true], - ]}); -}); - -add_task(function* test_cookie_containers() { - async function background() { - function assertExpected(expected, cookie) { - for (let key of Object.keys(cookie)) { - browser.test.assertTrue(key in expected, `found property ${key}`); - browser.test.assertEq(expected[key], cookie[key], `property value for ${key} is correct`); - } - browser.test.assertEq(Object.keys(expected).length, Object.keys(cookie).length, "all expected properties found"); - } - - const TEST_URL = "http://example.org/"; - const THE_FUTURE = Date.now() + 5 * 60; - - let expected = { - name: "name1", - value: "value1", - domain: "example.org", - hostOnly: true, - path: "/", - secure: false, - httpOnly: false, - session: false, - expirationDate: THE_FUTURE, - storeId: "firefox-container-1", - }; - - let cookie = await browser.cookies.set({ - url: TEST_URL, name: "name1", value: "value1", - expirationDate: THE_FUTURE, storeId: "firefox-container-1", - }); - browser.test.assertEq("firefox-container-1", cookie.storeId, "the cookie has the correct storeId"); - - cookie = await browser.cookies.get({url: TEST_URL, name: "name1"}); - browser.test.assertEq(null, cookie, "get() without storeId returns null"); - - cookie = await browser.cookies.get({url: TEST_URL, name: "name1", storeId: "firefox-container-1"}); - assertExpected(expected, cookie); - - let cookies = await browser.cookies.getAll({storeId: "firefox-default"}); - browser.test.assertEq(0, cookies.length, "getAll() with default storeId returns an empty array"); - - cookies = await browser.cookies.getAll({storeId: "firefox-container-1"}); - browser.test.assertEq(1, cookies.length, "one cookie found for matching domain"); - assertExpected(expected, cookies[0]); - - let details = await browser.cookies.remove({url: TEST_URL, name: "name1", storeId: "firefox-container-1"}); - assertExpected({url: TEST_URL, name: "name1", storeId: "firefox-container-1"}, details); - - cookie = await browser.cookies.get({url: TEST_URL, name: "name1", storeId: "firefox-container-1"}); - browser.test.assertEq(null, cookie, "removed cookie not found"); - - browser.test.notifyPass("cookies"); - } - - let extension = ExtensionTestUtils.loadExtension({ - background, - manifest: { - permissions: ["cookies", "*://example.org/"], - }, - }); - - yield extension.startup(); - yield extension.awaitFinish("cookies"); - yield extension.unload(); -}); - -</script> - -</body> -</html> |