Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp

Issue 1952893003: Implement custom element construction and some 'define' checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use DCHECK, revert RuntimeEnabledFeatures.in. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 void ExceptionState::reject(ScriptPromiseResolver* resolver) 53 void ExceptionState::reject(ScriptPromiseResolver* resolver)
54 { 54 {
55 resolver->reject(m_exception.newLocal(resolver->getScriptState()->isolate()) ); 55 resolver->reject(m_exception.newLocal(resolver->getScriptState()->isolate()) );
56 clearException(); 56 clearException();
57 } 57 }
58 58
59 void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me ssage) 59 void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me ssage)
60 { 60 {
61 ASSERT(ec); 61 DCHECK(ec);
62 ASSERT(m_isolate); 62 DCHECK(m_isolate);
63 ASSERT(!m_creationContext.IsEmpty()); 63 DCHECK(!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 DCHECK(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, m_creationContext));
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 DCHECK(m_isolate);
77 ASSERT(!m_creationContext.IsEmpty()); 77 DCHECK(!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, m_creationContext));
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 DCHECK(!m_exception.isEmpty());
100 V8ThrowException::throwException(m_exception.newLocal(m_isolate), m_isolate) ; 100 V8ThrowException::throwException(m_exception.newLocal(m_isolate), 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 DCHECK(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
111 void ExceptionState::throwSyntaxError(const String& message)
112 {
113 DCHECK(m_isolate);
114 m_code = V8SyntaxError;
115 m_message = message;
116 setException(V8ThrowException::createSyntaxError(m_isolate, addExceptionCont ext(message)));
117 }
118
111 void ExceptionState::throwRangeError(const String& message) 119 void ExceptionState::throwRangeError(const String& message)
112 { 120 {
113 ASSERT(m_isolate); 121 DCHECK(m_isolate);
114 m_code = V8RangeError; 122 m_code = V8RangeError;
115 m_message = message; 123 m_message = message;
116 setException(V8ThrowException::createRangeError(m_isolate, addExceptionConte xt(message))); 124 setException(V8ThrowException::createRangeError(m_isolate, addExceptionConte xt(message)));
117 } 125 }
118 126
119 void NonThrowableExceptionState::throwDOMException(const ExceptionCode& ec, cons t String& message) 127 void NonThrowableExceptionState::throwDOMException(const ExceptionCode& ec, cons t String& message)
120 { 128 {
121 ASSERT_NOT_REACHED(); 129 NOTREACHED();
122 m_code = ec; 130 m_code = ec;
123 m_message = message; 131 m_message = message;
124 } 132 }
125 133
126 void NonThrowableExceptionState::throwTypeError(const String& message) 134 void NonThrowableExceptionState::throwTypeError(const String& message)
127 { 135 {
128 ASSERT_NOT_REACHED(); 136 NOTREACHED();
129 m_code = V8TypeError; 137 m_code = V8TypeError;
130 m_message = message; 138 m_message = message;
131 } 139 }
132 140
133 void NonThrowableExceptionState::throwSecurityError(const String& sanitizedMessa ge, const String&) 141 void NonThrowableExceptionState::throwSecurityError(const String& sanitizedMessa ge, const String&)
134 { 142 {
135 ASSERT_NOT_REACHED(); 143 NOTREACHED();
136 m_code = SecurityError; 144 m_code = SecurityError;
137 m_message = sanitizedMessage; 145 m_message = sanitizedMessage;
138 } 146 }
139 147
148 void NonThrowableExceptionState::throwSyntaxError(const String& message)
149 {
150 NOTREACHED();
151 m_code = V8SyntaxError;
152 m_message = message;
153 }
154
140 void NonThrowableExceptionState::throwRangeError(const String& message) 155 void NonThrowableExceptionState::throwRangeError(const String& message)
141 { 156 {
142 ASSERT_NOT_REACHED(); 157 NOTREACHED();
143 m_code = V8RangeError; 158 m_code = V8RangeError;
144 m_message = message; 159 m_message = message;
145 } 160 }
146 161
147 void TrackExceptionState::throwDOMException(const ExceptionCode& ec, const Strin g& message) 162 void TrackExceptionState::throwDOMException(const ExceptionCode& ec, const Strin g& message)
148 { 163 {
149 m_code = ec; 164 m_code = ec;
150 m_message = message; 165 m_message = message;
151 } 166 }
152 167
153 void TrackExceptionState::throwTypeError(const String& message) 168 void TrackExceptionState::throwTypeError(const String& message)
154 { 169 {
155 m_code = V8TypeError; 170 m_code = V8TypeError;
156 m_message = message; 171 m_message = message;
157 } 172 }
158 173
159 void TrackExceptionState::throwSecurityError(const String& sanitizedMessage, con st String&) 174 void TrackExceptionState::throwSecurityError(const String& sanitizedMessage, con st String&)
160 { 175 {
161 m_code = SecurityError; 176 m_code = SecurityError;
162 m_message = sanitizedMessage; 177 m_message = sanitizedMessage;
163 } 178 }
164 179
180 void TrackExceptionState::throwSyntaxError(const String& message)
181 {
182 m_code = V8SyntaxError;
183 m_message = message;
184 }
185
165 void TrackExceptionState::throwRangeError(const String& message) 186 void TrackExceptionState::throwRangeError(const String& message)
166 { 187 {
167 m_code = V8RangeError; 188 m_code = V8RangeError;
168 m_message = message; 189 m_message = message;
169 } 190 }
170 191
171 String ExceptionState::addExceptionContext(const String& message) const 192 String ExceptionState::addExceptionContext(const String& message) const
172 { 193 {
173 if (message.isEmpty()) 194 if (message.isEmpty())
174 return message; 195 return message;
(...skipping 17 matching lines...) Expand all
192 processedMessage = ExceptionMessages::failedToDeleteIndexed(interfac eName(), message); 213 processedMessage = ExceptionMessages::failedToDeleteIndexed(interfac eName(), message);
193 else if (m_context == IndexedGetterContext) 214 else if (m_context == IndexedGetterContext)
194 processedMessage = ExceptionMessages::failedToGetIndexed(interfaceNa me(), message); 215 processedMessage = ExceptionMessages::failedToGetIndexed(interfaceNa me(), message);
195 else if (m_context == IndexedSetterContext) 216 else if (m_context == IndexedSetterContext)
196 processedMessage = ExceptionMessages::failedToSetIndexed(interfaceNa me(), message); 217 processedMessage = ExceptionMessages::failedToSetIndexed(interfaceNa me(), message);
197 } 218 }
198 return processedMessage; 219 return processedMessage;
199 } 220 }
200 221
201 } // namespace blink 222 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698