| 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 fe50602608ce9a230a6ead4ad27f152cc401d04d..26e44d2db9fcc690dda8e54e332aab207e96b14d 100644
 | 
| --- a/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
 | 
| +++ b/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
 | 
| @@ -37,133 +37,60 @@
 | 
|  
 | 
|  namespace blink {
 | 
|  
 | 
| -void ExceptionState::clearException()
 | 
| -{
 | 
| -    m_code = 0;
 | 
| -    m_exception.clear();
 | 
| -}
 | 
| -
 | 
| -ScriptPromise ExceptionState::reject(ScriptState* scriptState)
 | 
| -{
 | 
| -    ScriptPromise promise = ScriptPromise::reject(scriptState, m_exception.newLocal(scriptState->isolate()));
 | 
| -    clearException();
 | 
| -    return promise;
 | 
| -}
 | 
| -
 | 
| -void ExceptionState::reject(ScriptPromiseResolver* resolver)
 | 
| -{
 | 
| -    resolver->reject(m_exception.newLocal(resolver->getScriptState()->isolate()));
 | 
| -    clearException();
 | 
| -}
 | 
| -
 | 
|  void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& message)
 | 
|  {
 | 
| -    ASSERT(ec);
 | 
| -    ASSERT(m_isolate);
 | 
| -
 | 
|      // SecurityError is thrown via ::throwSecurityError, and _careful_ consideration must be given to the data exposed to JavaScript via the 'sanitizedMessage'.
 | 
| -    ASSERT(ec != SecurityError);
 | 
| +    DCHECK(ec != SecurityError);
 | 
|  
 | 
| -    m_code = ec;
 | 
| -    String processedMessage = addExceptionContext(message);
 | 
| -    m_message = processedMessage;
 | 
| -    setException(V8ThrowException::createDOMException(m_isolate, ec, processedMessage));
 | 
| +    const String& processedMessage = addExceptionContext(message);
 | 
| +    setException(ec, processedMessage, V8ThrowException::createDOMException(m_isolate, ec, processedMessage));
 | 
|  }
 | 
|  
 | 
| -void ExceptionState::throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage)
 | 
| +void ExceptionState::throwRangeError(const String& message)
 | 
|  {
 | 
| -    ASSERT(m_isolate);
 | 
| -    m_code = SecurityError;
 | 
| -    String finalSanitized = addExceptionContext(sanitizedMessage);
 | 
| -    m_message = finalSanitized;
 | 
| -    String finalUnsanitized = addExceptionContext(unsanitizedMessage);
 | 
| -
 | 
| -    setException(V8ThrowException::createDOMException(m_isolate, SecurityError, finalSanitized, finalUnsanitized));
 | 
| +    setException(V8RangeError, message, V8ThrowException::createRangeError(m_isolate, addExceptionContext(message)));
 | 
|  }
 | 
|  
 | 
| -void ExceptionState::setException(v8::Local<v8::Value> exception)
 | 
| -{
 | 
| -    // FIXME: Assert that exception is not empty?
 | 
| -    if (exception.IsEmpty()) {
 | 
| -        clearException();
 | 
| -        return;
 | 
| -    }
 | 
| -
 | 
| -    m_exception.set(m_isolate, exception);
 | 
| -}
 | 
| -
 | 
| -void ExceptionState::throwException()
 | 
| +void ExceptionState::throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage)
 | 
|  {
 | 
| -    ASSERT(!m_exception.isEmpty());
 | 
| -    V8ThrowException::throwException(m_isolate, m_exception.newLocal(m_isolate));
 | 
| +    const String& finalSanitized = addExceptionContext(sanitizedMessage);
 | 
| +    const String& finalUnsanitized = addExceptionContext(unsanitizedMessage);
 | 
| +    setException(SecurityError, finalSanitized, V8ThrowException::createDOMException(m_isolate, SecurityError, finalSanitized, finalUnsanitized));
 | 
|  }
 | 
|  
 | 
|  void ExceptionState::throwTypeError(const String& message)
 | 
|  {
 | 
| -    ASSERT(m_isolate);
 | 
| -    m_code = V8TypeError;
 | 
| -    m_message = message;
 | 
| -    setException(V8ThrowException::createTypeError(m_isolate, addExceptionContext(message)));
 | 
| +    setException(V8TypeError, message, V8ThrowException::createTypeError(m_isolate, addExceptionContext(message)));
 | 
|  }
 | 
|  
 | 
| -void ExceptionState::throwRangeError(const String& message)
 | 
| +void ExceptionState::clearException()
 | 
|  {
 | 
| -    ASSERT(m_isolate);
 | 
| -    m_code = V8RangeError;
 | 
| -    m_message = message;
 | 
| -    setException(V8ThrowException::createRangeError(m_isolate, addExceptionContext(message)));
 | 
| +    m_code = 0;
 | 
| +    m_message = String();
 | 
| +    m_exception.clear();
 | 
|  }
 | 
