Undelete lazyload feature policy test
Once test file got removed in https://crrev.com/c/2166638/
This CL adds the test back
TBR=sclittle@chromium.org
Bug: 1074608
Change-Id: I2fca32d1e06c75c9be278838d6abd981578c2515
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2169012
Commit-Queue: rajendrant <rajendrant@chromium.org>
Reviewed-by: rajendrant <rajendrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763389}
diff --git a/feature-policy/experimental-features/lazyload/lazyload-image-loading-lazy-tentative.sub.html b/feature-policy/experimental-features/lazyload/lazyload-image-loading-lazy-tentative.sub.html
new file mode 100644
index 0000000..8f1ef19
--- /dev/null
+++ b/feature-policy/experimental-features/lazyload/lazyload-image-loading-lazy-tentative.sub.html
@@ -0,0 +1,49 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Verify behavior of 'loading' attribute state 'LAZY' (sanity-check for lazyload policy tests).
+</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 loading="lazy" src="http://{{hosts[alt][www1]}}:{{ports[http][0]}}/feature-policy/experimental-features/resources/lazyload.png"/>
+ </div>
+ <script>
+ var img = document.querySelector("img");
+
+ [img, window].forEach((target) => {
+ target.did_load = false;
+ target.load_complete = wait_for_load(target).then(() => target.did_load = true );
+ });
+
+ // Verify that when feature-policy 'lazyload' is enabled, the loading
+ // attribute value 'LAZY' works as expected (images load only when scrolled
+ // down).
+ promise_test( async(t) => {
+ await window.load_complete;
+ assert_false(img.did_load, "Out-of-viewport image should not have loaded.");
+ img.scrollIntoView();
+ await img.load_complete;
+ }, "Verify 'loading' attribute state 'lazy' works as expected: image loads only when in " +
+ "viewport.");
+ </script>
+</body>