Skip to content

Truly independent web browser

1.0 KB
Raw Blame
<!DOCTYPE html>
<!-- Test: Image with loading="lazy" inside an iframe. The intersection observer
     for lazy loading may fire after the iframe is removed, triggering
     image fetch on an inactive document. -->
<html class="test-wait">
<body>
<script>
    const imageUrl = new URL("../../Assets/120.png", document.baseURI).href;
    const iframe = document.createElement("iframe");
    iframe.src = "../../Assets/blank.html";
    iframe.onload = () => {
        const doc = iframe.contentDocument;
        const img = doc.createElement("img");
        img.loading = "lazy";
        img.src = imageUrl;
        doc.body.appendChild(img);

        // Remove iframe. The lazy loading intersection observer
        // may attempt to resume loading on the inactive document.
        setTimeout(() => {
            iframe.remove();
        }, 50);

        setTimeout(() => {
            document.documentElement.classList.remove("test-wait");
        }, 500);
    };
    document.body.appendChild(iframe);
</script>
</body>
</html>