Files
firefox/testing/web-platform/tests/client-hints/accept_ch.tentative.sub.https.html
T
Tarun Bansal 1ac7cb893e Bug 1472323 [wpt PR 11736] - WPT tests for http-equiv accept-ch header, a=testonly
Automatic update from web-platform-testsWPT tests for http-equiv accept-ch header

This CL adds WPT tests for http-equiv accept-ch header:
(1) The header is not honored on HTTP pages
(2) Malformed header is not honored
(3) When the header is present, client hints are attached only
    on the same-origin subresources, and not on cross-origin
    subresources in the same navigation.
(4) When the header is present, client hints are attached only
    on the same origin subresources, and not on subresources in
    a new navigation.

Bug: 856700
Change-Id: I3f82df8cd02816b06542256062eb291577ebe8b7
Reviewed-on: https://chromium-review.googlesource.com/1120953
Commit-Queue: Tarun Bansal <[email protected]>
Reviewed-by: Yoav Weiss <[email protected]>
Cr-Commit-Position: refs/heads/master@{#571986}

--

wpt-commits: 2937bc40761173d438d67b6ebf2b0abcfbb911a4
wpt-pr: 11736
2018-07-11 08:03:18 +01:00

63 lines
2.7 KiB
HTML

<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" in the response
// headers, then the browser should attach the specified client hints in the
// HTTP request headers depending on whether the resource is being fetched from
// the same origin or a different origin. Test this functionality by fetching
// same-origin and cross-origin resources from this page. The response headers
// for this page include "Accept-CH: device-memory, dpr, viewport-width, rtt, downlink, ect".
//
// echo_client_hints_received.py sets the response headers depending on the set
// of client hints it receives in the request headers.
promise_test(t => {
return fetch("https://{{domains[]}}:{{ports[https][0]}}/client-hints/echo_client_hints_received.py").then(r => {
assert_equals(r.status, 200)
// Verify that the browser includes client hints in the headers for a
// same-origin fetch.
assert_true(r.headers.has("device-memory-received"), "device-memory-received");
assert_true(r.headers.has("dpr-received"), "dpr-received");
assert_true(r.headers.has("viewport-width-received"), "viewport-width-received");
assert_true(r.headers.has("rtt-received"), "rtt-received");
var rtt = parseInt(r.headers.get("rtt-received"));
assert_greater_than_equal(rtt, 0);
assert_less_than_equal(rtt, 3000);
assert_equals(rtt % 50, 0, 'rtt must be a multiple of 50 msec');
assert_true(r.headers.has("downlink-received"), "downlink-received");
var downlinkKbps = r.headers.get("downlink-received") * 1000;
assert_greater_than_equal(downlinkKbps, 0);
assert_less_than_equal(downlinkKbps, 10000);
assert_in_array(r.headers.get("ect-received"), ["slow-2g", "2g",
"3g", "4g"], 'ect-received is unexpected');
});
}, "Accept-CH header test");
promise_test(t => {
return fetch("https://{{domains[www]}}:{{ports[https][0]}}/client-hints/echo_client_hints_received.py").then(r => {
assert_equals(r.status, 200)
// Verify that the browser does not include client hints in the headers
// for a cross-origin fetch.
assert_false(r.headers.has("device-memory-received"), "device-memory-received");
assert_false(r.headers.has("dpr-received"), "dpr-received");
assert_false(r.headers.has("viewport-width-received"), "viewport-width-received");
assert_false(r.headers.has("rtt-received"), "rtt-received");
assert_false(r.headers.has("downlink-received"), "downlink-received");
assert_false(r.headers.has("ect-received"), "ect-received");
});
}, "Cross-Origin Accept-CH header test");
</script>
</body>
</html>