mirror of
https://github.com/servo/servo.git
synced 2025-09-05 04:28:22 +01:00
Update web-platform-tests to revision 60220357131c65146444da1f54624d5b54d0975d
This commit is contained in:
parent
c45192614c
commit
775b784f79
2144 changed files with 58115 additions and 29658 deletions
|
@ -4,10 +4,10 @@
|
|||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id=test>
|
||||
<p>Apart from this webpage, the test opens another html web page. One test
|
||||
is run in this web page, and another in the second web page.
|
||||
</div>
|
||||
<!--
|
||||
Apart from this webpage, the test opens two more html web page. One test is run
|
||||
in this web page, and two in the other web pages.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
|
@ -23,11 +23,11 @@
|
|||
// verifies that the user agent does not send the client hints in the request
|
||||
// headers.
|
||||
|
||||
// Verify the initial state to make sure that the browser does not have client
|
||||
// hints preferences cached from a previous run of the 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("echo_client_hints_received.py").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
|
@ -35,25 +35,33 @@ promise_test(t => {
|
|||
// headers when fetching echo_client_hints_received.py.
|
||||
assert_false(r.headers.has("device-memory-received"), "device-memory-received");
|
||||
});
|
||||
}, "Test that the browser does not have client hints preferences cached");
|
||||
|
||||
promise_test(t => {
|
||||
return fetch("resources/accept_ch.html").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
assert_false(r.headers.has("device-memory-received"), "device-memory-received");
|
||||
|
||||
// Open a new window.
|
||||
window.open("resources/do_not_expect_client_hints_headers.html");
|
||||
});
|
||||
}, "Test receiving Accept-CH header");
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(event) {
|
||||
t.done();
|
||||
})
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");
|
||||
|
||||
</script>
|
||||
function acceptChLoaded() {
|
||||
// Open a new window. Verify that the user agent does not attach the client
|
||||
// hints.
|
||||
var verify_win = window.open("do_not_expect_client_hints_headers.html");
|
||||
assert_not_equals(verify_win, null, "Popup windows not allowed?");
|
||||
}
|
||||
|
||||
// Fetching this webpage should NOT cause user-agent to persist client hint
|
||||
// preferences for the origin.
|
||||
var win = window.open("resources/accept_ch.html");
|
||||
assert_not_equals(win, null, "Popup windows not allowed?");
|
||||
win.addEventListener('load', acceptChLoaded, false);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// 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", {"mode": "no-cors"}).then(r => {
|
||||
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.
|
|
@ -4,10 +4,10 @@
|
|||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id=test>
|
||||
<p>Apart from this webpage, the test opens another html web page. One test
|
||||
is run in this web page, and another in the second web page.
|
||||
</div>
|
||||
<!--
|
||||
Apart from this webpage, the test opens two more html web page. One test is run
|
||||
in this web page, and two in the other web pages.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
|
@ -23,11 +23,11 @@
|
|||
// verifies that the user agent actually sends the client hints in the request
|
||||
// headers.
|
||||
|
||||
// Verify the initial state to make sure that the browser does not have client
|
||||
// hints preferences cached from a previous run of the 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("echo_client_hints_received.py").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
|
@ -35,26 +35,33 @@ promise_test(t => {
|
|||
// headers when fetching echo_client_hints_received.py.
|
||||
assert_false(r.headers.has("device-memory-received"), "device-memory-received");
|
||||
});
|
||||
}, "Test that the browser does not have client hints preferences cached");
|
||||
|
||||
promise_test(t => {
|
||||
return fetch("resources/accept_ch_lifetime.html").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
assert_false(r.headers.has("device-memory-received"), "device-memory-received");
|
||||
|
||||
// Open a new window.
|
||||
window.open("resources/expect_client_hints_headers.html");
|
||||
});
|
||||
}, "Test receiving Accept-CH-Lifetime header");
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(event) {
|
||||
t.done();
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/expect_client_hints_headers.html did not finish.");
|
||||
|
||||
|
||||
</script>
|
||||
function acceptChLifetimeLoaded() {
|
||||
// Open a new window. Verify that the user agent attaches the client hints.
|
||||
var verify_win = window.open("expect_client_hints_headers.html");
|
||||
assert_not_equals(verify_win, null, "Popup windows not allowed?");
|
||||
}
|
||||
|
||||
// Fetching this webpage should cause user-agent to persist client hint
|
||||
// preferences for the origin.
|
||||
var win = window.open("resources/accept_ch_lifetime.html");
|
||||
assert_not_equals(win, null, "Popup windows not allowed?");
|
||||
win.addEventListener('load', acceptChLifetimeLoaded, false);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<html>
|
||||
<title>Accept-CH-Lifetime test with cross-origin iframe</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<!--
|
||||
Apart from this webpage, the test opens another html web page. One test is run
|
||||
in this web page, and another in the second web page.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
// This test fetches resources/accept_ch_lifetime.html in a cross origin iframe.
|
||||
// The response headers to that webpage contain Accept-CH and Accept-CH-Lifetime
|
||||
// headers.
|
||||
|
||||
// Fetching that webpage should NOT cause the user-agent to persist origin
|
||||
// preferences for the client hints specified.
|
||||
|
||||
// Next, to verify if the origin preferences were NOT persisted by the user
|
||||
// agent, this test fetches resources/do_not_expect_client_hints_headers.html
|
||||
// in a new window. Fetching of
|
||||
// resources/do_not_expect_client_hints_headers.html
|
||||
// verifies that the user agent did not actually sent the client hints in the
|
||||
// request headers.
|
||||
|
||||
// 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("echo_client_hints_received.py").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");
|
||||
});
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");
|
||||
|
||||
function acceptChLifetimeLoaded() {
|
||||
// Open a new window. Verify that the user agent does not attach the client
|
||||
// hints.
|
||||
var verify_win = window.open("resources/do_not_expect_client_hints_headers.html");
|
||||
assert_not_equals(verify_win, null, "Popup windows not allowed?");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Fetching this webpage should NOT cause user-agent to persist client hint
|
||||
preferences for the origin.-->
|
||||
<iframe onload="acceptChLifetimeLoaded()" src="https://{{hosts[][www]}}:{{ports[https][0]}}/client-hints/resources/accept_ch_lifetime.html"></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,67 @@
|
|||
<html>
|
||||
<title>Accept-CH-Lifetime test with same-origin iframe</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<!--
|
||||
Apart from this webpage, the test opens another html web page. One test is run
|
||||
in this web page, and another in the second web page.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
// This test fetches resources/accept_ch_lifetime.html in a same origin iframe.
|
||||
// The response headers to that webpage contain Accept-CH and Accept-CH-Lifetime
|
||||
// headers.
|
||||
|
||||
// Fetching that webpage should cause the user-agent to persist origin
|
||||
// preferences for the client hints specified in Accept-CH header for a
|
||||
// duration specified in the Accept-CH-Lifetime header.
|
||||
|
||||
// Next, to verify if the origin preferences were persisted by the user
|
||||
// agent, this test fetches resources/expect_client_hints_headers.html
|
||||
// in a new window. Fetching of resources/expect_client_hints_headers.html
|
||||
// verifies that the user agent actually sends the client hints in the request
|
||||
// headers.
|
||||
|
||||
// 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("echo_client_hints_received.py").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");
|
||||
});
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/expect_client_hints_headers.html did not finish.");
|
||||
|
||||
function acceptChLifetimeLoaded() {
|
||||
// Open a new window. Verify that the user agent attaches the client hints.
|
||||
var verify_win = window.open("resources/expect_client_hints_headers.html");
|
||||
assert_not_equals(verify_win, null, "Popup windows not allowed?");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Fetching this webpage should cause user-agent to persist client hint
|
||||
preferences for the origin.-->
|
||||
<iframe onload="acceptChLifetimeLoaded()" src="resources/accept_ch_lifetime.html"></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,71 @@
|
|||
<html>
|
||||
<title>Accept-CH-Lifetime test with subresource</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<!--
|
||||
Apart from this webpage, the test opens another html web page. One test is run
|
||||
in this web page, and another in the second web page.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
// This test fetches resources/accept_ch_lifetime.html as a subresource. The
|
||||
// response headers to that webpage contain Accept-CH and Accept-CH-Lifetime
|
||||
// headers.
|
||||
|
||||
// Fetching that webpage as a subresource should NOT cause the user-agent to
|
||||
// persist origin preferences for the client hints specified in Accept-CH
|
||||
// header.
|
||||
|
||||
// Next, to verify if the origin preferences were not persisted by the user
|
||||
// agent, this test fetches resources/do_not_expect_client_hints_headers.html
|
||||
// in a new window. Fetching of
|
||||
// resources/do_not_expect_client_hints_headers.html verifies that the user
|
||||
// agent does not send the client hints in the request headers.
|
||||
|
||||
// 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("echo_client_hints_received.py").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");
|
||||
});
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
promise_test(t => {
|
||||
// Fetching this web page as a subresource should NOT cause user-agent to
|
||||
// persist client hint preferences for the origin.
|
||||
return fetch("resources/accept_ch_lifetime.html").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
// Verify that the browser did not include client hints in the request
|
||||
// headers.
|
||||
assert_false(r.headers.has("device-memory-received"), "device-memory-received");
|
||||
// Open a new window. Verify that the user agent does not attach the client
|
||||
// hints.
|
||||
var win = window.open("resources/do_not_expect_client_hints_headers.html");
|
||||
assert_not_equals(win, null, "Popup windows not allowed?");
|
||||
});
|
||||
}, "Test receiving Accept-CH-Lifetime header");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,35 @@
|
|||
<html>
|
||||
<meta http-equiv="Accept-CH" content="DPR, Width, Viewport-Width, Device-Memory, rtt, downlink, ect">
|
||||
<title>Accept-CH http-equiv insecure transport test</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// Even though this HTML file contains "Accept-CH" http-equiv headers, the
|
||||
// browser should NOT attach the specified client hints in the HTTP request
|
||||
// headers since the page is being fetched over an insecure transport.
|
||||
// Test this functionality by fetching an XHR from this page hosted on
|
||||
// an insecure HTTP server.
|
||||
|
||||
// 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("/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
|
||||
// when fetching the XHR from an insecure HTTP server.
|
||||
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");
|
||||
});
|
||||
}, "Accept-CH http-equiv test over insecure transport");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,49 @@
|
|||
<html>
|
||||
<meta http-equiv="Accept-CH" content="DPR, Width, Viewport-Width, Device-Memory, rtt, downlink, ect">
|
||||
<title>Accept-CH http-equiv cross-navigation test</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<div id=test>
|
||||
<p>Apart from this webpage, the test opens another html web page. One test
|
||||
is run in this web page, and another in the second web page.
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
// This test contains accept-ch http-equiv header. Due to the missing
|
||||
// Accept-CH-Lifetime header, the user-agent should not persist origin
|
||||
// preferences for the client hints specified in Accept-CH header.
|
||||
|
||||
// Next, to verify that the origin preferences were not persisted by the user
|
||||
// agent, this test fetches resources/do_not_expect_client_hints_headers.html
|
||||
// in a new window. Fetching of
|
||||
// resources/do_not_expect_client_hints_headers.html
|
||||
// verifies that the user agent does not send the client hints in the request
|
||||
// headers.
|
||||
|
||||
// Test is marked as tentative until https://github.com/whatwg/fetch/issues/726
|
||||
// is resolved.
|
||||
promise_test(t => {
|
||||
return fetch("echo_client_hints_received.py").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
// Verify that the browser includes client hints in the request
|
||||
// headers when fetching echo_client_hints_received.py within this page.
|
||||
assert_true(r.headers.has("device-memory-received"), "device-memory-received");
|
||||
});
|
||||
}, "Test that the browser attaches client hints on subresources in the same navigation");
|
||||
|
||||
// Verify that the browser does not attach client hints on resources in a
|
||||
// different navigation. This verifies that the client hint preferences were
|
||||
// not persisted for the origin.
|
||||
window.open("resources/do_not_expect_client_hints_headers.html");
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(event) {
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,62 @@
|
|||
<html>
|
||||
<meta http-equiv="Accept-CH" content="DPR, Width, Viewport-Width, Device-Memory, rtt, downlink, ect">
|
||||
<title>Accept-CH http-equiv same-origin and cross-origin test</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// Since this HTML file contains "Accept-CH" http-equiv headers 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.
|
||||
//
|
||||
// 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');
|
||||
});
|
||||
}, "Same origin Accept-CH http-equiv 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 http-equiv test");
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,66 @@
|
|||
<html>
|
||||
<title>Accept-CH-Lifetime test</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<!--
|
||||
Apart from this webpage, the test opens two more html web page. One test is run
|
||||
in this web page, and two in the other web pages.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
// This test fetches resources/http_equiv_accept_ch_lifetime.html. The response
|
||||
// to that webpage contains Accept-CH and Accept-CH-Lifetime http-equiv headers.
|
||||
// Fetching that webpage should cause the user-agent to persist origin
|
||||
// preferences for the client hints specified in Accept-CH header for a
|
||||
// duration specified in the Accept-CH-Lifetime header.
|
||||
|
||||
// Next, to verify if the origin preferences were persisted by the user
|
||||
// agent, this test fetches resources/expect_client_hints_headers.html
|
||||
// in a new window. Fetching of resources/expect_client_hints_headers.html
|
||||
// verifies that the user agent actually sends the client hints in the request
|
||||
// headers.
|
||||
|
||||
// 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("echo_client_hints_received.py").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");
|
||||
});
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/expect_client_hints_headers.html did not finish.");
|
||||
|
||||
function acceptChLifetimeLoaded() {
|
||||
// Open a new window. Verify that the user agent attaches the client hints.
|
||||
var verify_win = window.open("expect_client_hints_headers.html");
|
||||
assert_not_equals(verify_win, null, "Popup windows not allowed?");
|
||||
}
|
||||
|
||||
// Fetching this webpage should cause user-agent to persist client hint
|
||||
// preferences for the origin.
|
||||
var win = window.open("resources/http_equiv_accept_ch_lifetime.html");
|
||||
assert_not_equals(win, null, "Popup windows not allowed?");
|
||||
win.addEventListener('load', acceptChLifetimeLoaded, false);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,66 @@
|
|||
<html>
|
||||
<title>Accept-CH-Lifetime test with cross-origin iframe</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<!--
|
||||
Apart from this webpage, the test opens another html web page. One test is run
|
||||
in this web page, and another in the second web page.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
// This test fetches resources/http_equiv_accept_ch_lifetime.html in a cross
|
||||
// origin iframe. The response to that webpage contains Accept-CH and
|
||||
// Accept-CH-Lifetime http-equiv headers.
|
||||
|
||||
// Fetching that webpage should NOT cause the user-agent to persist origin
|
||||
// preferences for the client hints specified.
|
||||
|
||||
// Next, to verify if the origin preferences were NOT persisted by the user
|
||||
// agent, this test fetches resources/do_not_expect_client_hints_headers.html
|
||||
// in a new window. Fetching of
|
||||
// resources/do_not_expect_client_hints_headers.html
|
||||
// verifies that the user agent did not actually sent the client hints in the
|
||||
// request headers.
|
||||
|
||||
// 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("echo_client_hints_received.py").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");
|
||||
});
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");
|
||||
|
||||
function acceptChLifetimeLoaded() {
|
||||
var verify_win = window.open("resources/do_not_expect_client_hints_headers.html");
|
||||
assert_not_equals(verify_win, null, "Popup windows not allowed?");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Fetching this webpage should NOT cause user-agent to persist client hint
|
||||
preferences for the origin.-->
|
||||
<iframe onload="acceptChLifetimeLoaded()" src="https://{{hosts[][www]}}:{{ports[https][0]}}/client-hints/resources/http_equiv_accept_ch_lifetime.html"></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,67 @@
|
|||
<html>
|
||||
<title>Accept-CH-Lifetime test with same-origin iframe</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<!--
|
||||
Apart from this webpage, the test opens another html web page. One test is run
|
||||
in this web page, and another in the second web page.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
// This test fetches resources/http_equiv_accept_ch_lifetime.html in a same
|
||||
// origin iframe. The response to that webpage contains Accept-CH and
|
||||
// Accept-CH-Lifetime http-equiv headers.
|
||||
|
||||
// Fetching that webpage should cause the user-agent to persist origin
|
||||
// preferences for the client hints specified in Accept-CH header for a
|
||||
// duration specified in the Accept-CH-Lifetime header.
|
||||
|
||||
// Next, to verify if the origin preferences were persisted by the user
|
||||
// agent, this test fetches resources/expect_client_hints_headers.html
|
||||
// in a new window. Fetching of resources/expect_client_hints_headers.html
|
||||
// verifies that the user agent actually sends the client hints in the request
|
||||
// headers.
|
||||
|
||||
// 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("echo_client_hints_received.py").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");
|
||||
});
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/expect_client_hints_headers.html did not finish.");
|
||||
|
||||
function acceptChLifetimeLoaded() {
|
||||
// Open a new window. Verify that the user agent attaches the client hints.
|
||||
var verify_win = window.open("resources/expect_client_hints_headers.html");
|
||||
assert_not_equals(verify_win, null, "Popup windows not allowed?");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Fetching this webpage should cause user-agent to persist client hint
|
||||
preferences for the origin.-->
|
||||
<iframe onload="acceptChLifetimeLoaded()" src="resources/http_equiv_accept_ch_lifetime.html"></iframe>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,74 @@
|
|||
<html>
|
||||
<title>Accept-CH-Lifetime test with subresource</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<!--
|
||||
Apart from this webpage, the test opens another html web page. One test is run
|
||||
in this web page, and another in the second web page.
|
||||
-->
|
||||
|
||||
<script>
|
||||
|
||||
// This test fetches resources/http_equiv_accept_ch_lifetime.html as a
|
||||
// subresource. The response to that webpage contains Accept-CH and
|
||||
// Accept-CH-Lifetime http-equiv headers.
|
||||
|
||||
// Fetching that webpage as a subresource should NOT cause the user-agent to
|
||||
// persist origin preferences for the client hints specified in Accept-CH
|
||||
// header.
|
||||
|
||||
// Next, to verify if the origin preferences were not persisted by the user
|
||||
// agent, this test fetches resources/do_not_expect_client_hints_headers.html
|
||||
// in a new window. Fetching of
|
||||
// resources/do_not_expect_client_hints_headers.html verifies that the user
|
||||
// agent does not send the client hints in the request headers.
|
||||
|
||||
// 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("echo_client_hints_received.py").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");
|
||||
});
|
||||
}, "Precondition: Test that the browser does not have client hints preferences cached");
|
||||
|
||||
promise_test(t => {
|
||||
// Fetching this web page as a subresource should NOT cause user-agent to
|
||||
// persist client hint preferences for the origin.
|
||||
return fetch("resources/http_equiv_accept_ch_lifetime.html").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
// Verify that the browser did not include client hints in the request
|
||||
// headers.
|
||||
assert_false(r.headers.has("device-memory-received"), "device-memory-received");
|
||||
|
||||
// Open a new window. Verify that the user agent does not attach the client
|
||||
// hints.
|
||||
var win = window.open("resources/do_not_expect_client_hints_headers.html");
|
||||
assert_not_equals(win, null, "Popup windows not allowed?");
|
||||
|
||||
});
|
||||
}, "Test receiving Accept-CH-Lifetime header");
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('message', function(e) {
|
||||
if(!e.source.location.pathname.includes("do_not_expect_client_hints_headers.html")) {
|
||||
return;
|
||||
}
|
||||
if(typeof e.data != "string")
|
||||
return;
|
||||
assert_equals(e.data, "PASS");
|
||||
t.done();
|
||||
})
|
||||
}, "Loading of resources/do_not_expect_client_hints_headers.html did not finish.");
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
<html>
|
||||
<meta http-equiv="Accept-CH" content="DPR Width">
|
||||
<title>Accept-CH malformed http-equiv test</title>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
promise_test(t => {
|
||||
return fetch("/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
|
||||
// since Accept-CH value in http-equiv is malformed (includes whitespace
|
||||
// between attributes instead of comma).
|
||||
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");
|
||||
});
|
||||
}, "Accept-CH malformed http-equiv test");
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,2 +1,2 @@
|
|||
Accept-CH: device-memory
|
||||
Accept-CH-Lifetime: 20
|
||||
Accept-CH-Lifetime: 5
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// This test checks if browser attaches the device-memory client hint in the
|
||||
|
@ -11,18 +8,15 @@
|
|||
// 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("../echo_client_hints_received.py").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");
|
||||
fetch("../echo_client_hints_received.py").then(r => {
|
||||
if(r.status == 200 && !r.headers.has("device-memory-received")) {
|
||||
window.top.opener.postMessage('PASS', '*');
|
||||
});
|
||||
}, "Test if device-memory header was not sent by the browser");
|
||||
|
||||
}
|
||||
else {
|
||||
window.top.opener.postMessage('FAIL', '*');
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// This test checks if browser attaches the device-memory client hint in the
|
||||
|
@ -11,18 +8,15 @@
|
|||
// 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("../echo_client_hints_received.py").then(r => {
|
||||
assert_equals(r.status, 200)
|
||||
// Verify that the browser included client hints in the request headers when
|
||||
// fetching echo_client_hints_received.py.
|
||||
assert_true(r.headers.has("device-memory-received"), "device-memory-received");
|
||||
fetch("../echo_client_hints_received.py").then(r => {
|
||||
if(r.status == 200 && r.headers.has("device-memory-received")) {
|
||||
window.top.opener.postMessage('PASS', '*');
|
||||
});
|
||||
}, "Test if device-memory header was sent by the browser");
|
||||
|
||||
}
|
||||
else {
|
||||
window.top.opener.postMessage('FAIL', '*');
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<html>
|
||||
<meta http-equiv="Accept-CH" content="device-memory">
|
||||
<meta http-equiv="Accept-CH-Lifetime" content="5">
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue