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

Unified Diff: third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp

Issue 2342953002: Update EME errors to use TypeError (Closed)
Patch Set: Created 4 years, 3 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
Index: third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
diff --git a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
index c65194b436d3af6e2f5e610de4ec11bc95a8db51..64e7015b48dbef41ca9d6833bd15af67115c9c75 100644
--- a/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
+++ b/third_party/WebKit/Source/modules/encryptedmedia/ContentDecryptionModuleResultPromise.cpp
@@ -6,6 +6,7 @@
#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/V8Binding.h"
#include "core/dom/DOMException.h"
#include "core/dom/ExecutionContext.h"
#include "core/dom/ExecutionContextTask.h"
@@ -33,6 +34,10 @@ ExceptionCode WebCdmExceptionToExceptionCode(WebContentDecryptionModuleException
// FIXME: Update DOMException to handle these if actually added to
// the EME spec.
return UnknownError;
+ case WebContentDecryptionModuleExceptionTypeError:
+ // This is not a DOMException but rather a seperate TypeError. Use a
+ // different ExceptionCode for this so it can be checked for.
+ return TypeMismatchError;
}
NOTREACHED();
@@ -103,7 +108,16 @@ void ContentDecryptionModuleResultPromise::reject(ExceptionCode code, const Stri
void ContentDecryptionModuleResultPromise::rejectInternal(ExceptionCode code, const String& errorMessage)
{
- m_resolver->reject(DOMException::create(code, errorMessage));
+ if (code == TypeMismatchError) {
+ if (m_resolver->getScriptState()->contextIsValid()) {
+ ScriptState::Scope scope(m_resolver->getScriptState());
+ v8::Isolate* isolate = m_resolver->getScriptState()->isolate();
+ m_resolver->reject(v8::Exception::TypeError(v8String(isolate, errorMessage)));
+ }
+ } else {
+ m_resolver->reject(DOMException::create(code, errorMessage));
+ }
+
m_resolver.clear();
}

Powered by Google App Engine
This is Rietveld 408576698