|  
 | 
| -void NonThrowableExceptionState::throwDOMException(const ExceptionCode& ec, const String& message)
 | 
| +ScriptPromise ExceptionState::reject(ScriptState* scriptState)
 | 
|  {
 | 
| -    ASSERT_NOT_REACHED();
 | 
| -    m_code = ec;
 | 
| -    m_message = message;
 | 
| +    ScriptPromise promise = ScriptPromise::reject(scriptState, getException());
 | 
| +    clearException();
 | 
| +    return promise;
 | 
|  }
 | 
|  
 | 
| -void NonThrowableExceptionState::throwTypeError(const String& message)
 | 
| +void ExceptionState::reject(ScriptPromiseResolver* resolver)
 | 
|  {
 | 
| -    ASSERT_NOT_REACHED();
 | 
| -    m_code = V8TypeError;
 | 
| -    m_message = message;
 | 
| +    resolver->reject(getException());
 | 
| +    clearException();
 | 
|  }
 | 
|  
 | 
| -void NonThrowableExceptionState::throwSecurityError(const String& sanitizedMessage, const String&)
 | 
| +void ExceptionState::setException(ExceptionCode ec, const String& message, v8::Local<v8::Value> exception)
 | 
|  {
 | 
| -    ASSERT_NOT_REACHED();
 | 
| -    m_code = SecurityError;
 | 
| -    m_message = sanitizedMessage;
 | 
| -}
 | 
| +    CHECK(ec);
 | 
| +    CHECK(!exception.IsEmpty());
 | 
|  
 | 
| -void NonThrowableExceptionState::throwRangeError(const String& message)
 | 
| -{
 | 
| -    ASSERT_NOT_REACHED();
 | 
| -    m_code = V8RangeError;
 | 
| -    m_message = message;
 | 
| -}
 | 
| -
 | 
| -void TrackExceptionState::throwDOMException(const ExceptionCode& ec, const String& message)
 | 
| -{
 | 
|      m_code = ec;
 | 
|      m_message = message;
 | 
| -}
 | 
| -
 | 
| -void TrackExceptionState::throwTypeError(const String& message)
 | 
| -{
 | 
| -    m_code = V8TypeError;
 | 
| -    m_message = message;
 | 
| -}
 | 
| -
 | 
| -void TrackExceptionState::throwSecurityError(const String& sanitizedMessage, const String&)
 | 
| -{
 | 
| -    m_code = SecurityError;
 | 
| -    m_message = sanitizedMessage;
 | 
| -}
 | 
| -
 | 
| -void TrackExceptionState::throwRangeError(const String& message)
 | 
| -{
 | 
| -    m_code = V8RangeError;
 | 
| -    m_message = message;
 | 
| +    m_exception.set(m_isolate, exception);
 | 
|  }
 | 
|  
 | 
|  String ExceptionState::addExceptionContext(const String& message) const
 | 
| @@ -196,4 +123,44 @@ String ExceptionState::addExceptionContext(const String& message) const
 | 
|      return processedMessage;
 | 
|  }
 | 
|  
 | 
| +void NonThrowableExceptionState::throwDOMException(const ExceptionCode& ec, const String& message)
 | 
| +{
 | 
| +    NOTREACHED();
 | 
| +}
 | 
| +
 | 
| +void NonThrowableExceptionState::throwRangeError(const String& message)
 | 
| +{
 | 
| +    NOTREACHED();
 | 
| +}
 | 
| +
 | 
| +void NonThrowableExceptionState::throwSecurityError(const String& sanitizedMessage, const String&)
 | 
| +{
 | 
| +    NOTREACHED();
 | 
| +}
 | 
| +
 | 
| +void NonThrowableExceptionState::throwTypeError(const String& message)
 | 
| +{
 | 
| +    NOTREACHED();
 | 
| +}
 | 
| +
 | 
| +void TrackExceptionState::throwDOMException(const ExceptionCode& ec, const String& message)
 | 
| +{
 | 
| +    setException(ec, message, v8::Null(isolate()));
 | 
| +}
 | 
| +
 | 
| +void TrackExceptionState::throwRangeError(const String& message)
 | 
| +{
 | 
| +    setException(V8RangeError, message, v8::Null(isolate()));
 | 
| +}
 | 
| +
 | 
| +void TrackExceptionState::throwSecurityError(const String& sanitizedMessage, const String&)
 | 
| +{
 | 
| +    setException(SecurityError, sanitizedMessage, v8::Null(isolate()));
 | 
| +}
 | 
| +
 | 
| +void TrackExceptionState::throwTypeError(const String& message)
 | 
| +{
 | 
| +    setException(V8TypeError, message, v8::Null(isolate()));
 | 
| +}
 | 
| +
 | 
|  } // namespace blink
 | 
| 
 |