haikuwebkit/LayoutTests/media/video-defaultmuted.html

137 lines
5.4 KiB
HTML
Raw Permalink Normal View History

<!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);
}
Setting muted attribute on <video> element is not reflected in controls https://bugs.webkit.org/show_bug.cgi?id=127726 Reviewed by Eric Carlson. Source/WebCore: If the 'muted' IDL attribute is queried after the 'muted' and 'src' content attributes are set but before loading begins, it will return 'false' until loading begins, but with no way to query whether that value is valid, nor firing a volumechange event when its value changes. The HTML spec says that the 'muted' content attribute controls whether audio output is muted "when the media element is created", not when loading begins, but we don't necessarily have a signal that the element is fully parsed. Additionally, this means its impossible to make an element via script and get this behavior. So the new behavior is that the 'muted' IDL attribute will always reflect the 'muted' content attribute up until one of the following three conditions: - The 'muted' IDL attribute is set via script. - The element is inserted in the document. - The element begins loading. After the first one of the above conditions, the 'muted' IDL attribute will no longer change when the 'muted' content attribute changes. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::parseAttribute): * html/HTMLMediaElement.h: LayoutTests: * media/video-defaultmuted-expected.txt: * media/video-defaultmuted.html: Canonical link: https://commits.webkit.org/145780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-28 17:49:58 +00:00
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)
{
Setting muted attribute on <video> element is not reflected in controls https://bugs.webkit.org/show_bug.cgi?id=127726 Reviewed by Eric Carlson. Source/WebCore: If the 'muted' IDL attribute is queried after the 'muted' and 'src' content attributes are set but before loading begins, it will return 'false' until loading begins, but with no way to query whether that value is valid, nor firing a volumechange event when its value changes. The HTML spec says that the 'muted' content attribute controls whether audio output is muted "when the media element is created", not when loading begins, but we don't necessarily have a signal that the element is fully parsed. Additionally, this means its impossible to make an element via script and get this behavior. So the new behavior is that the 'muted' IDL attribute will always reflect the 'muted' content attribute up until one of the following three conditions: - The 'muted' IDL attribute is set via script. - The element is inserted in the document. - The element begins loading. After the first one of the above conditions, the 'muted' IDL attribute will no longer change when the 'muted' content attribute changes. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::parseAttribute): * html/HTMLMediaElement.h: LayoutTests: * media/video-defaultmuted-expected.txt: * media/video-defaultmuted.html: Canonical link: https://commits.webkit.org/145780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-28 17:49:58 +00:00
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')");
Setting muted attribute on <video> element is not reflected in controls https://bugs.webkit.org/show_bug.cgi?id=127726 Reviewed by Eric Carlson. Source/WebCore: If the 'muted' IDL attribute is queried after the 'muted' and 'src' content attributes are set but before loading begins, it will return 'false' until loading begins, but with no way to query whether that value is valid, nor firing a volumechange event when its value changes. The HTML spec says that the 'muted' content attribute controls whether audio output is muted "when the media element is created", not when loading begins, but we don't necessarily have a signal that the element is fully parsed. Additionally, this means its impossible to make an element via script and get this behavior. So the new behavior is that the 'muted' IDL attribute will always reflect the 'muted' content attribute up until one of the following three conditions: - The 'muted' IDL attribute is set via script. - The element is inserted in the document. - The element begins loading. After the first one of the above conditions, the 'muted' IDL attribute will no longer change when the 'muted' content attribute changes. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::parseAttribute): * html/HTMLMediaElement.h: LayoutTests: * media/video-defaultmuted-expected.txt: * media/video-defaultmuted.html: Canonical link: https://commits.webkit.org/145780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-28 17:49:58 +00:00
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);
Setting muted attribute on <video> element is not reflected in controls https://bugs.webkit.org/show_bug.cgi?id=127726 Reviewed by Eric Carlson. Source/WebCore: If the 'muted' IDL attribute is queried after the 'muted' and 'src' content attributes are set but before loading begins, it will return 'false' until loading begins, but with no way to query whether that value is valid, nor firing a volumechange event when its value changes. The HTML spec says that the 'muted' content attribute controls whether audio output is muted "when the media element is created", not when loading begins, but we don't necessarily have a signal that the element is fully parsed. Additionally, this means its impossible to make an element via script and get this behavior. So the new behavior is that the 'muted' IDL attribute will always reflect the 'muted' content attribute up until one of the following three conditions: - The 'muted' IDL attribute is set via script. - The element is inserted in the document. - The element begins loading. After the first one of the above conditions, the 'muted' IDL attribute will no longer change when the 'muted' content attribute changes. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::parseAttribute): * html/HTMLMediaElement.h: LayoutTests: * media/video-defaultmuted-expected.txt: * media/video-defaultmuted.html: Canonical link: https://commits.webkit.org/145780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-28 17:49:58 +00:00
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()
{
Setting muted attribute on <video> element is not reflected in controls https://bugs.webkit.org/show_bug.cgi?id=127726 Reviewed by Eric Carlson. Source/WebCore: If the 'muted' IDL attribute is queried after the 'muted' and 'src' content attributes are set but before loading begins, it will return 'false' until loading begins, but with no way to query whether that value is valid, nor firing a volumechange event when its value changes. The HTML spec says that the 'muted' content attribute controls whether audio output is muted "when the media element is created", not when loading begins, but we don't necessarily have a signal that the element is fully parsed. Additionally, this means its impossible to make an element via script and get this behavior. So the new behavior is that the 'muted' IDL attribute will always reflect the 'muted' content attribute up until one of the following three conditions: - The 'muted' IDL attribute is set via script. - The element is inserted in the document. - The element begins loading. After the first one of the above conditions, the 'muted' IDL attribute will no longer change when the 'muted' content attribute changes. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::parseAttribute): * html/HTMLMediaElement.h: LayoutTests: * media/video-defaultmuted-expected.txt: * media/video-defaultmuted.html: Canonical link: https://commits.webkit.org/145780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-28 17:49:58 +00:00
if (video && video.parentNode) {
video.parentNode.removeChild(video);
video = null;
}
switch (++index)
{
case 1:
test(true);
break;
case 2:
test(false);
break;
case 3:
Setting muted attribute on <video> element is not reflected in controls https://bugs.webkit.org/show_bug.cgi?id=127726 Reviewed by Eric Carlson. Source/WebCore: If the 'muted' IDL attribute is queried after the 'muted' and 'src' content attributes are set but before loading begins, it will return 'false' until loading begins, but with no way to query whether that value is valid, nor firing a volumechange event when its value changes. The HTML spec says that the 'muted' content attribute controls whether audio output is muted "when the media element is created", not when loading begins, but we don't necessarily have a signal that the element is fully parsed. Additionally, this means its impossible to make an element via script and get this behavior. So the new behavior is that the 'muted' IDL attribute will always reflect the 'muted' content attribute up until one of the following three conditions: - The 'muted' IDL attribute is set via script. - The element is inserted in the document. - The element begins loading. After the first one of the above conditions, the 'muted' IDL attribute will no longer change when the 'muted' content attribute changes. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::parseAttribute): * html/HTMLMediaElement.h: LayoutTests: * media/video-defaultmuted-expected.txt: * media/video-defaultmuted.html: Canonical link: https://commits.webkit.org/145780@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-28 17:49:58 +00:00
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>