Index: Source/modules/mediasession/HTMLMediaElementMediaSession.cpp |
diff --git a/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp b/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp |
index ddcde17601ffe90911027ed7909630e6e3bda4cf..3226b4f908a48f5bb1b60c633987209627b941ed 100644 |
--- a/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp |
+++ b/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp |
@@ -5,6 +5,8 @@ |
#include "config.h" |
#include "modules/mediasession/HTMLMediaElementMediaSession.h" |
+#include "Source/core/dom/ExceptionCode.h" |
+ |
namespace blink { |
MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaElement) |
@@ -14,8 +16,14 @@ MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaEleme |
return nullptr; |
} |
-void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, MediaSession* session) |
+void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, MediaSession* session, ExceptionState& exceptionState) |
{ |
+ if (mediaElement.networkState() != HTMLMediaElement::NETWORK_EMPTY |
+ && mediaElement.networkState() != HTMLMediaElement::NETWORK_NO_SOURCE) { |
+ exceptionState.throwDOMException(InvalidStateError, "A media session must be set when before a resource is selected"); |
+ return; |
+ } |
+ |
from(mediaElement).m_session = session; |
} |