blob: 956a9837fc36c419a989489e8f2341366abd4f73 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script src="resources/currentSrcHelper.js"></script>
<script>
if (window.testRunner)
testRunner.dumpAsText();
addEventListener("load", function() {
shouldBe('document.getElementById("canary").clientWidth', '75');
shouldBe('currentSrcFileName("canary")', '"blue_rect.jpg?0"');
shouldBe('document.getElementById("div_end_picture").clientWidth', '800');
shouldBe('currentSrcFileName("div_end_picture")', '"image-set-2x.png?2"');
shouldBe('document.getElementById("div_multiple_end").clientWidth', '800');
shouldBe('currentSrcFileName("div_multiple_end")', '"image-set-2x.png?2"');
shouldBe('document.getElementById("source_in_div").clientWidth', '75');
shouldBe('currentSrcFileName("source_in_div")', '"blue_rect.jpg"');
shouldBe('document.getElementById("not_in_picture").clientWidth', '75');
shouldBe('currentSrcFileName("not_in_picture")', '"blue_rect.jpg"');
}, false);
</script>
<!-- A canary image to see that the test is actually working -->
<img id="canary" src="resources/blue_rect.jpg?0">
<!-- Invalid nesting tests -->
<!-- In the following tests, nesting shouldn't mess up the selection algorithm -->
<picture>
<picture>
<source sizes="800px" srcset="../hidpi/resources/image-set-1x.png?2 400w, ../hidpi/resources/image-set-2x.png?2 800w,
resources/image-set-4x.png?2 1600w">
<div>
</picture>
</div>
<img id="div_end_picture" src="resources/blue_rect.jpg">
</picture>
</picture>
<picture>
<div>
</picture>
</picture>
</picture>
</div>
<source sizes="800px" srcset="../hidpi/resources/image-set-1x.png?2 400w, ../hidpi/resources/image-set-2x.png?2 800w,
resources/image-set-4x.png?2 1600w">
<img id="div_multiple_end" src="resources/blue_rect.jpg">
</picture>
<!-- In the following tests, nesting messes up the selection algorithm -->
<picture>
<div>
<picture>
<div>
<source sizes="400px" srcset="resources/base-image1.png?4 200w, resources/base-image3.png?4 400w, resources/base-image2.png?4 800w">
</div>
<img id="source_in_div" src="resources/blue_rect.jpg">
</picture>
</div>
</picture>
<picture>
<div>
<picture>
<div>
<source sizes="400px" srcset="resources/base-image1.png?5 200w, resources/base-image3.png?5 400w, resources/base-image2.png?5 800w">
<img id="not_in_picture" src="resources/blue_rect.jpg">
</div>
</picture>
</div>
</picture>