Commit 9e26712b authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

LazyLoad: Timeout when moving image elements between documents

This CL adds WPT test for moving image elements between documents
as well as removing image elements.

Bug: 10019689
Change-Id: I725b60bfaf2406d7fdeabe8d4422d0618dc29478
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1967084Reviewed-by: default avatarDominic Farolino <dom@chromium.org>
Commit-Queue: Rob Buis <rbuis@igalia.com>
Cr-Commit-Position: refs/heads/master@{#727350}
parent 06d59a33
main frame - DidStartNavigation
main frame - ReadyToCommitNavigation
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Images with loading='lazy' load being moved to another document and then scrolled to
frame "<!--framePath //<!--frame0-->-->" - didReceiveTitle:
frame "<!--framePath //<!--frame0-->-->" - BeginNavigation request to 'about:srcdoc', http method GET
frame "<!--framePath //<!--frame0-->-->" - DidStartNavigation
main frame - didFinishDocumentLoadForFrame
frame "<!--framePath //<!--frame0-->-->" - ReadyToCommitNavigation
frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame
frame "<!--framePath //<!--frame0-->-->" - didReceiveTitle:
frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame
frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame
frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
This is a testharness.js-based test.
FAIL Test that <img> below viewport is not loaded when moved to another document and then scrolled to assert_unreached: The below viewport image should not load Reached unreachable code
Harness: the test ran to completion.
<!DOCTYPE html>
<head>
<title>Images with loading='lazy' load being moved to another document
and then scrolled to</title>
<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.
-->
<body>
<div id="tall_div" style="height:1000vh"></div>
<div id="below_viewport_div"></div>
<img id="below_viewport" src='resources/image.png?below_viewport' loading="lazy">
<script>
const tall_div = document.getElementById("tall_div");
const below_viewport_element = document.getElementById("below_viewport");
const below_viewport_div = document.getElementById("below_viewport_div");
async_test(function(t) {
below_viewport_element.onload =
t.unreached_func("The below viewport image should not load");
t.step_timeout(t.step_func_done(), 1000);
const iframe = document.createElement('iframe');
iframe.setAttribute("style", "display:none");
iframe.srcdoc = "<body></body>";
iframe.onload = () => {
const adopted_img = iframe.contentDocument.adoptNode(below_viewport_element);
iframe.contentDocument.body.appendChild(adopted_img);
below_viewport_div.scrollIntoView();
};
document.body.insertBefore(iframe, tall_div);
}, "Test that <img> below viewport is not loaded when moved to another " +
"document and then scrolled to");
</script>
</body>
<!DOCTYPE html>
<head>
<title>Images with loading='lazy' load being removed and then scrolled to</title>
<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.
-->
<body>
<img id="in_viewport" src='resources/image.png?in_viewport&pipe=trickle(d1)'>
<div style="height:1000vh"></div>
<div id="below_viewport_div"></div>
<img id="below_viewport" src='resources/image.png?below_viewport' loading="lazy">
<script>
const in_viewport_element = document.getElementById("in_viewport");
const below_viewport_element = document.getElementById("below_viewport");
const below_viewport_div = document.getElementById("below_viewport_div");
async_test(t => {
below_viewport_element.onload = t.unreached_func("Removed loading=lazy image " +
"should not load when its old position is scrolled to.");
below_viewport_element.remove();
in_viewport_element.onload = () => {
below_viewport_div.scrollIntoView();
t.step_timeout(t.step_func_done(), 2000);
};
}, "Test that <img> below viewport is not loaded when removed from the " +
"document and then scrolled to");
</script>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment