Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External WPT tests for Client hints #9888

Merged
merged 1 commit into from Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions client-hints/accept_ch.https.html
@@ -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>
1 change: 1 addition & 0 deletions client-hints/accept_ch.https.html.headers
@@ -0,0 +1 @@
Accept-CH: device-memory
8 changes: 8 additions & 0 deletions client-hints/echo_device_memory_header_received.py
@@ -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")