| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 ASSERT(ec); | 61 ASSERT(ec); |
| 62 ASSERT(m_isolate); | 62 ASSERT(m_isolate); |
| 63 ASSERT(!m_creationContext.IsEmpty()); | 63 ASSERT(!m_creationContext.IsEmpty()); |
| 64 | 64 |
| 65 // SecurityError is thrown via ::throwSecurityError, and _careful_ considera
tion must be given to the data exposed to JavaScript via the 'sanitizedMessage'. | 65 // SecurityError is thrown via ::throwSecurityError, and _careful_ considera
tion must be given to the data exposed to JavaScript via the 'sanitizedMessage'. |
| 66 ASSERT(ec != SecurityError); | 66 ASSERT(ec != SecurityError); |
| 67 | 67 |
| 68 m_code = ec; | 68 m_code = ec; |
| 69 String processedMessage = addExceptionContext(message); | 69 String processedMessage = addExceptionContext(message); |
| 70 m_message = processedMessage; | 70 m_message = processedMessage; |
| 71 setException(V8ThrowException::createDOMException(m_isolate, ec, processedMe
ssage, m_creationContext)); | 71 setException(V8ThrowException::createDOMException(m_isolate, ec, processedMe
ssage)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void ExceptionState::throwSecurityError(const String& sanitizedMessage, const St
ring& unsanitizedMessage) | 74 void ExceptionState::throwSecurityError(const String& sanitizedMessage, const St
ring& unsanitizedMessage) |
| 75 { | 75 { |
| 76 ASSERT(m_isolate); | 76 ASSERT(m_isolate); |
| 77 ASSERT(!m_creationContext.IsEmpty()); | 77 ASSERT(!m_creationContext.IsEmpty()); |
| 78 m_code = SecurityError; | 78 m_code = SecurityError; |
| 79 String finalSanitized = addExceptionContext(sanitizedMessage); | 79 String finalSanitized = addExceptionContext(sanitizedMessage); |
| 80 m_message = finalSanitized; | 80 m_message = finalSanitized; |
| 81 String finalUnsanitized = addExceptionContext(unsanitizedMessage); | 81 String finalUnsanitized = addExceptionContext(unsanitizedMessage); |
| 82 | 82 |
| 83 setException(V8ThrowException::createDOMException(m_isolate, SecurityError,
finalSanitized, finalUnsanitized, m_creationContext)); | 83 setException(V8ThrowException::createDOMException(m_isolate, SecurityError,
finalSanitized, finalUnsanitized)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ExceptionState::setException(v8::Local<v8::Value> exception) | 86 void ExceptionState::setException(v8::Local<v8::Value> exception) |
| 87 { | 87 { |
| 88 // FIXME: Assert that exception is not empty? | 88 // FIXME: Assert that exception is not empty? |
| 89 if (exception.IsEmpty()) { | 89 if (exception.IsEmpty()) { |
| 90 clearException(); | 90 clearException(); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 m_exception.set(m_isolate, exception); | 94 m_exception.set(m_isolate, exception); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void ExceptionState::throwException() | 97 void ExceptionState::throwException() |
| 98 { | 98 { |
| 99 ASSERT(!m_exception.isEmpty()); | 99 ASSERT(!m_exception.isEmpty()); |
| 100 V8ThrowException::throwException(m_exception.newLocal(m_isolate), m_isolate)
; | 100 V8ThrowException::throwException(m_isolate, m_exception.newLocal(m_isolate))
; |
| 101 } | 101 } |
| 102 | 102 |
| 103 void ExceptionState::throwTypeError(const String& message) | 103 void ExceptionState::throwTypeError(const String& message) |
| 104 { | 104 { |
| 105 ASSERT(m_isolate); | 105 ASSERT(m_isolate); |
| 106 m_code = V8TypeError; | 106 m_code = V8TypeError; |
| 107 m_message = message; | 107 m_message = message; |
| 108 setException(V8ThrowException::createTypeError(m_isolate, addExceptionContex
t(message))); | 108 setException(V8ThrowException::createTypeError(m_isolate, addExceptionContex
t(message))); |
| 109 } | 109 } |
| 110 | 110 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 processedMessage = ExceptionMessages::failedToDeleteIndexed(interfac
eName(), message); | 192 processedMessage = ExceptionMessages::failedToDeleteIndexed(interfac
eName(), message); |
| 193 else if (m_context == IndexedGetterContext) | 193 else if (m_context == IndexedGetterContext) |
| 194 processedMessage = ExceptionMessages::failedToGetIndexed(interfaceNa
me(), message); | 194 processedMessage = ExceptionMessages::failedToGetIndexed(interfaceNa
me(), message); |
| 195 else if (m_context == IndexedSetterContext) | 195 else if (m_context == IndexedSetterContext) |
| 196 processedMessage = ExceptionMessages::failedToSetIndexed(interfaceNa
me(), message); | 196 processedMessage = ExceptionMessages::failedToSetIndexed(interfaceNa
me(), message); |
| 197 } | 197 } |
| 198 return processedMessage; | 198 return processedMessage; |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace blink | 201 } // namespace blink |
| OLD | NEW |