Update web-platform-tests to revision 1268bd5901289acc95b1a576f108bdf382d82e44

This commit is contained in:
WPT Sync Bot 2019-12-19 08:23:25 +00:00
parent f183d66217
commit 292a12e545
261 changed files with 5513 additions and 966 deletions

View file

@ -1,11 +1,11 @@
<!DOCTYPE html>
<head>
<title>Images with loading='lazy' load when in the viewport</title>
<title>Images with loading='lazy' load only when in the viewport</title>
<link rel="author" title="Scott Little" href="mailto:sclittle@chromium.org">
<link rel="author" title="Dom Farolino" href="mailto:dom@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>
<!--
@ -13,43 +13,40 @@ Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed.
-->
<script>
const t = async_test("Test that images with loading='lazy' load once they enter the viewport.");
const t = async_test("Images with loading='lazy' load only when in the viewport");
let has_in_viewport_loaded = false;
let has_window_loaded = false;
let has_window_load_fired = 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;
assert_true(document.getElementById("in_viewport").complete);
document.getElementById("below_viewport").scrollIntoView();
});
window.addEventListener("load", t.step_func(function() {
assert_true(has_in_viewport_loaded, "The in_viewport element should have loaded before window.load().");
assert_true(document.getElementById("in_viewport").complete);
assert_false(has_window_loaded, "The window.load() event should only fire once.");
has_window_loaded = true;
document.getElementById("below_viewport").scrollIntoView();
window.addEventListener("load", t.step_func(() => {
has_window_load_fired = true;
}));
const below_viewport_img_onload = t.step_func_done(function() {
assert_true(is_image_fully_loaded(
document.getElementById("below_viewport"),
document.getElementById("in_viewport")));
assert_true(has_window_loaded, "The window.load() event should have fired before below_viewport loaded.");
const below_viewport_img_onload = t.step_func_done(() => {
assert_true(has_in_viewport_loaded,
"The below-viewport image should not load until it has been " +
"scrolled into viewport, after the in-viewport image loads");
assert_true(has_window_load_fired,
"Below-viewport loading=lazy images should not block the " +
"window load event from firing");
});
</script>
<body>
<img id="in_viewport" src="resources/image.png?first" loading="lazy" onload="in_viewport_img_onload();">
<div style="height:10000px;"></div>
<img id="below_viewport" src="resources/image.png?second" loading="lazy" onload="below_viewport_img_onload();">
<!--
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>
<!-- |in_viewport| takes 2 seconds to load, so that in browsers that don't
support lazy loading, |below_viewport| finishes before |in_viewport|, and
the test will dependably fail without relying on a timeout. -->
<img id="in_viewport" loading="lazy" src="resources/image.png?first&pipe=trickle(d2)"
onload="in_viewport_img_onload();">
<div style="height:1000vh;"></div>
<img id="below_viewport" loading="lazy" src="resources/image.png?second"
onload="below_viewport_img_onload();">
</body>