Update web-platform-tests to revision afb5f984d7beecafa3d68ea7719ae2f4d203f1e1

This commit is contained in:
WPT Sync Bot 2020-05-18 08:19:00 +00:00
parent 50bd5c3e0f
commit 4f13fd6595
92 changed files with 576 additions and 476 deletions

View file

@ -6,7 +6,7 @@
<link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>

View file

@ -1,45 +0,0 @@
// Helper to access the element, its associated loading promise, and also to
// resolve the promise.
class ElementLoadPromise {
constructor(element_id) {
this.element_id = element_id;
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve
this.reject = reject
});
}
element() {
return document.getElementById(this.element_id);
}
}
// Returns if the image is complete and the lazily loaded image matches the expected image.
function is_image_fully_loaded(image, expected_image) {
if (!image.complete || !expected_image.complete) {
return false;
}
if (image.width != expected_image.width ||
image.height != expected_image.height) {
return false;
}
let canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
let canvasContext = canvas.getContext("2d");
canvasContext.save();
canvasContext.drawImage(image, 0, 0);
let data = canvasContext.getImageData(0, 0, canvas.width, canvas.height).data;
canvasContext.restore();
canvasContext.drawImage(expected_image, 0, 0);
let expected_data = canvasContext.getImageData(0, 0, canvas.width, canvas.height).data;
for (var i = 0; i < data.length; i++) {
if (data[i] != expected_data[i]) {
return false;
}
}
return true;
}

View file

@ -1,42 +0,0 @@
<!DOCTYPE html>
<head>
<title>Iframes with loading='eager' load immediately regardless of their position with respect to the viewport.</title>
<link rel="author" title="Scott Little" href="mailto:sclittle@chromium.org">
<link rel="help" href="https://github.com/scott-little/lazyload">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
const t = async_test("Test that iframes with loading='eager' load immediately regardless of their position with respect to the viewport.");
let has_in_viewport_loaded = false;
const in_viewport_iframe_onload = t.step_func(function() {
assert_false(has_in_viewport_loaded, "The in_viewport element should load only once.");
has_in_viewport_loaded = true;
});
let has_below_viewport_loaded = false;
const below_viewport_iframe_onload = t.step_func(function() {
assert_false(has_below_viewport_loaded, "The below_viewport element should load only once.");
has_below_viewport_loaded = true;
});
window.addEventListener("load", t.step_func_done(function() {
assert_true(has_in_viewport_loaded, "The in_viewport element should have loaded before window.load().");
assert_true(has_below_viewport_loaded, "The below_viewport element should have loaded before window.load().");
}));
</script>
<body>
<iframe id="in_viewport" src="resources/subframe.html?first" loading="eager" width="200px" height="100px" onload="in_viewport_iframe_onload();">
</iframe>
<div style="height:10000px;"></div>
<!--
The below_viewport element loads very slowly in order to ensure that the
window load event is blocked on it.
-->
<iframe id="below_viewport" src="resources/subframe.html?pipe=trickle(d1)" loading="eager" width="200px" height="100px" onload="below_viewport_iframe_onload();">
</iframe>
</body>

View file

