Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp

Issue 1856373004: Fix potential null pointer access in HTMLMediaElement::seek (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/html/HTMLVideoElement.h" 5 #include "core/html/HTMLVideoElement.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/loader/EmptyClients.h" 8 #include "core/loader/EmptyClients.h"
9 #include "core/page/NetworkStateNotifier.h" 9 #include "core/page/NetworkStateNotifier.h"
10 #include "core/testing/DummyPageHolder.h" 10 #include "core/testing/DummyPageHolder.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 networkStateNotifier().setWebConnection(WebConnectionTypeWifi, 54.0); 81 networkStateNotifier().setWebConnection(WebConnectionTypeWifi, 54.0);
82 m_video = HTMLVideoElement::create(m_dummyPageHolder->document()); 82 m_video = HTMLVideoElement::create(m_dummyPageHolder->document());
83 } 83 }
84 84
85 void setSrc(const AtomicString& url) 85 void setSrc(const AtomicString& url)
86 { 86 {
87 m_video->setSrc(url); 87 m_video->setSrc(url);
88 testing::runPendingTasks(); 88 testing::runPendingTasks();
89 } 89 }
90 90
91 void breakReadyState()
92 {
93 // Manually setup a situation when ready state goes out of sync with
94 // m_webMediaPlayer. The real call sequence that results in error is unk own.
philipj_slow 2016/04/06 15:08:01 This isn't very reassuring. Can you look at all th
pavor 2016/05/12 12:03:36 I tried to figure it out, but without any success.
95 m_video->setPreload("none");
96 setSrc("http://foo.bar/");
97 m_video->setReadyState(HTMLMediaElement::HAVE_FUTURE_DATA);
98 m_video->remoteRouteAvailabilityChanged(true);
99 }
100
101 void callPrivateWebMediaPlayerAccessors()
102 {
103 m_video->updatePlayState();
104 m_video->audioTracksTimerFired(nullptr);
105 }
106
91 MockWebMediaPlayer* webMediaPlayer() 107 MockWebMediaPlayer* webMediaPlayer()
92 { 108 {
93 return static_cast<MockWebMediaPlayer*>(m_video->webMediaPlayer()); 109 return static_cast<MockWebMediaPlayer*>(m_video->webMediaPlayer());
94 } 110 }
95 111
96 OwnPtr<DummyPageHolder> m_dummyPageHolder; 112 OwnPtr<DummyPageHolder> m_dummyPageHolder;
97 Persistent<HTMLVideoElement> m_video; 113 Persistent<HTMLVideoElement> m_video;
98 }; 114 };
99 115
100 TEST_F(HTMLVideoElementTest, setBufferingStrategy_NonUserPause) 116 TEST_F(HTMLVideoElementTest, setBufferingStrategy_NonUserPause)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 m_video->pause(); 152 m_video->pause();
137 } 153 }
138 ::testing::Mock::VerifyAndClearExpectations(player); 154 ::testing::Mock::VerifyAndClearExpectations(player);
139 155
140 // On play, the strategy is set to normal. 156 // On play, the strategy is set to normal.
141 EXPECT_CALL(*player, setBufferingStrategy(WebMediaPlayer::BufferingStrategy: :Normal)); 157 EXPECT_CALL(*player, setBufferingStrategy(WebMediaPlayer::BufferingStrategy: :Normal));
142 m_video->play(); 158 m_video->play();
143 ::testing::Mock::VerifyAndClearExpectations(player); 159 ::testing::Mock::VerifyAndClearExpectations(player);
144 } 160 }
145 161
162 TEST_F(HTMLVideoElementTest, webMediaPlayerOutOfSyncWithReadyState)
163 {
164 breakReadyState();
165
166 MockWebMediaPlayer* player = webMediaPlayer();
167 ASSERT_FALSE(player);
168
169 // Call public methods that access m_webMediaPlayer
170 // If a check of m_webMediaPlayer for nullptr is missing,
171 // the test crashes.
172 m_video->setCurrentTime(0.0);
173 m_video->requestRemotePlayback();
174 m_video->requestRemotePlaybackControl();
175 m_video->selectedVideoTrackChanged(nullptr);
176
177 callPrivateWebMediaPlayerAccessors();
178 }
179
146 } // namespace blink 180 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698