servo/tests/wpt/web-platform-tests/feature-policy/experimental-features/lazyload/lazyload-enabled-image-tentative.sub.html

45 lines
1.3 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>Verify behavior of 'lazyload' attribute state 'OFF' when the feature policy 'lazyload' is
enabled.
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/experimental-features/resources/common.js"></script>
<style>
body {
width: 100%;
height: 100%;
}
img {
width: 200px;
height: 200px;
border: solid 1px black;
}
#image-container {
position: absolute;
top: 10000px;
}
</style>
<body>
<p>Image inserted further below.</p>
<div id="image-container">
<img id="off" loading="eager" src="http://{{hosts[alt][www1]}}:{{ports[http][0]}}/feature-policy/experimental-features/resources/lazyload.png"></img>
</div>
<script>
var img = document.querySelector("img");
[img, window].forEach((target) => {
target.load_complete = wait_for_load(target).then(() => target.did_load = true );
});
// Sanity-check: Verify that when feature-policy 'lazyload' is enabled, the attribute
// loading='eager' works as expected (images load immediately).
promise_test( async(t) => {
await window.load_complete;
assert_true(img.did_load, "Image should have loaded.");
}, "When feature is enabled, loading=eager works as expected.");
</script>
</body>