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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "bindings/v8/ExceptionState.h" | 32 #include "bindings/v8/ExceptionState.h" |
33 | 33 |
| 34 #include "bindings/v8/ExceptionMessages.h" |
34 #include "bindings/v8/V8ThrowException.h" | 35 #include "bindings/v8/V8ThrowException.h" |
35 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
36 | 37 |
37 namespace WebCore { | 38 namespace WebCore { |
38 | 39 |
39 void ExceptionState::clearException() | 40 void ExceptionState::clearException() |
40 { | 41 { |
41 m_code = 0; | 42 m_code = 0; |
42 m_exception.clear(); | 43 m_exception.clear(); |
43 } | 44 } |
44 | 45 |
45 void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me
ssage) | 46 void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me
ssage) |
46 { | 47 { |
47 ASSERT(ec); | 48 ASSERT(ec); |
48 ASSERT(m_isolate); | 49 ASSERT(m_isolate); |
49 | 50 |
50 // SecurityError is thrown via ::throwSecurityError, and _careful_ considera
tion must be given to the data exposed to JavaScript via the 'sanitizedMessage'. | 51 // SecurityError is thrown via ::throwSecurityError, and _careful_ considera
tion must be given to the data exposed to JavaScript via the 'sanitizedMessage'. |
51 ASSERT(ec != SecurityError); | 52 ASSERT(ec != SecurityError); |
52 | 53 |
| 54 String processedMessage = message; |
| 55 if (propertyName() && interfaceName() && m_context != UnknownContext) { |
| 56 if (m_context == DeletionContext) |
| 57 processedMessage = ExceptionMessages::failedToDelete(propertyName(),
interfaceName(), message); |
| 58 else if (m_context == ExecutionContext) |
| 59 processedMessage = ExceptionMessages::failedToExecute(propertyName()
, interfaceName(), message); |
| 60 else if (m_context == GetterContext) |
| 61 processedMessage = ExceptionMessages::failedToGet(propertyName(), in
terfaceName(), message); |
| 62 else if (m_context == SetterContext) |
| 63 processedMessage = ExceptionMessages::failedToSet(propertyName(), in
terfaceName(), message); |
| 64 } else if (!propertyName() && interfaceName() && m_context == ConstructionCo
ntext) { |
| 65 processedMessage = ExceptionMessages::failedToConstruct(interfaceName(),
message); |
| 66 } |
| 67 |
53 m_code = ec; | 68 m_code = ec; |
54 setException(V8ThrowException::createDOMException(ec, message, m_creationCon
text, m_isolate)); | 69 setException(V8ThrowException::createDOMException(ec, processedMessage, m_cr
eationContext, m_isolate)); |
55 } | 70 } |
56 | 71 |
57 void ExceptionState::throwSecurityError(const String& sanitizedMessage, const St
ring& unsanitizedMessage) | 72 void ExceptionState::throwSecurityError(const String& sanitizedMessage, const St
ring& unsanitizedMessage) |
58 { | 73 { |
59 ASSERT(m_isolate); | 74 ASSERT(m_isolate); |
60 m_code = SecurityError; | 75 m_code = SecurityError; |
61 setException(V8ThrowException::createDOMException(SecurityError, sanitizedMe
ssage, unsanitizedMessage, m_creationContext, m_isolate)); | 76 setException(V8ThrowException::createDOMException(SecurityError, sanitizedMe
ssage, unsanitizedMessage, m_creationContext, m_isolate)); |
62 } | 77 } |
63 | 78 |
64 void ExceptionState::setException(v8::Handle<v8::Value> exception) | 79 void ExceptionState::setException(v8::Handle<v8::Value> exception) |
(...skipping 23 matching lines...) Expand all Loading... |
88 { | 103 { |
89 m_code = TypeError; | 104 m_code = TypeError; |
90 } | 105 } |
91 | 106 |
92 void TrackExceptionState::throwSecurityError(const String&, const String&) | 107 void TrackExceptionState::throwSecurityError(const String&, const String&) |
93 { | 108 { |
94 m_code = SecurityError; | 109 m_code = SecurityError; |
95 } | 110 } |
96 | 111 |
97 } // namespace WebCore | 112 } // namespace WebCore |
OLD | NEW |