Update web-platform-tests to revision 3f3849c5d05f9350fad0b06d3bb3ae30d7e18d14

This commit is contained in:
WPT Sync Bot 2019-07-24 10:23:41 +00:00
parent 9a7e2663e8
commit f767403c00
310 changed files with 8134 additions and 895 deletions

View file

@ -0,0 +1,13 @@
// 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 => {
this.resolve = resolve
});
}
element() {
return document.getElementById(this.element_id);
}
}

View file

@ -0,0 +1,40 @@
<!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>
<!--
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed.
-->
<script>
const below_viewport_iframe = new ElementLoadPromise("below_viewport_iframe");
// 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.");
</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>
</body>

View file

@ -0,0 +1,41 @@
<!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>
<!--
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed.
-->
<script>
const below_viewport_iframe = new ElementLoadPromise("below_viewport_iframe");
// Change the referrer-policy and scroll down to load the deferred elements.
window.addEventListener("load", () => {
below_viewport_iframe.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://{{host}}:{{ports[http][0]}}/loading/lazyload/"));
}));
}, "Test that when deferred iframe 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>
</body>

View file

@ -0,0 +1,68 @@
<!DOCTYPE html>
<head>
<title>Images with loading='lazy' in picture elements load when near the viewport</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>
<!--
Marked as tentative until https://github.com/whatwg/html/pull/3752 is landed.
-->
<script>
const in_viewport_img = new ElementLoadPromise("in_viewport_img");
const lazy_attribute_img = new ElementLoadPromise("lazy_attribute_img");
const eager_attribute_img = new ElementLoadPromise("eager_attribute_img");
const document_load_promise = new Promise(resolve => {
window.addEventListener("load", resolve);
});
async_test(function(t) {
document_load_promise.then(t.step_func_done(function() {
assert_false(lazy_attribute_img.element().complete);
lazy_attribute_img.element().scrollIntoView();
}));
}, "Test that the loading=lazy <picture> element below viewport was deferred, on document load.");
async_test(function(t) {
in_viewport_img.promise.then(t.step_func_done());
}, "Test that in viewport <picture> element was loaded");
async_test(function(t) {
eager_attribute_img.promise.then(t.step_func_done());
}, "Test that eager <picture> element was loaded");
async_test(function(t) {
lazy_attribute_img.promise.then(t.step_func_done());
}, "Test that deferred <picture> element was loaded-in as well, after scrolled down");
</script>
<body>
<picture>
<source sizes='50vw' srcset='resources/image.png?in_viewport_img'>
<img id='in_viewport_img' src='img-not-loaded.png' loading="lazy" onload="in_viewport_img.resolve();">
</picture>
<div style="height:10000px;"></div>
<picture>
<source sizes='50vw' srcset='resources/image.png?lazy_attribute_img'>
<img id='lazy_attribute_img' src='img-not-loaded.png' loading="lazy" onload="lazy_attribute_img.resolve();">
</picture>
<picture>
<source sizes='50vw' srcset='resources/image.png?eager_attribute_img'>
<img id='eager_attribute_img' src='img-not-loaded.png' loading="eager" onload="eager_attribute_img.resolve();">
</picture>
<!--
This async script loads very slowly in order to ensure that, if the
below_viewport image 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>