mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Update web-platform-tests to revision 556afc9ad1a27504be759fb9e62a266a1f653b09
This commit is contained in:
parent
c0d9ee0ce2
commit
bdf20e37ce
44 changed files with 559 additions and 204 deletions
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Deferred images with loading='lazy' use the latest crossorigin attribute</title>
|
||||
<link rel="author" title="Raj T" href="mailto:rajendrant@chromium.org">
|
||||
<link rel="author" title="Rob Buis" href="mailto:rbuis@igalia.com">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.js"></script>
|
||||
</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();
|
||||
});
|
||||
|
||||
async_test(function(t) {
|
||||
crossorigin_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"
|
||||
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();">
|
||||
</body>
|
|
@ -1,42 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Deferred images with loading='lazy' use the original crossorigin attribute specified at the parse time</title>
|
||||
<link rel="author" title="Raj T" href="mailto:rajendrant@chromium.org">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="common.js"></script>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
const crossorigin_img = new ElementLoadPromise("crossorigin_img");
|
||||
|
||||
// Set the crossorigin and scroll down to load the deferred image.
|
||||
window.addEventListener("load", () => {
|
||||
crossorigin_img.element().crossOrigin = 'anonymous';
|
||||
crossorigin_img.element().scrollIntoView();
|
||||
});
|
||||
|
||||
async_test(function(t) {
|
||||
crossorigin_img.promise.then(t.step_func_done(() => {
|
||||
// The image originally did not had crossOrigin property set, so CORS will
|
||||
// not be involved in fetching that. So drawing the image in a canvas will
|
||||
// make it tainted. Verify that the image did not load with CORS headers
|
||||
// due to the updated crossOrigin property.
|
||||
const img_element = crossorigin_img.element();
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d');
|
||||
canvas.width = img_element.width;
|
||||
canvas.height = img_element.height;
|
||||
context.drawImage(img_element, 0, 0);
|
||||
assert_throws_dom('SecurityError', () => canvas.toDataURL());
|
||||
})
|
||||
).catch(t.unreached_func("The image load should not fail, trying to load with CORS headers set."));
|
||||
}, "Test that when deferred image is loaded, it uses the crossorigin attribute specified at parse time.");
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<div style="height:10000px;"></div>
|
||||
<img id="crossorigin_img" loading="lazy"
|
||||
src='http://{{hosts[alt][www]}}:{{ports[http][0]}}/html/semantics/embedded-content/the-img-element/resources/image.png'
|
||||
onload="crossorigin_img.resolve();" onerror="crossorigin_img.reject();">
|
||||
</body>
|
Loading…
Add table
Add a link
Reference in a new issue