| Index: Source/modules/crypto/CryptoResultImpl.cpp
|
| diff --git a/Source/modules/crypto/CryptoResultImpl.cpp b/Source/modules/crypto/CryptoResultImpl.cpp
|
| index 11015d4abdde9d77e4354399cacb02eefa7581d0..efa19485d27d534508cd2ad82dd38f83ee46ec03 100644
|
| --- a/Source/modules/crypto/CryptoResultImpl.cpp
|
| +++ b/Source/modules/crypto/CryptoResultImpl.cpp
|
| @@ -33,6 +33,8 @@
|
|
|
| #include "bindings/v8/NewScriptState.h"
|
| #include "bindings/v8/ScriptPromiseResolverWithContext.h"
|
| +#include "core/dom/DOMError.h"
|
| +#include "core/dom/DOMException.h"
|
| #include "core/dom/ExecutionContext.h"
|
| #include "modules/crypto/Key.h"
|
| #include "modules/crypto/KeyPair.h"
|
| @@ -44,6 +46,37 @@
|
|
|
| namespace WebCore {
|
|
|
| +namespace {
|
| +
|
| +ExceptionCode toExceptionCode(blink::WebCryptoErrorType exceptionType)
|
| +{
|
| + switch (exceptionType) {
|
| + case blink::WebCryptoErrorTypeNotSupported:
|
| + return NotSupportedError;
|
| + case blink::WebCryptoErrorTypeSyntax:
|
| + return SyntaxError;
|
| + case blink::WebCryptoErrorTypeInvalidState:
|
| + return InvalidStateError;
|
| + case blink::WebCryptoErrorTypeInvalidAccess:
|
| + return InvalidAccessError;
|
| + case blink::WebCryptoErrorTypeUnknown:
|
| + return UnknownError;
|
| + case blink::WebCryptoErrorTypeData:
|
| + return DataError;
|
| + case blink::WebCryptoErrorTypeOperation:
|
| + // FIXME: This exception type is new to WebCrypto and not yet defined.
|
| + // Use a placeholder for now.
|
| + return InvalidStateError;
|
| + case blink::WebCryptoErrorTypeType:
|
| + // FIXME: This should construct a TypeError instead. For now do
|
| + // something to facilitate refactor, but this will need to be
|
| + // revisited.
|
| + return DataError;
|
| + }
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| CryptoResultImpl::~CryptoResultImpl()
|
| {
|
| }
|
| @@ -53,24 +86,15 @@ PassRefPtr<CryptoResultImpl> CryptoResultImpl::create()
|
| return adoptRef(new CryptoResultImpl(callingExecutionContext(v8::Isolate::GetCurrent())));
|
| }
|
|
|
| -void CryptoResultImpl::completeWithError(const blink::WebString& errorDetails)
|
| +void CryptoResultImpl::completeWithError(blink::WebCryptoErrorType exceptionType, const blink::WebString& errorDetails)
|
| {
|
| ASSERT(!m_finished);
|
|
|
| if (canCompletePromise()) {
|
| - if (!errorDetails.isEmpty()) {
|
| - // FIXME: Include the line number which started the crypto operation.
|
| - executionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, errorDetails);
|
| - }
|
| - m_promiseResolver->reject(V8NullType());
|
| + m_promiseResolver->reject(DOMException::create(toExceptionCode(exceptionType), errorDetails));
|
| }
|
| }
|
|
|
| -void CryptoResultImpl::completeWithError()
|
| -{
|
| - completeWithError(blink::WebString());
|
| -}
|
| -
|
| void CryptoResultImpl::completeWithBuffer(const blink::WebArrayBuffer& buffer)
|
| {
|
| ASSERT(!m_finished);
|
|
|