Skip to content

Commit b42bb20

Browse files
Yoav Weisschromium-wpt-export-bot
authored andcommitted
__Http- cookie prefix
This CL implements the __Http- [1] cookie prefixes. They enable site operators to know that a certain cookie was issued with the HttpOnly attribute, and was not set by a malicious script on the client side. [1] httpwg/http-extensions#3110 Bug: 426096760 Change-Id: I13205747406a8b3c33bd9f0e60abd7526eb9490d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6638647 Reviewed-by: Maks Orlovich <[email protected]> Reviewed-by: Chris Fredrickson <[email protected]> Commit-Queue: Yoav Weiss (@Shopify) <[email protected]> Cr-Commit-Position: refs/heads/main@{#1478348}
1 parent 0340513 commit b42bb20

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

cookie-store/cookieStore_special_names.https.any.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@
5454
}, `cookieStore.set with ${prefix} prefix a path option`);
5555
});
5656

57+
['__Http-', '__http-'].forEach(prefix => {
58+
promise_test(async testCase => {
59+
await promise_rejects_js(testCase, TypeError,
60+
cookieStore.set({ name: `${prefix}cookie-name`, value: 'cookie-value'}));
61+
}, `cookieStore.set with ${prefix} prefix rejects`);
62+
});
63+
5764
promise_test(async testCase => {
5865
let exceptionThrown = false;
5966
try {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<script src="/cookies/resources/cookie-helper.sub.js"></script>
5+
<script>
6+
set_prefixed_cookie_via_dom_test({
7+
prefix: "__Http-",
8+
params: "Path=/",
9+
shouldExistInDOM: false,
10+
shouldExistViaHTTP: false,
11+
title: "__Http: Does not set via DOM 'Path=/'"
12+
});
13+
14+
set_prefixed_cookie_via_dom_test({
15+
prefix: "__Http-",
16+
params: "Secure; Path=/",
17+
shouldExistInDOM: false,
18+
shouldExistViaHTTP: false,
19+
title: "__Http: Does not set via DOM 'Secure; Path=/'"
20+
});
21+
22+
set_prefixed_cookie_via_dom_test({
23+
prefix: "__Http-",
24+
params: "Secure; Path=/;httponly",
25+
shouldExistInDOM: false,
26+
shouldExistViaHTTP: false,
27+
title: "__Http: Does not set via DOM 'Secure; Path=/; httponly'"
28+
});
29+
30+
set_prefixed_cookie_via_http_test({
31+
prefix: "__Http-",
32+
params: "Path=/",
33+
shouldExistViaHTTP: false,
34+
origin: self.origin,
35+
title: "__Http: Does not set via HTTP with 'Path=/;' (without Secure)"
36+
});
37+
38+
set_prefixed_cookie_via_http_test({
39+
prefix: "__Http-",
40+
params: "Secure;Path=/",
41+
shouldExistViaHTTP: false,
42+
origin: self.origin,
43+
title: "__Http: Does not set via HTTP with 'Secure; Path=/'"
44+
});
45+
46+
set_prefixed_cookie_via_http_test({
47+
prefix: "__Http-",
48+
params: "Secure;Path=/;httponly",
49+
shouldExistViaHTTP: true,
50+
origin: self.origin,
51+
title: "__Http: Does set via HTTP with 'Secure; Path=/;httponly'"
52+
});
53+
54+
set_prefixed_cookie_via_http_test({
55+
prefix: "__Http-",
56+
params: "Secure;Path=/cookies/;httponly",
57+
shouldExistViaHTTP: true,
58+
origin: self.origin,
59+
title: "__Http: Does set via HTTP with 'Secure; Path=/cookies/;httponly'"
60+
});
61+
</script>

0 commit comments

Comments
 (0)