mirror of
https://github.com/servo/servo.git
synced 2025-08-23 14:25:33 +01:00
Update web-platform-tests to revision 6340a70e8df5e850ea44436b54105f59dd5aa22e
This commit is contained in:
parent
5788e8c050
commit
7be3e2f06b
131 changed files with 3893 additions and 1852 deletions
|
@ -0,0 +1,73 @@
|
|||
const echo = "/client-hints/echo_client_hints_received.py";
|
||||
const accept = "/client-hints/resources/accept_ch_lifetime.html";
|
||||
const httpequiv_accept = "/client-hints/resources/http_equiv_accept_ch_lifetime.html";
|
||||
const expect = "/client-hints/resources/expect_client_hints_headers.html"
|
||||
const do_not_expect = "/client-hints/resources/do_not_expect_client_hints_headers.html"
|
||||
|
||||
const host_info = get_host_info();
|
||||
const run_test = test => {
|
||||
// Test is marked as tentative until https://github.com/whatwg/fetch/issues/726
|
||||
// is resolved.
|
||||
|
||||
// First, verify the initial state to make sure that the browser does not have
|
||||
// client hints preferences cached from a previous run of the test.
|
||||
promise_test(t => {
|
||||
return fetch(test.initial_url).then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
// Verify that the browser did not include client hints in the request
|
||||
// headers when fetching echo_client_hints_received.py.
|
||||
assert_false(r.headers.has("device-memory-received"),
|
||||
"device-memory-received");
|
||||
});
|
||||
}, test.name + " precondition: Test that the browser does not have client " +
|
||||
"hints preferences cached");
|
||||
|
||||
// Then, attempt to set Accept-CH-Lifetime for 1 second
|
||||
promise_test(t => {
|
||||
return new Promise(resolve => {
|
||||
if (test.type == "navigation") {
|
||||
const win = window.open(test.accept_url);
|
||||
assert_not_equals(win, null, "Popup windows not allowed?");
|
||||
addEventListener('message', t.step_func(() => {
|
||||
win.close();
|
||||
resolve();
|
||||
}), false);
|
||||
} else if (test.type == "iframe") {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.addEventListener('load', t.step_func(() => {
|
||||
resolve();
|
||||
}), false);
|
||||
iframe.src = test.accept_url;
|
||||
document.body.appendChild(iframe);
|
||||
} else if (test.type == "subresource") {
|
||||
fetch(test.accept_url).then(r => {
|
||||
assert_equals(r.status, 200, "subresource response status")
|
||||
// Verify that the browser did not include client hints in the request
|
||||
// headers, just because we can..
|
||||
assert_false(r.headers.has("device-memory-received"),
|
||||
"device-memory-received",
|
||||
"subresource request had no client hints");
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
assert_unreached("unknown test type");
|
||||
}
|
||||
});
|
||||
}, test.name + " set Accept-CH-Lifetime");
|
||||
|
||||
// Finally, verify that CH are actually sent (or not) on requests
|
||||
promise_test(t => {
|
||||
return new Promise(resolve => {
|
||||
let win;
|
||||
window.addEventListener('message', t.step_func(function(e) {
|
||||
win.close();
|
||||
assert_equals(e.data, "PASS", "message from opened page");
|
||||
fetch("/client-hints/resources/clear-site-data.html").then(resolve);
|
||||
}));
|
||||
// Open a new window. Verify that the user agent attaches client hints.
|
||||
win = window.open(test.expect_url);
|
||||
assert_not_equals(win, null, "Popup windows not allowed?");
|
||||
});
|
||||
}, test.name + " got client hints according to expectations.");
|
||||
};
|
||||
|
|
@ -6,6 +6,10 @@ and Accept-CH-Lifetime header. Fetching this webpage should cause
|
|||
user-agent to persist origin preferences for the client hints
|
||||
specified in the Accept-CH header for a duration specified in
|
||||
the Accept-CH-Lifetime header.-->
|
||||
<script>
|
||||
window.top.opener.postMessage('Loaded', '*');
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
Accept-CH: device-memory
|
||||
Accept-CH-Lifetime: 5
|
||||
Accept-CH-Lifetime: 1
|
||||
Access-Control-Allow-Origin: *
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Clear-Site-Data: "*"
|
|
@ -2,5 +2,8 @@
|
|||
<meta http-equiv="Accept-CH" content="device-memory">
|
||||
<meta http-equiv="Accept-CH-Lifetime" content="5">
|
||||
<body>
|
||||
<script>
|
||||
window.top.opener.postMessage('Loaded', '*');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Access-Control-Allow-Origin: *
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue