Bug 602072 - Ensure media play() overrides preload='none'. r=roc a=blocking2.0

This commit is contained in:
Chris Pearce 2010-10-17 07:41:53 +13:00
Родитель eb4e29d363
Коммит 84e276b818
2 изменённых файлов: 28 добавлений и 3 удалений

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

@ -831,9 +831,11 @@ static PRBool IsAutoplayEnabled()
void nsHTMLMediaElement::UpdatePreloadAction()
{
PreloadAction nextAction = PRELOAD_UNDEFINED;
// If autoplay is set, we should always preload data, as we'll need it
// to play.
if (IsAutoplayEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) {
// If autoplay is set, or we're playing, we should always preload data,
// as we'll need it to play.
if ((IsAutoplayEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) ||
!mPaused)
{
nextAction = nsHTMLMediaElement::PRELOAD_ENOUGH;
} else {
// Find the appropriate preload action by looking at the attribute.
@ -1394,7 +1396,9 @@ NS_IMETHODIMP nsHTMLMediaElement::Play()
mPaused = PR_FALSE;
mAutoplaying = PR_FALSE;
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
// and our preload status.
AddRemoveSelfReference();
UpdatePreloadAction();
return NS_OK;
}

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

@ -535,6 +535,27 @@ var tests = [
v.src = test.name;
},
},
{
// 18. On a preload='none' video, call play() before load algorithms's sync
// has run, the play() call should override preload='none'.
ended:
function(e) {
ok(true, "(18) Got playback ended.");
var v = e.target;
v._finished = true;
maybeFinish(v, 18);
},
setup:
function(v) {
v.addEventListener("ended", this.ended, false);
v._finished = false;
v.preload = "none";
v.src = test.name; // Schedules async section to continue load algorithm.
document.body.appendChild(v);
v.play(); // Should cause preload:none to be overridden.
},
}
];
function startTest(test, token) {