@ -1,48 +0,0 @@
<!DOCTYPE html>
<head>
<title>Iframes with loading='lazy' load when in the viewport</title>
<link rel="author" title="Scott Little" href="mailto:sclittle@chromium.org">
<link rel="help" href="https://github.com/scott-little/lazyload">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
const t = async_test("Test that iframes with loading='lazy' load once they enter the viewport.");
let has_window_loaded = false;
let has_in_viewport_loaded = false;
const in_viewport_iframe_onload = t.step_func(function() {
assert_false(has_in_viewport_loaded, "The in_viewport element should load only once.");
has_in_viewport_loaded = true;
});
window.addEventListener("load", t.step_func(function() {
assert_true(has_in_viewport_loaded, "The in_viewport element should have loaded before window.load().");
assert_false(has_window_loaded, "The window.load() event should only fire once.");
has_window_loaded = true;
document.getElementById("below_viewport").scrollIntoView();
}));
const below_viewport_iframe_onload = t.step_func_done(function() {
assert_true(has_window_loaded, "The window.load() event should have fired before below_viewport loaded.");
});
</script>
<body>
<iframe id="in_viewport" src="resources/subframe.html?first" loading="lazy" width="200px" height="100px" onload="in_viewport_iframe_onload();">
</iframe>
<div style="height:10000px;"></div>
<iframe id="below_viewport" src="resources/subframe.html?second" loading="lazy" width="200px" height="100px" onload="below_viewport_iframe_onload();">
</iframe>
<!--
This async script loads very slowly in order to ensure that, if the
below_viewport element has started loading, it has a chance to finish
loading before window.load() happens, so that the test will dependably fail
in that case instead of potentially passing depending on how long different
resource fetches take.
-->
<script async src="/common/slow.py"></script>
</body>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html>
<head>
<title>Images with loading='eager' load immediately regardless of their position with respect to the viewport</title>
<title>Images with loading='eager' load immediately regardless of their
position with respect to the viewport</title>
<link rel="author" title="Scott Little" href="mailto:sclittle@chromium.org">
<link rel="help" href="https://github.com/scott-little/lazyload">
<script src="/resources/testharness.js"></script>
@ -8,33 +9,39 @@
</head>
<script>
const t = async_test("Test that images with loading='eager' load immediately regardless of their position with respect to the viewport.");
const t = async_test("Test that images with loading='eager' load " +
"immediately regardless of their position with " +
"respect to the viewport.");
let has_in_viewport_loaded = false;
const in_viewport_img_onload = t.step_func(function() {
assert_false(has_in_viewport_loaded, "The in_viewport element should load only once.");
const in_viewport_img_onload = t.step_func(() => {
assert_false(has_in_viewport_loaded,
"The in_viewport element should load only once.");
has_in_viewport_loaded = true;
});
let has_below_viewport_loaded = false;
const below_viewport_img_onload = t.step_func(function() {
assert_false(has_below_viewport_loaded, "The below_viewport element should load only once.");
const below_viewport_img_onload = t.step_func(() => {
assert_false(has_below_viewport_loaded,
"The below_viewport element should load only once.");
has_below_viewport_loaded = true;
});
window.addEventListener("load", t.step_func_done(function() {
assert_true(has_in_viewport_loaded, "The in_viewport element should have loaded before window.load().");
assert_true(has_below_viewport_loaded, "The below_viewport element should have loaded before window.load().");
window.addEventListener("load", t.step_func_done(() => {
assert_true(has_in_viewport_loaded,
"The in_viewport element should have loaded before window.load().");
assert_true(has_below_viewport_loaded,
"The below_viewport element should have loaded before window.load().");
}));
</script>
<body>
<img id="in_viewport" src="resources/image.png?first" loading="eager" onload="in_viewport_img_onload();">
<img id="in_viewport" src="resources/image.png?in-viewport" loading="eager" onload="in_viewport_img_onload();">
<div style="height:10000px;"></div>
<!--
The below_viewport element loads very slowly in order to ensure that the
window load event is blocked on it.
-->
<img id="below_viewport" src="resources/image.png?pipe=trickle(d2)" loading="eager" onload="below_viewport_img_onload();">
<!-- The below_viewport element loads very slowly in order to ensure that the
window load event is blocked on it. -->
<img id="below_viewport"
src="resources/image.png?below-viewport&pipe=trickle(d2)"
loading="eager" onload="below_viewport_img_onload();">
</body>

View file

@ -0,0 +1,52 @@
<!DOCTYPE html>
<head>
<title>Deferred loading=lazy images load relative to the document's base URL
at parse-time</title>
<link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
<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="../resources/common.js"></script>
</head>
<script>
const below_viewport_img = new ElementLoadPromise("below-viewport");
let has_window_loaded = false;
async_test(t => {
// Change the document's base URL to a bogus one, and scroll the
// below-viewport img into view. When it loads, it should load relative
// to the old base URL computed at parse-time.
window.addEventListener("load", t.step_func(() => {
window.history.pushState(2, document.title,
'/invalid-url-where-no-subresources-exist/')
has_window_loaded = true;
below_viewport_img.element().scrollIntoView();
}));
below_viewport_img.promise.then(t.step_func_done(() => {
assert_true(has_window_loaded,
"Below-viewport loading=lazy images do not block the " +
"window load event");
}));
below_viewport_img.promise.catch(
t.unreached_func("The image request should not load relative to the " +
"current (incorrect) base URL.")
);
}, "When a loading=lazy image is loaded, it loads relative to the " +
"document's base URL computed at parse-time.");
</script>
<body>
<div style="height:1000vh;"></div>
<script>
// Change the document's base URL so that the img request parses relative
// to it when it sets up the request at parse-time.
window.history.pushState(1, document.title, 'resources/')
</script>
<img id="below-viewport" src="image.png" loading="lazy"
onload="below_viewport_img.resolve()"
onerror="below_viewport_img.reject()">
</body>

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<head>
<title>Deferred images with loading='lazy' use the original
base URL specified at parse-time</title>
<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="../resources/common.js"></script>
<base href='/html/semantics/embedded-content/the-img-element/resources/'>
</head>
<script>
const below_viewport_img = new ElementLoadPromise("below-viewport");
let has_window_loaded = false;
async_test(t => {
// At this point, the below-viewport image's request has been set-up, and
// its URL is the URL that was parsed relative to the document's base URL
// at this time. Any changes to the document's base URL from this point
// forward should not impact the image when we scroll it in-view. This is
// because the next step in the #updating-the-img-data algorithm is to to
// fetch the request that has already been set up. Now we'll change the
// document's base URL, and scroll the image in-view.
window.addEventListener("load", t.step_func(() => {
const base = document.querySelector('base');
base.href = '/invalid-url-where-no-subresources-exist/';
has_window_loaded = true;
below_viewport_img.element().scrollIntoView();
}));
below_viewport_img.promise.then(t.step_func_done(() => {
assert_true(has_window_loaded,
"Below-viewport loading=lazy images do not block the " +
"window load event");
}));
below_viewport_img.promise.catch(
t.unreached_func("The image request should not load relative to the " +
"current (incorrect) base URL.")
);
}, "When a loading=lazy image is loaded, it loads relative to the " +
"document's base URL computed at parse-time.");
</script>
<body>
<div style="height:1000vh"></div>
<img id="below-viewport" src="image.png" loading="lazy"
onload="below_viewport_img.resolve()"
onerror="below_viewport_img.reject()">
</body>

View file

@ -5,7 +5,7 @@
<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>
<script src="../resources/common.js"></script>
</head>
<script>

View file

@ -5,7 +5,7 @@
<link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>

View file

@ -7,7 +7,7 @@
<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>
<script src="../resources/common.js"></script>
</head>
<script>

View file

@ -6,7 +6,7 @@
<link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>

View file

@ -5,7 +5,7 @@
<link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>

View file

@ -1,51 +0,0 @@
<!DOCTYPE html>
<head>
<title>Deferred images with loading='lazy' use the original
base URL specified at the parse time</title>
<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>
<base href='/html/semantics/embedded-content/the-img-element/resources/'>
</head>
<script>
const below_viewport_img_promise = new ElementLoadPromise("below_viewport_img");
let has_window_loaded = false;
async_test(function(t) {
// Change the base URL and scroll down to load the deferred elements.
window.addEventListener("load", t.step_func(function() {
const base = document.getElementsByTagName('base')[0];
base.href = '/invalid-url-where-no-subresources-exist/';
has_window_loaded = true;
below_viewport_img_promise.element().scrollIntoView();
}));
below_viewport_img_promise.promise.then(
t.step_func_done(function() {
assert_true(has_window_loaded,
"Below-viewport loading=lazy images do not block the " +
"window load event");
assert_true(below_viewport_img_promise.element().complete,
"The loading=lazy image should be considered complete " +
"upon load.");
assert_greater_than(below_viewport_img_promise.element().naturalWidth,
0,
"The loading=lazy should have non-zero width " +
"upon loading");
})
).catch(t.unreached_func("The image request should not load relative to " +
"the current (incorrect) base URL."));
}, "Deferred images with loading='lazy' use the original base URL " +
"specified at the parse time");
</script>
<body>
<div style="height:1000vh"></div>
<img id="below_viewport_img" src="image.png" loading="lazy"
onload="below_viewport_img_promise.resolve();"
onerror="below_viewport_img_promise.reject();">
</body>

View file

@ -1,48 +0,0 @@
<!DOCTYPE html>
<head>
<title>Deferred iframes with loading='lazy' use the original
base URL specified at the parse time</title>
<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>
<base href='/html/semantics/embedded-content/the-img-element/resources/'>
</head>
<script>
const below_viewport_iframe_promise = new ElementLoadPromise("below_viewport_iframe");
let has_window_loaded = false;
async_test(function(t) {
// Change the base URL and scroll down to load the deferred elements.
window.addEventListener("load", t.step_func(function() {
const base = document.getElementsByTagName('base')[0];
base.href = '/invalid-url-where-no-subresources-exist/';
has_window_loaded = true;
below_viewport_iframe_promise.element().scrollIntoView();
}));
below_viewport_iframe_promise.promise.then(
t.step_func_done(function() {
assert_true(has_window_loaded,
"Below-viewport loading=lazy iframes do not block the " +
"window load event");
assert_true(below_viewport_iframe_promise.element().contentDocument.body.
innerHTML.includes("<p>Subframe</p>"),
"The loading=lazy iframe's content is accessible upon loading");
})
).catch(t.unreached_func("The iframe request should not load relative to " +
"the current (incorrect) base URL."));
}, "Deferred iframes with loading='lazy' use the original base URL " +
"specified at the parse time");
</script>
<body>
<div style="height:1000vh"></div>
<iframe id="below_viewport_iframe" src="subframe.html" loading="lazy"
width="200px" height="100px" onload="below_viewport_iframe_promise.resolve();"
onerror="below_viewport_iframe_promise.reject();">
</iframe>
</body>

View file

@ -1,48 +0,0 @@
<!DOCTYPE html>
<head>
<title>Deferred iframes and images with loading='lazy' use the original base URL 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 below_viewport_iframe = new ElementLoadPromise("below_viewport_iframe");
const below_viewport_img = new ElementLoadPromise("below_viewport_img");
// Change the base URL and scroll down to load the deferred elements.
window.addEventListener("load", () => {
window.history.pushState(1, document.title, '/invalid-url-where-no-subresources-exist/')
below_viewport_iframe.element().scrollIntoView();
});
async_test(function(t) {
below_viewport_iframe.promise.then(
t.step_func_done(function() {
assert_true(below_viewport_iframe.element().contentDocument.body.innerHTML.includes("<p>Subframe</p>"));
}));
}, "Test that when deferred iframe is loaded, it uses the base URL computed at parse time.");
async_test(function(t) {
below_viewport_img.promise.then(
t.step_func_done(function() {
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, trying to load with invalid base URL."));
}, "Test that when deferred img is loaded, it uses the base URL computed at parse time.");
</script>
<body>
<div style="height:10000px;"></div>
<script>
// Change the base URL so that the iframe makes use of that in its relative
// URL to absolute URL computation at parse time.
window.history.pushState(1, document.title, 'resources/')
</script>
<iframe id="below_viewport_iframe" src="subframe.html" loading="lazy" width="200px" height="100px" onload="below_viewport_iframe.resolve();">
</iframe>
<img id="below_viewport_img" src="image.png" loading="lazy" onload="below_viewport_img.resolve();"
onerror="below_viewport_img.reject();">
</body>

View file

@ -5,7 +5,7 @@
<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>
<script src="../resources/common.js"></script>
</head>
<script>

View file

@ -1,4 +0,0 @@
<!DOCTYPE html>
<body>
<p>Subframe</p>
</body>