Commit faa91395 authored by Will Cassella's avatar Will Cassella Committed by Commit Bot

Prevent poster rendering over video if LoadTimerFired runs after Play

If HTMLMediaElement::Play is called before
HTMLMediaElement::LoadTimerFired is run, then LoadTimerFired will
set the 'show-poster-flag' to 'true', and nothing will unset it even
after playback begins. This was because the call to
'SetShowPosterFlag(true)' was in the wrong location, this CL moves it to
the right location, and adds a test to prevent regression.

Bug: 1094778, 1095320
Change-Id: Ia1c558a35f2816136994c0013061d2e00ae90ff4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2249459
Commit-Queue: Will Cassella <cassew@google.com>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780338}
parent 90d4f3cb
......@@ -344,6 +344,7 @@ void AutoplayPolicy::OnIntersectionChangedForAutoplay(
if (ShouldAutoplay()) {
element_->paused_ = false;
element_->SetShowPosterFlag(false);
element_->ScheduleEvent(event_type_names::kPlay);
element_->ScheduleNotifyPlaying();
......
......@@ -1185,8 +1185,6 @@ void HTMLMediaElement::LoadResource(const WebMediaPlayerSource& source,
StartProgressEventTimer();
SetShowPosterFlag(true);
SetPlayerPreload();
DCHECK(!media_source_);
......@@ -1531,11 +1529,14 @@ void HTMLMediaElement::WaitForSourceChange() {
StopPeriodicTimers();
load_state_ = kWaitingForSource;
// 6.17 - Waiting: Set the element's networkState attribute to the
// 17 - Waiting: Set the element's networkState attribute to the
// NETWORK_NO_SOURCE value
SetNetworkState(kNetworkNoSource);
// 6.18 - Set the element's delaying-the-load-event flag to false. This stops
// 18 - Set the element's show poster flag to true.
SetShowPosterFlag(true);
// 19 - Set the element's delaying-the-load-event flag to false. This stops
// delaying the load event.
SetShouldDelayLoadEvent(false);
......@@ -1941,6 +1942,9 @@ void HTMLMediaElement::SetReadyState(ReadyState state) {
}
void HTMLMediaElement::SetShowPosterFlag(bool value) {
DVLOG(3) << "SetShowPosterFlag(" << *this << ", " << value
<< ") - current state is " << show_poster_flag_;
if (value == show_poster_flag_)
return;
......
......@@ -129,6 +129,8 @@ class HTMLMediaElementTest : public testing::TestWithParam<MediaTestParam> {
bool CouldPlayIfEnoughData() { return Media()->CouldPlayIfEnoughData(); }
bool PotentiallyPlaying() { return Media()->PotentiallyPlaying(); }
bool ShouldDelayLoadEvent() { return Media()->should_delay_load_event_; }
void SetReadyState(HTMLMediaElement::ReadyState state) {
......@@ -715,4 +717,35 @@ TEST_P(HTMLMediaElementTest, ShowPosterFlag_FalseAfterAutoPlay) {
EXPECT_FALSE(Media()->IsShowPosterFlagSet());
}
TEST_P(HTMLMediaElementTest, ShowPosterFlag_FalseAfterPlayBeforeReady) {
Media()->SetSrc(SrcSchemeToURL(TestURLScheme::kHttp));
// Initially we have nothing, we're not playing, trying to play, and the 'show
// poster' flag is set
EXPECT_EQ(Media()->getReadyState(), HTMLMediaElement::kHaveNothing);
EXPECT_TRUE(Media()->paused());
EXPECT_FALSE(PotentiallyPlaying());
EXPECT_TRUE(Media()->IsShowPosterFlagSet());
// Attempt to begin playback
Media()->Play();
test::RunPendingTasks();
// We still have no data, but we're not paused, and the 'show poster' flag is
// not set
EXPECT_EQ(Media()->getReadyState(), HTMLMediaElement::kHaveNothing);
EXPECT_FALSE(Media()->paused());
EXPECT_FALSE(PotentiallyPlaying());
EXPECT_FALSE(Media()->IsShowPosterFlagSet());
// Pretend we have data to begin playback
SetReadyState(HTMLMediaElement::kHaveFutureData);
// We should have data, be playing, and the show poster flag should be unset
EXPECT_EQ(Media()->getReadyState(), HTMLMediaElement::kHaveFutureData);
EXPECT_FALSE(Media()->paused());
EXPECT_TRUE(PotentiallyPlaying());
EXPECT_FALSE(Media()->IsShowPosterFlagSet());
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment