Bug 601881 - video and audio should never play automatically in editor; r,a=bzbarsky

This commit is contained in:
Ehsan Akhgari 2010-10-06 16:31:09 -04:00
Родитель 60ab044952
Коммит 62db0bd0f7
3 изменённых файлов: 61 добавлений и 1 удалений

Просмотреть файл

@ -388,7 +388,8 @@ NS_IMPL_STRING_ATTR(nsHTMLMediaElement, Preload, preload)
/* readonly attribute nsIDOMHTMLMediaElement mozAutoplayEnabled; */
NS_IMETHODIMP nsHTMLMediaElement::GetMozAutoplayEnabled(PRBool *aAutoplayEnabled)
{
*aAutoplayEnabled = mAutoplayEnabled;
// Do not allow autoplay on editable nodes
*aAutoplayEnabled = !IsEditable() && mAutoplayEnabled;
return NS_OK;
}

Просмотреть файл

@ -64,6 +64,7 @@ _TEST_FILES = \
test_bug592592.html \
test_bug597784.html \
test_bug599322.html \
test_bug601881.html \
test_CF_HTML_clipboard.html \
test_contenteditable_focus.html \
test_contenteditable_text_input_handling.html \

Просмотреть файл

@ -0,0 +1,58 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=601881
-->
<head>
<title>Test for Bug 601881</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=601881">Mozilla Bug 601881</a>
<p id="display"></p>
<div id="content">
<video id="v"></video>
<audio id="a"></audio>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 601881 **/
var v = document.getElementById("v");
var a = document.getElementById("a");
var content = document.getElementById("content");
function runPass(makeEditable, makeUneditable, callback) {
is(v.mozAutoplayEnabled, true, "Video should be autoplay-able when not made editable yet");
is(a.mozAutoplayEnabled, true, "Audio should be autoplay-able when not made editable yet");
makeEditable();
is(v.mozAutoplayEnabled, false, "Video should not be autoplay-able when made editable");
is(a.mozAutoplayEnabled, false, "Audio should not be autoplay-able ehen made editable");
makeUneditable();
is(v.mozAutoplayEnabled, true, "Video should be autoplay-able after being made uneditable");
is(a.mozAutoplayEnabled, true, "Audio should be autoplay-able after being made uneditable");
callback();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
runPass(function () document.designMode = 'on',
function () document.designMode = 'off',
function () {
runPass(function() content.setAttribute("contenteditable", "true"),
function() content.removeAttribute("contenteditable"),
function() SimpleTest.finish()
)
}
);
});
</script>
</pre>
</body>
</html>