mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1488312 [wpt PR 12817] - [cookies] Remove cookies when tests complete, a=testonly
Automatic update from web-platform-tests[cookies] Remove cookies when tests complete (#12817) Avoid test interactions by removing cookies at the completion of each test. Use the `add_cleanup` feature of testharness.js to ensure that this occurs regardless of the passing/failing status of each test. Persist the existing "setup" logic which defensively removes cookies as a precaution against still other tests which do not properly restore global state. This resolves a known instability caused by `cookies/prefix/__secure.document-cookie.https.html`. That test sets a cookie with a "Domain" attribute which `cookies/prefix/__secure.header.https.html` is not written to remove. -- wpt-commits: 88e4a9aa658f08de05f6a4d5354c30100c15e688 wpt-pr: 12817
This commit is contained in:
parent
6084e467ce
commit
cbfe2509c4
@ -462019,11 +462019,11 @@
|
||||
"testharness"
|
||||
],
|
||||
"cookies/prefix/document-cookie.non-secure.html": [
|
||||
"1b5edf76a298a18e40b3b4c3cb256b29b65f1a9a",
|
||||
"dbf92207a136e5749f8afb100cbebd2113f9959e",
|
||||
"testharness"
|
||||
],
|
||||
"cookies/resources/cookie-helper.sub.js": [
|
||||
"49cf0b1fdbf46dc0b045d35abf32e16dcb40d184",
|
||||
"d00a11f6f4396177a9885e30adac435fe8dab479",
|
||||
"support"
|
||||
],
|
||||
"cookies/resources/drop.py": [
|
||||
|
@ -6,7 +6,8 @@
|
||||
function create_test(prefix, params, shouldExistInDOM, shouldExistViaHTTP, title) {
|
||||
promise_test(t => {
|
||||
var name = prefix + "prefixtestcookie";
|
||||
erase_cookie_from_js(name);
|
||||
erase_cookie_from_js(name, params);
|
||||
t.add_cleanup(() => erase_cookie_from_js(name, params));
|
||||
var value = "" + Math.random();
|
||||
document.cookie = name + "=" + value + ";" + params;
|
||||
|
||||
|
@ -72,7 +72,8 @@ function create_cookie(origin, name, value, extras) {
|
||||
function set_prefixed_cookie_via_dom_test(options) {
|
||||
promise_test(t => {
|
||||
var name = options.prefix + "prefixtestcookie";
|
||||
erase_cookie_from_js(name);
|
||||
erase_cookie_from_js(name, options.paras);
|
||||
t.add_cleanup(() => erase_cookie_from_js(name, options.params));
|
||||
var value = "" + Math.random();
|
||||
document.cookie = name + "=" + value + ";" + options.params;
|
||||
|
||||
@ -97,7 +98,7 @@ function set_prefixed_cookie_via_http_test(options) {
|
||||
var name = options.prefix + "prefixtestcookie";
|
||||
if (!options.origin) {
|
||||
options.origin = self.origin;
|
||||
erase_cookie_from_js(name);
|
||||
erase_cookie_from_js(name, options.params);
|
||||
return postDelete;
|
||||
} else {
|
||||
return credFetch(options.origin + "/cookies/resources/drop.py?name=" + name)
|
||||
@ -184,9 +185,8 @@ return credFetch(origin + "/cookies/resources/dropSecure.py")
|
||||
//
|
||||
|
||||
// erase cookie value and set for expiration
|
||||
function erase_cookie_from_js(name) {
|
||||
let secure = self.location.protocol == "https:" ? "Secure" : "";
|
||||
document.cookie = `${name}=0; path=/; expires=${new Date(0).toUTCString()}; ${secure}`;
|
||||
function erase_cookie_from_js(name, params) {
|
||||
document.cookie = `${name}=0; expires=${new Date(0).toUTCString()}; ${params};`;
|
||||
var re = new RegExp("(?:^|; )" + name);
|
||||
assert_equals(re.test(document.cookie), false, "Sanity check: " + name + " has been deleted.");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user