Commit 7e1c3081 authored by Maks Orlovich's avatar Maks Orlovich Committed by Commit Bot

Test behavior of document.cookie on navigated-away-from documents.

https://html.spec.whatwg.org/multipage/dom.html#dom-document-cookie specifies
that a document with null browsing context is "cookie-averse", and that

"On getting, if the document is a cookie-averse Document object, then
 the user agent must return the empty string. "

and:

"On setting, if the document is a cookie-averse Document object, then
 the user agent must do nothing. "

(Adding test since refactors I am working on for document.cookie implementation
 have their complexity points around this sort of stuff).

Change-Id: I2f2c163276a316b77166762d0b196dcdebb7a65a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1652544
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678342}
parent f04bd1b3
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<iframe id="if" src="about:blank"></iframe>
<script>
var t = async_test("document.cookie behavior on documents without browser context");
t.add_cleanup(function() {
document.cookie = "nav_away_test=yes;max-age=0";
});
function step2() {
t.step(function() {
// Get from saved doc should fail.
assert_equals(window.iframeDoc.cookie, "");
// Try set from saved doc, should do nothing.
window.iframeDoc.cookie = "nav_away_test=second";
assert_equals(window.iframeDoc.cookie, "");
assert_not_equals(document.cookie.indexOf("nav_away_test=yes"), -1);
});
t.done();
}
t.step(function() {
document.cookie = "nav_away_test=yes";
var iframe = document.getElementById("if");
// Save original document.
window.iframeDoc = iframe.contentDocument;
assert_not_equals(window.iframeDoc.cookie.indexOf("nav_away_test=yes"), -1);
// Navigate away.
iframe.onload = step2;
iframe.contentWindow.location = "/common/blank.html";
})
</script>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment