зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315504: Split up test_ext_cookies_permissions.
MozReview-Commit-ID: 1hrEi7mljJB --HG-- rename : toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html => toolkit/components/extensions/test/mochitest/head_cookies.js rename : toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html => toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html rename : toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html => toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html extra : rebase_source : e3d14a8aa94d4bbcb818ad2f930411fb9cf30856
This commit is contained in:
Родитель
791bd2888f
Коммит
31e144beda
|
@ -2,6 +2,7 @@
|
|||
support-files =
|
||||
chrome_head.js
|
||||
head.js
|
||||
head_cookies.js
|
||||
file_sample.html
|
||||
webrequest_chromeworker.js
|
||||
webrequest_test.jsm
|
||||
|
@ -22,7 +23,8 @@ skip-if = (os == 'android') # browser.tabs is undefined. Bug 1258975 on android.
|
|||
[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]
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
<!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">
|
||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"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.
|
||||
|
@ -175,156 +165,3 @@ function* testCookies(options) {
|
|||
// 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>
|
|
@ -0,0 +1,112 @@
|
|||
<!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>
|
||||
<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";
|
||||
|
||||
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_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>
|
|
@ -0,0 +1,86 @@
|
|||
<!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>
|
||||
<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";
|
||||
|
||||
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,
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче