| <!doctype html> |
| <html> |
| <head> |
| <script src=video-test.js></script> |
| <script src=media-file.js></script> |
| <script> |
| var index = 0; |
| |
| function testMuted(expectedMuted, expectedDefaultMuted) |
| { |
| testExpected("video.muted", expectedMuted); |
| testExpected("video.defaultMuted", expectedDefaultMuted); |
| } |
| |
| function testAddedToDocument() |
| { |
| consoleWrite("<br><br><em>*** Test that the 'muted' content attribute reflects the 'muted' IDL attribute before the element" |
| + " is added to the document, and does not reflect after</em></br>"); |
| |
| run("video = document.createElement('video')"); |
| run("video.setAttribute('controls', 'controls')"); |
| video.setAttribute('width', '300'); |
| testMuted(false, false); |
| |
| consoleWrite("<br>*** Change 'muted' content attribute, IDL attribute should change."); |
| run("video.setAttribute('muted', 'muted')"); |
| testMuted(true, true); |
| run("document.getElementById('parent').appendChild(video)"); |
| |
| consoleWrite("<br>*** Change 'muted' content attribute, IDL attribute should not change."); |
| video.removeAttribute('muted'); |
| testMuted(true, false); |
| |
| runNextTest(); |
| } |
| |
| function testExplicitlySetBeforeAddedToDocument() |
| { |
| consoleWrite("<br><br><em>*** Test that setting the 'muted' IDL attribute means that changes to " |
| + "the 'muted' content attribute are no longer reflected.</em></br>"); |
| |
| run("video = document.createElement('video')"); |
| run("video.setAttribute('controls', 'controls')"); |
| video.setAttribute('width', '300'); |
| testMuted(false, false); |
| |
| consoleWrite("<br>*** Change 'muted' content attribute, IDL attribute should change."); |
| run("video.setAttribute('muted', 'muted')"); |
| testMuted(true, true); |
| |
| consoleWrite("<br>*** Change 'muted' IDL attribute, then the content attribute. IDL attribute should not change."); |
| run("video.muted = true"); |
| video.removeAttribute('muted'); |
| testMuted(true, false); |
| |
| runNextTest(); |
| } |
| |
| function test(defaultMuted) |
| { |
| consoleWrite("<br><br><em>*** Test <em>" + (defaultMuted ? "with" : "without") + "</em> 'muted' content attribute</em><br>"); |
| |
| run("video = document.createElement('video')"); |
| run("video.setAttribute('controls', 'controls')"); |
| video.setAttribute('width', '300'); |
| if (defaultMuted) |
| run("video.setAttribute('muted', 'muted')"); |
| |
| consoleWrite("<br>*** Test before setting src, muted IDL attribute should default to muted content attribute"); |
| testMuted(defaultMuted, defaultMuted); |
| |
| var loadedmetadata = function(evt) |
| { |
| consoleWrite("<br>EVENT(" + evt.type + ")"); |
| |
| consoleWrite("<br>*** Change 'defaultMuted', IDL attribute should not change but content attribute should."); |
| var newDefaultMuted = !defaultMuted; |
| run("video.defaultMuted = " + newDefaultMuted); |
| testMuted(defaultMuted, newDefaultMuted); |
| testExpected("video.hasAttribute('muted')", newDefaultMuted); |
| |
| consoleWrite("<br>*** Change 'muted' IDL attribute, content attribute should not change"); |
| run("video.muted = false"); |
| testMuted(false, newDefaultMuted); |
| testExpected("video.hasAttribute('muted')", newDefaultMuted); |
| |
| var action = defaultMuted ? "Remove" : "Add"; |
| consoleWrite("<br>*** " + action + " 'muted' content attribute, it should have no effect on IDL attribute"); |
| if (defaultMuted) |
| run("video.removeAttribute('muted')"); |
| else |
| run("video.setAttribute('muted', 'muted')"); |
| testMuted(false, video.hasAttribute('muted')); |
| |
| runNextTest(); |
| } |
| video.addEventListener('loadedmetadata', loadedmetadata); |
| video.src = findMediaFile("audio", "content/test"); |
| } |
| |
| function runNextTest() |
| { |
| if (video && video.parentNode) { |
| video.parentNode.removeChild(video); |
| video = null; |
| } |
| |
| switch (++index) |
| { |
| case 1: |
| test(true); |
| break; |
| case 2: |
| test(false); |
| break; |
| case 3: |
| testAddedToDocument(); |
| break; |
| case 4: |
| testExplicitlySetBeforeAddedToDocument(); |
| break; |
| case 5: |
| consoleWrite(""); |
| endTest(); |
| break; |
| } |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runNextTest()"> |
| <div id="parent"></div> |
| <p>Test 'muted' content attribute<p> |
| </body> |
| </html> |