mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-19 23:07:33 +09:00
Rename Toolkit's webextensions component directory to better reflect what it is.
This commit is contained in:
parent
6955450f7a
commit
d7d16e7fbb
242 changed files with 4 additions and 2 deletions
|
|
@ -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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue