Skip to content

Commit

Permalink
[Accept-CH] Ensure multiple headers are respected
Browse files Browse the repository at this point in the history
As per https://www.rfc-editor.org/rfc/rfc2068#section-4.2
we need to be sure we treat:
Accept-CH: A, B
the same as:
Accept-CH: A
Accept-CH: B

We also should be sure to treat:
Accept-CH:
the same as:
Accept-CH:
Accept-CH: A
Accept-CH: B
Accept-CH:

Bug: 1422562
Change-Id: Idb40b732c37ebebfdcaaa34b695347ccf7e16562
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4324500
Commit-Queue: Ari Chivukula <[email protected]>
Auto-Submit: Ari Chivukula <[email protected]>
Reviewed-by: Yoav Weiss <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1115341}
  • Loading branch information
arichiv authored and chromium-wpt-export-bot committed Mar 9, 2023
1 parent b8b076a commit 26c02b1
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client-hints/accept-ch-change.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@
// settings have been saved
await open_and_expect_headers("resources/expect-no-client-hints-headers.html");

// Check that multiple headers will fill the cache.
await open_and_add_load_event("resources/accept-ch-split.html");
await open_and_expect_headers("resources/expect-client-hints-headers.html");

// Check that a mix of empty and full headers drops the cache.
await open_and_add_load_event("resources/accept-ch-mixed.html");
await open_and_expect_headers("resources/expect-no-client-hints-headers.html");

}, "Accept-CH changes based on header");

</script>
Expand Down
10 changes: 10 additions & 0 deletions client-hints/resources/accept-ch-mixed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<body>

<!-- An empty webpage whose response headers include empty and full
Accept-CH headers. Fetching this webpage should cause
the hint cache to be dropped.-->

</body>
</html>
5 changes: 5 additions & 0 deletions client-hints/resources/accept-ch-mixed.html.headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Accept-CH:
Accept-CH: sec-ch-device-memory
Accept-CH: device-memory
Accept-CH:
Access-Control-Allow-Origin: *
10 changes: 10 additions & 0 deletions client-hints/resources/accept-ch-split.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<body>

<!-- An empty webpage whose response headers include only
non-empty Accept-CH headers. Fetching this webpage should cause
hints to be added to the cache.-->

</body>
</html>
3 changes: 3 additions & 0 deletions client-hints/resources/accept-ch-split.html.headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Accept-CH: sec-ch-device-memory
Accept-CH: device-memory
Access-Control-Allow-Origin: *

0 comments on commit 26c02b1

Please sign in to comment.