Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / HTMLImageElement / image-picture-source-dynamic-changes.html
blob5ca9569d55057f2da49d4ba347132b36b3c3a399
1 <!DOCTYPE html>
2 <script src="../../../resources/js-test.js"></script>
3 <script src="resources/currentSrcHelper.js"></script>
5 <picture>
6 <source id="src" srcset="../../hidpi/resources/image-set-1x.png?1 1x">
7 <img id="simple" src="resources/blue_rect.jpg?1">
8 </picture>
10 <script>
11 jsTestIsAsync = true;
13 var iteration = 0;
15 var simple = document.getElementById('simple');
16 var src = document.getElementById('src');
18 simple.addEventListener('load', function() {
19 switch (iteration) {
20 case 0:
21 shouldBe('document.getElementById("simple").clientWidth', '400');
22 shouldBe('currentSrcFileName("simple")', '"image-set-1x.png?1"');
24 src.srcset = 'resources/image-set-4x.png 1x';
25 break;
26 case 1:
27 shouldBe('document.getElementById("simple").clientWidth', '1600');
28 shouldBe('currentSrcFileName("simple")', '"image-set-4x.png"');
30 src.parentNode.removeChild(src);
31 break;
32 case 2:
33 shouldBe('document.getElementById("simple").clientWidth', '75');
34 shouldBe('currentSrcFileName("simple")', '"blue_rect.jpg?1"');
36 src.srcset = '../../hidpi/resources/image-set-1x.png?2 1x';
37 simple.parentNode.insertBefore(src, simple);
38 break;
39 case 3:
40 shouldBe('document.getElementById("simple").clientWidth', '400');
41 shouldBe('currentSrcFileName("simple")', '"image-set-1x.png?2"');
44 // When there is a <source>, changing the <src> should have no effect
45 simple.src = 'resources/blue_rect.jpg?2';
46 shouldBe('currentSrcFileName("simple")', '"image-set-1x.png?2"');
48 finishJSTest();
49 break;
51 ++iteration;
52 }, false);
53 </script>