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

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp

Issue 1856373004: Fix potential null pointer access in HTMLMediaElement::seek (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: correct review comments Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9c8f1cd08f9c91dc3f333e1880ceeab4173d2efc
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/HTMLMediaElement.h"
+
+#include "core/dom/Document.h"
+#include "core/html/HTMLVideoElement.h"
+#include "core/loader/EmptyClients.h"
+#include "core/testing/DummyPageHolder.h"
+#include "platform/testing/UnitTestHelpers.h"
+#include "public/platform/WebMediaPlayer.h"
+#include "public/platform/WebSize.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class HTMLMediaElementTest : public ::testing::Test {
+protected:
+ HTMLMediaElementTest()
+ : m_dummyPageHolder(DummyPageHolder::create(IntSize(640, 360), nullptr, EmptyFrameLoaderClient::create()))
+ {
+ m_video = HTMLVideoElement::create(m_dummyPageHolder->document());
+ }
+
+ void breakReadyState()
+ {
+ // Manually setup a situation when ready state goes out of sync with
+ // m_webMediaPlayer. The real call sequence that results in error is unkown.
+ m_video->setPreload("none");
+ m_video->setSrc("http://foo.bar/");
+ testing::runPendingTasks();
+ m_video->setReadyState(HTMLMediaElement::HAVE_FUTURE_DATA);
+ m_video->remoteRouteAvailabilityChanged(true);
mlamouri (slow - plz ping) 2016/05/19 13:13:03 Do you really need this line?
+ }
+
+ OwnPtr<DummyPageHolder> m_dummyPageHolder;
+ Persistent<HTMLVideoElement> m_video;
+};
+
+TEST_F(HTMLMediaElementTest, webMediaPlayerOutOfSyncWithReadyState)
+{
+ breakReadyState();
+
+ WebMediaPlayer* player = m_video->webMediaPlayer();
+ ASSERT_FALSE(player);
+
+ // Call setCurrentTime that accesses m_webMediaPlayer
+ // If a check of m_webMediaPlayer for nullptr is missing,
+ // the test crashes.
+ m_video->setCurrentTime(0.0);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMediaElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698