4 <script src=video-test.js
></script>
5 <script src=media-file.js
></script>
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');
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");
50 run("video.removeAttribute('muted')");
52 run("video.setAttribute('muted', 'muted')");
53 testMuted(false, video
.hasAttribute('muted'));
57 video
.addEventListener('loadedmetadata', loadedmetadata
);
58 video
.src
= findMediaFile("audio", "content/test");
61 function runNextTest()
64 video
.parentNode
.removeChild(video
);
86 <body onload=
"runNextTest()">
87 <div id=
"parent"></div>
88 <p>Test 'muted' content attribute
<p>