Bug 505150. 'new Audio' constructors should set autobuffer automatically. r=doublec

--HG--
extra : rebase_source : 418f3c2ad918ae729857363041273c95230dfd2c
This commit is contained in:
Robert O'Callahan 2009-07-27 09:31:11 +12:00
parent 7f80aa5dd5
commit 93cecdc075
3 changed files with 10 additions and 3 deletions

View File

@ -117,8 +117,15 @@ NS_IMETHODIMP
nsHTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext,
JSObject *aObj, PRUint32 argc, jsval *argv)
{
// Audio elements created using "new Audio(...)" should have
// 'autobuffer' set (since the script must intend to play the audio)
nsresult rv = SetAttr(kNameSpaceID_None, nsGkAtoms::autobuffer,
NS_LITERAL_STRING("autobuffer"), PR_TRUE);
if (NS_FAILED(rv))
return rv;
if (argc <= 0) {
// Nothing to do here if we don't get any arguments.
// Nothing more to do here if we don't get any arguments.
return NS_OK;
}

View File

@ -19,7 +19,7 @@ for (var i = 0; i < gAudioTests.length; ++i) {
if (!a1.canPlayType(test.type))
continue;
a1.setAttribute("autobuffer", "");
is(a1.getAttribute("autobuffer"), "autobuffer", "Autobuffer automatically set");
a1.addEventListener('load', function(event) {
is(event.target.networkState, HTMLMediaElement.NETWORK_LOADED,
"Audio " + event.target.currentSrc + " loaded");

View File

@ -20,7 +20,7 @@ for (var i = 0; i < gAudioTests.length; ++i) {
continue;
var a1 = new Audio(test.name);
a1.setAttribute("autobuffer", "");
is(a1.getAttribute("autobuffer"), "autobuffer", "Autobuffer automatically set");
a1.addEventListener('load', function(event) {
is(event.target.networkState, HTMLMediaElement.NETWORK_LOADED,
"Audio " + event.target.currentSrc + " loaded");