| Index: third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp b/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
|
| index a446114b11798ba8f25ee03c6dd238db98817c89..f035f4cd6d6fb829959b0ee483d806223a03ad38 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
|
| @@ -37,6 +37,10 @@
|
|
|
| namespace blink {
|
|
|
| +bool ExceptionState::shouldThrow() const {
|
| + return true;
|
| +}
|
| +
|
| void ExceptionState::throwDOMException(ExceptionCode ec, const char* message) {
|
| throwDOMException(ec, String(message));
|
| }
|
| @@ -61,12 +65,18 @@ void ExceptionState::throwDOMException(ExceptionCode ec,
|
| // 'sanitizedMessage'.
|
| DCHECK(ec != SecurityError);
|
|
|
| + if (!shouldThrow())
|
| + return;
|
| +
|
| const String& processedMessage = addExceptionContext(message);
|
| setException(ec, processedMessage, V8ThrowException::createDOMException(
|
| m_isolate, ec, processedMessage));
|
| }
|
|
|
| void ExceptionState::throwRangeError(const String& message) {
|
| + if (!shouldThrow())
|
| + return;
|
| +
|
| setException(V8RangeError, message,
|
| V8ThrowException::createRangeError(
|
| m_isolate, addExceptionContext(message)));
|
| @@ -74,6 +84,9 @@ void ExceptionState::throwRangeError(const String& message) {
|
|
|
| void ExceptionState::throwSecurityError(const String& sanitizedMessage,
|
| const String& unsanitizedMessage) {
|
| + if (!shouldThrow())
|
| + return;
|
| +
|
| const String& finalSanitized = addExceptionContext(sanitizedMessage);
|
| const String& finalUnsanitized = addExceptionContext(unsanitizedMessage);
|
| setException(SecurityError, finalSanitized,
|
| @@ -82,12 +95,18 @@ void ExceptionState::throwSecurityError(const String& sanitizedMessage,
|
| }
|
|
|
| void ExceptionState::throwTypeError(const String& message) {
|
| + if (!shouldThrow())
|
| + return;
|
| +
|
| setException(V8TypeError, message,
|
| V8ThrowException::createTypeError(m_isolate,
|
| addExceptionContext(message)));
|
| }
|
|
|
| void ExceptionState::rethrowV8Exception(v8::Local<v8::Value> value) {
|
| + if (!shouldThrow())
|
| + return;
|
| +
|
| setException(kRethrownException, String(), value);
|
| }
|
|
|
| @@ -172,50 +191,14 @@ NonThrowableExceptionState::NonThrowableExceptionState(const char* file,
|
| m_file(file),
|
| m_line(line) {}
|
|
|
| -void NonThrowableExceptionState::throwDOMException(ExceptionCode ec,
|
| - const String& message) {
|
| - DCHECK_AT(false, m_file, m_line) << "DOMExeption should not be thrown.";
|
| -}
|
| -
|
| -void NonThrowableExceptionState::throwRangeError(const String& message) {
|
| - DCHECK_AT(false, m_file, m_line) << "RangeError should not be thrown.";
|
| -}
|
| -
|
| -void NonThrowableExceptionState::throwSecurityError(
|
| - const String& sanitizedMessage,
|
| - const String&) {
|
| - DCHECK_AT(false, m_file, m_line) << "SecurityError should not be thrown.";
|
| -}
|
| -
|
| -void NonThrowableExceptionState::throwTypeError(const String& message) {
|
| - DCHECK_AT(false, m_file, m_line) << "TypeError should not be thrown.";
|
| -}
|
| -
|
| -void NonThrowableExceptionState::rethrowV8Exception(v8::Local<v8::Value>) {
|
| - DCHECK_AT(false, m_file, m_line) << "An exception should not be rethrown.";
|
| -}
|
| -
|
| -void DummyExceptionStateForTesting::throwDOMException(ExceptionCode ec,
|
| - const String& message) {
|
| - setException(ec, message, v8::Local<v8::Value>());
|
| -}
|
| -
|
| -void DummyExceptionStateForTesting::throwRangeError(const String& message) {
|
| - setException(V8RangeError, message, v8::Local<v8::Value>());
|
| -}
|
| -
|
| -void DummyExceptionStateForTesting::throwSecurityError(
|
| - const String& sanitizedMessage,
|
| - const String&) {
|
| - setException(SecurityError, sanitizedMessage, v8::Local<v8::Value>());
|
| -}
|
| -
|
| -void DummyExceptionStateForTesting::throwTypeError(const String& message) {
|
| - setException(V8TypeError, message, v8::Local<v8::Value>());
|
| +bool NonThrowableExceptionState::shouldThrow() const {
|
| + DCHECK_AT(false, m_file, m_line) << "An exception should not be thrown.";
|
| + return false;
|
| }
|
|
|
| -void DummyExceptionStateForTesting::rethrowV8Exception(v8::Local<v8::Value>) {
|
| - setException(kRethrownException, String(), v8::Local<v8::Value>());
|
| +bool DummyExceptionStateForTesting::shouldThrow() const {
|
| + // This class ignores all exceptions.
|
| + return false;
|
| }
|
|
|
| } // namespace blink
|
|
|