-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This CL includes the test for "Accept-CH" header. If the origin includes "Accept-CH" in the response header, then the browser should include the specified client hints in the HTTP request headers for the resources contained in that page. Bug: 817049 Change-Id: Id74193ab7a1cc3c4b03d66e080c43c64a6fcfbb2 Reviewed-on: https://chromium-review.googlesource.com/951867 Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Tarun Bansal <tbansal@chromium.org> Cr-Commit-Position: refs/heads/master@{#542724}
- Loading branch information
1 parent
6163df2
commit 6339a50
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<html> | ||
<body> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
|
||
// If the response for the HTML file contains "Accept-CH: device-memory" in | ||
// the response headers, then the browser should attach device-memory client | ||
// hint in the HTTP request headers. Test this functionality by fetching an | ||
// XHR from this page. The response headers for this page include | ||
// "Accept-CH: device-memory". | ||
// | ||
// echo_device_memory_header_received.py includes "device-memory-received" in | ||
// the response headers only if the request included "device-memory" in the | ||
// headers. | ||
|
||
promise_test(t => { | ||
return fetch("/client-hints/echo_device_memory_header_received.py").then(r => { | ||
assert_equals(r.status, 200) | ||
// Verify that the browser included "device-memory" in the headers when | ||
// fetching the XHR. | ||
assert_true(r.headers.has("device-memory-received")); | ||
}); | ||
}, "Accept-CH header test"); | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Accept-CH: device-memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
def main(request, response): | ||
""" | ||
Simple handler that sets a response header based on if device-memory | ||
request header was received or not. | ||
""" | ||
|
||
if "device-memory" in request.headers: | ||
response.headers.set("device-memory-received", "true") |