Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-defaultmuted.html
blob931c0a2fff5ad92cae351216e4ae85c4039629b4
1 <!doctype html>
2 <html>
3 <head>
4 <script src=video-test.js></script>
5 <script src=media-file.js></script>
6 <script>
7 var index = 0;
9 function testMuted(expectedMuted, expectedDefaultMuted)
11 testExpected("video.muted", expectedMuted);
12 testExpected("video.defaultMuted", expectedDefaultMuted);
15 function test(defaultMuted)
17 consoleWrite("<br><br><b>*** Test <em>" + (defaultMuted ? "with" : "without") + "</em> 'muted' content attribute</b><br>");
19 run("video = document.createElement('video')");
20 run("video.setAttribute('controls', 'controls')");
21 video.setAttribute('width', '300');
22 if (defaultMuted)
23 run("video.setAttribute('muted', 'muted')");
24 document.getElementById('parent').appendChild(video);
26 consoleWrite("<br>*** Test before setting src, IDL attribute should default to false");
27 testMuted(false, defaultMuted);
29 var loadedmetadata = function(evt)
31 consoleWrite("<br>EVENT(" + evt.type + ")");
33 consoleWrite("<br>*** After setting url, content attribute should have set IDL attribute");
34 testMuted(defaultMuted, defaultMuted);
36 consoleWrite("<br>*** Change 'defaultMuted', IDL attribute should not change but content attribute should.");
37 var newDefaultMuted = !defaultMuted;
38 run("video.defaultMuted = " + newDefaultMuted);
39 testMuted(defaultMuted, newDefaultMuted);
40 testExpected("video.hasAttribute('muted')", newDefaultMuted);
42 consoleWrite("<br>*** Change 'muted' IDL attribute, content attribute should not change");
43 run("video.muted = false");
44 testMuted(false, newDefaultMuted);
45 testExpected("video.hasAttribute('muted')", newDefaultMuted);
47 var action = defaultMuted ? "Remove" : "Add";
48 consoleWrite("<br>*** " + action + " 'muted' content attribute, it should have no effect on IDL attribute");
49 if (defaultMuted)
50 run("video.removeAttribute('muted')");
51 else
52 run("video.setAttribute('muted', 'muted')");
53 testMuted(false, video.hasAttribute('muted'));
55 runNextTest();
57 video.addEventListener('loadedmetadata', loadedmetadata);
58 video.src = findMediaFile("audio", "content/test");
61 function runNextTest()
63 if (video) {
64 video.parentNode.removeChild(video);
65 video = null;
68 switch (++index)
70 case 1:
71 test(true);
72 break;
73 case 2:
74 test(false);
75 break;
76 case 3:
77 consoleWrite("");
78 endTest();
79 break;
83 </script>
84 </head>
86 <body onload="runNextTest()">
87 <div id="parent"></div>
88 <p>Test 'muted' content attribute<p>
89 </body>
90 </html>