mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update web-platform-tests to revision a49081e46a18e439defbd77d18cc5e261d68b215
This commit is contained in:
parent
aa9f16ce45
commit
fb0507d174
69 changed files with 1412 additions and 698 deletions
|
@ -9,22 +9,32 @@
|
|||
</head>
|
||||
|
||||
<script>
|
||||
const crossorigin_img = new ElementLoadPromise("crossorigin_img");
|
||||
|
||||
// Set the crossorigin attribute and scroll down to load the deferred image.
|
||||
window.addEventListener("load", () => {
|
||||
crossorigin_img.element().crossOrigin = 'anonymous';
|
||||
crossorigin_img.element().scrollIntoView();
|
||||
});
|
||||
const img = new ElementLoadPromise("cross-origin");
|
||||
|
||||
async_test(function(t) {
|
||||
crossorigin_img.promise.then(t.unreached_func("The image should not load.")).catch(t.step_func_done());
|
||||
window.addEventListener("load", t.step_func(() => {
|
||||
// At this point the image's #updating-the-image-data algorithm has been
|
||||
// invoked, and the image request has been deferred. The deferred
|
||||
// cross-origin image request was created with the `no-cors` request mode,
|
||||
// which would succeed to load the cross-origin image.
|
||||
// While the request is deferred, we'll set the `crossorigin` attribute to a
|
||||
// value that would cause the image request to fail. Since `crossorigin`
|
||||
// mutations trigger another #updating-the-image-data invocation (replacing
|
||||
// the first one), when we scroll the image into view, the image should be
|
||||
// fetched with the latest `crossorigin` attribute value, and fail to load.
|
||||
img.element().crossOrigin = 'anonymous';
|
||||
img.element().scrollIntoView();
|
||||
}));
|
||||
|
||||
img.promise
|
||||
.then(t.unreached_func("The image should not load."))
|
||||
.catch(t.step_func_done());
|
||||
}, "Test that when deferred image is loaded, it uses the latest crossorigin attribute.");
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<div style="height:1000vh;"></div>
|
||||
<img id="crossorigin_img" loading="lazy"
|
||||
<img id="cross-origin" loading="lazy"
|
||||
src='http://{{hosts[alt][]}}:{{ports[http][0]}}/html/semantics/embedded-content/the-img-element/resources/image.png'
|
||||
onload="crossorigin_img.resolve();" onerror="crossorigin_img.reject();">
|
||||
onload="img.resolve();" onerror="img.reject();">
|
||||
</body>
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Deferred loading=lazy images are fetched with the latest
|
||||
`referrerpolicy` attribute</title>
|
||||
<link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
|
||||
<link rel="author" title="Raj T" href="mailto:rajendrant@chromium.org">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.js"></script>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
const below_viewport_img = new ElementLoadPromise("below_viewport_img");
|
||||
|
||||
async_test(function(t) {
|
||||
// At this point the image's #updating-the-image-data algorithm has been
|
||||
// invoked, and the image request has been deferred. The deferred request
|
||||
// was created with the default referrer policy, which will result in a
|
||||
// `Referer` header being sent when the request is finally made. The request
|
||||
// is also for an image that the server will send a broken response for if
|
||||
// the request has a `Referer` header.
|
||||
// While the request is deferred, we'll set the `referrerpolicy` attribute
|
||||
// to `no-referrer`, which would cause the image request to succeed. Since
|
||||
// `referrerpolicy` mutations trigger another #updating-the-image-data
|
||||
// invocation (replacing the first one), when we scroll the image into view,
|
||||
// the image should be fetched with no `Referer` header, and succeed.
|
||||
window.addEventListener("load", t.step_func(() => {
|
||||
below_viewport_img.element().referrerPolicy = "no-referrer";
|
||||
below_viewport_img.element().scrollIntoView();
|
||||
}));
|
||||
|
||||
below_viewport_img.promise
|
||||
.then(t.step_func_done())
|
||||
.catch(t.unreached_func("The image request should successfully load"))
|
||||
}, "Test that when a deferred image is loaded, it uses the latest referrerpolicy");
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<div style="height:1000vh;"></div>
|
||||
<img id="below_viewport_img"
|
||||
src="resources/referrer-checker-img.py?expected_referrer="
|
||||
loading="lazy" referrerpolicy="unsafe-url"
|
||||
onload="below_viewport_img.resolve();"
|
||||
onerror="below_viewport_img.reject();">
|
||||
</body>
|
|
@ -1,51 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Deferred iframes and images with loading='lazy' use the original referrer-policy specified at the parse time</title>
|
||||
<link rel="author" title="Raj T" href="mailto:rajendrant@chromium.org">
|
||||
<link rel="help" href="https://github.com/scott-little/lazyload">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.js"></script>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
const below_viewport_iframe = new ElementLoadPromise("below_viewport_iframe");
|
||||
const below_viewport_img = new ElementLoadPromise("below_viewport_img");
|
||||
|
||||
// Change the referrer-policy and scroll down to load the deferred elements.
|
||||
window.addEventListener("load", () => {
|
||||
below_viewport_iframe.element().referrerPolicy = "no-referrer";
|
||||
below_viewport_img.element().referrerPolicy = "no-referrer";
|
||||
document.getElementById("below_viewport_iframe").scrollIntoView();
|
||||
});
|
||||
|
||||
async_test(function(t) {
|
||||
below_viewport_iframe.promise.then(
|
||||
t.step_func_done(function() {
|
||||
// The referer header should be the full URL (as specified in the iframe
|
||||
// at parse time), and not the origin (as specified in meta referrer
|
||||
// tag) or null (as overridden by iframe referrerpolicy=no-referrer).
|
||||
assert_true(below_viewport_iframe.element().contentDocument.body.innerHTML
|
||||
.includes("Referer: http://{{location[host]}}{{location[path]}}"));
|
||||
}));
|
||||
}, "Test that when deferred iframe is loaded, it uses the referrer-policy specified at parse time.");
|
||||
|
||||
async_test(function(t) {
|
||||
below_viewport_img.promise.then(
|
||||
t.step_func_done(function() {
|
||||
// The image will load successfully if the full URL is sent as referrer.
|
||||
assert_true(below_viewport_img.element().complete);
|
||||
assert_greater_than(below_viewport_img.element().naturalWidth, 0);
|
||||
})
|
||||
).catch(t.unreached_func("The image load should not fail, by sending the wrong referer header."));
|
||||
}, "Test that when deferred img is loaded, it uses the referrer-policy specified at parse time.");
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<meta name="referrer" content="origin">
|
||||
<div style="height:10000px;"></div>
|
||||
<iframe id="below_viewport_iframe" src="/xhr/resources/echo-headers.py" loading="lazy" width="200px" height="100px" referrerpolicy="unsafe-url" onload="below_viewport_iframe.resolve();">
|
||||
</iframe>
|
||||
<img id="below_viewport_img" src="resources/referrer-checker-img.py?expected_referrer=http://{{location[host]}}{{location[path]}}"
|
||||
loading="lazy" referrerpolicy="unsafe-url" onload="below_viewport_img.resolve();" onerror="below_viewport_img.reject();">
|
||||
</body>
|
Loading…
Add table
Add a link
Reference in a new issue