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

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 217053009: Validate finiteness of HTMLMediaElement properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add more FIXMEs. Created 6 years, 9 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 | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLMediaElement.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index e1d893b8f8c686596a7d8302bfef9a3c404c3509..a4ba701eafc1c4d6826406b9bfe4e66a691647db 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -668,7 +668,7 @@ void HTMLMediaElement::prepareForLoad()
}
// 5 - Set the playbackRate attribute to the value of the defaultPlaybackRate attribute.
- setPlaybackRate(defaultPlaybackRate());
+ setPlaybackRate(defaultPlaybackRate(), IGNORE_EXCEPTION);
// 6 - Set the error attribute to null and the autoplaying flag to true.
m_error = nullptr;
@@ -1870,6 +1870,11 @@ double HTMLMediaElement::currentTime() const
void HTMLMediaElement::setCurrentTime(double time, ExceptionState& exceptionState)
{
+ // FIXME: generated bindings should check isfinite: http://crbug.com/354298
+ if (!std::isfinite(time)) {
+ exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(time));
+ return;
+ }
if (m_mediaController) {
exceptionState.throwDOMException(InvalidStateError, "The element is slaved to a MediaController.");
return;
@@ -1908,8 +1913,13 @@ double HTMLMediaElement::defaultPlaybackRate() const
return m_defaultPlaybackRate;
}
-void HTMLMediaElement::setDefaultPlaybackRate(double rate)
+void HTMLMediaElement::setDefaultPlaybackRate(double rate, ExceptionState& exceptionState)
{
+ // FIXME: generated bindings should check isfinite: http://crbug.com/354298
+ if (!std::isfinite(rate)) {
+ exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(rate));
+ return;
+ }
if (m_defaultPlaybackRate != rate) {
m_defaultPlaybackRate = rate;
scheduleEvent(EventTypeNames::ratechange);
@@ -1921,10 +1931,16 @@ double HTMLMediaElement::playbackRate() const
return m_playbackRate;
}
-void HTMLMediaElement::setPlaybackRate(double rate)
+void HTMLMediaElement::setPlaybackRate(double rate, ExceptionState& exceptionState)
{
WTF_LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate);
+ // FIXME: generated bindings should check isfinite: http://crbug.com/354298
+ if (!std::isfinite(rate)) {
+ exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(rate));
+ return;
+ }
+
if (m_playbackRate != rate) {
m_playbackRate = rate;
invalidateCachedTime();
@@ -2089,6 +2105,12 @@ void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState)
{
WTF_LOG(Media, "HTMLMediaElement::setVolume(%f)", vol);
+ // FIXME: generated bindings should check isfinite: http://crbug.com/354298
+ if (!std::isfinite(vol)) {
+ exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(vol));
+ return;
+ }
+
if (vol < 0.0f || vol > 1.0f) {
exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::indexOutsideRange("volume", vol, 0.0, ExceptionMessages::InclusiveBound, 1.0, ExceptionMessages::InclusiveBound));
return;
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLMediaElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698