<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="http://127.0.0.1:8000/resources/slow-script.pl?delay=100"></script>
<script src="resources/picture-preload-helper.js"></script>
</head>
<body>
<script>
    if (window.testRunner)
        testRunner.dumpAsText();
    shouldBeTrue("internals.isPreloaded('resources/preload-test.jpg?0');");
    shouldBeTrue("internals.isPreloaded('resources/image2.png');");
    loadFromSource(1);
    loadFromSource(2);
    loadFromSource(3);
    loadFromSource(4);
    loadFromSource(5);
    loadFromSource(6);
    loadFromSource(7);
    shouldBeFalse("internals.isPreloaded('resources/preload-test.jpg?71');");
    shouldBeTrue("internals.isPreloaded('resources/preload-test.jpg?72');");
    shouldBeTrue("internals.isPreloaded('resources/preload-test.jpg?8');");
</script>
<!-- Control group -->
<img src="resources/preload-test.jpg?0">
<picture>
<source srcset="resources/image2.png">
<img></picture>
<!-- nested element tests  - In these we're doing the right thing -->
<picture>
    <picture>
        <source sizes="400px" srcset="resources/base-image1.png?1 200w, resources/base-image3.png?1 400w, resources/base-image2.png?1 800w">
        <img src="resources/preload-test.jpg?1">
    </picture>
</picture>
<picture>
    <div>
        <picture>
            <source sizes="400px" srcset="resources/base-image1.png?2 200w, resources/base-image3.png?2 400w, resources/base-image2.png?2 800w">
            <img src="resources/preload-test.jpg?2">
        </picture>
    </div>
</picture>
<picture>
    <source sizes="400px" srcset="resources/base-image1.png?3 200w, resources/base-image3.png?3 400w, resources/base-image2.png?3 800w">
    <div>
        <picture>
            <source sizes="400px" srcset="resources/base-image1.png?4 200w, resources/base-image3.png?4 400w, resources/base-image2.png?4 800w">
            <img src="resources/preload-test.jpg?4">
        </picture>
    </div>
    <img src="resources/preload-test.jpg?3">
</picture>
<picture>
    <source sizes="400px" srcset="resources/base-image1.png?5 200w, resources/base-image3.png?5 400w, resources/base-image2.png?5 800w">
    <div />
        <picture>
            <source sizes="400px" srcset="resources/base-image1.png?6 200w, resources/base-image3.png?6 400w, resources/base-image2.png?6 800w">
            <!-- We're getting this one right -->
            <img src="resources/preload-test.jpg?6">
        </picture>
    </div>
    <img src="resources/preload-test.jpg?5">
</picture>
<picture>
    <picture>
        <source sizes="400px" srcset="resources/base-image1.png?7 200w, resources/base-image3.png?7 400w, resources/base-image2.png?7 800w">
        <img src="resources/preload-test.jpg?7">
        <img src="resources/preload-test.jpg?71">
    </picture>
    <img src="resources/preload-test.jpg?72">
</picture>
<picture>
    <img src="resources/preload-test.jpg?8">
</picture>
</body>
</html>
