Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 throwTypeError(String(message)); | 54 throwTypeError(String(message)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ExceptionState::throwDOMException(ExceptionCode ec, | 57 void ExceptionState::throwDOMException(ExceptionCode ec, |
| 58 const String& message) { | 58 const String& message) { |
| 59 // SecurityError is thrown via ::throwSecurityError, and _careful_ | 59 // SecurityError is thrown via ::throwSecurityError, and _careful_ |
| 60 // consideration must be given to the data exposed to JavaScript via the | 60 // consideration must be given to the data exposed to JavaScript via the |
| 61 // 'sanitizedMessage'. | 61 // 'sanitizedMessage'. |
| 62 DCHECK(ec != SecurityError); | 62 DCHECK(ec != SecurityError); |
| 63 | 63 |
| 64 const String& processedMessage = addExceptionContext(message); | 64 const String& processedMessage = addExceptionContext(message); |
|
dcheng
2017/02/25 12:02:35
The alternative here is to consult a new policy vi
| |
| 65 setException(ec, processedMessage, V8ThrowException::createDOMException( | 65 setException(ec, processedMessage, V8ThrowException::createDOMException( |
| 66 m_isolate, ec, processedMessage)); | 66 m_isolate, ec, processedMessage)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void ExceptionState::throwRangeError(const String& message) { | 69 void ExceptionState::throwRangeError(const String& message) { |
| 70 setException(V8RangeError, message, | 70 setException(V8RangeError, message, |
| 71 V8ThrowException::createRangeError( | 71 V8ThrowException::createRangeError( |
| 72 m_isolate, addExceptionContext(message))); | 72 m_isolate, addExceptionContext(message))); |
| 73 } | 73 } |
| 74 | 74 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 : ExceptionState(nullptr, ExceptionState::UnknownContext, nullptr, nullptr), | 165 : ExceptionState(nullptr, ExceptionState::UnknownContext, nullptr, nullptr), |
| 166 m_file(""), | 166 m_file(""), |
| 167 m_line(0) {} | 167 m_line(0) {} |
| 168 | 168 |
| 169 NonThrowableExceptionState::NonThrowableExceptionState(const char* file, | 169 NonThrowableExceptionState::NonThrowableExceptionState(const char* file, |
| 170 int line) | 170 int line) |
| 171 : ExceptionState(nullptr, ExceptionState::UnknownContext, nullptr, nullptr), | 171 : ExceptionState(nullptr, ExceptionState::UnknownContext, nullptr, nullptr), |
| 172 m_file(file), | 172 m_file(file), |
| 173 m_line(line) {} | 173 m_line(line) {} |
| 174 | 174 |
| 175 void NonThrowableExceptionState::throwDOMException(ExceptionCode ec, | 175 void NonThrowableExceptionState::setException(ExceptionCode ec, |
| 176 const String& message) { | 176 const String& message, |
| 177 DCHECK_AT(false, m_file, m_line) << "DOMExeption should not be thrown."; | 177 v8::Local<v8::Value> exception) { |
| 178 } | |
| 179 | |
| 180 void NonThrowableExceptionState::throwRangeError(const String& message) { | |
| 181 DCHECK_AT(false, m_file, m_line) << "RangeError should not be thrown."; | |
| 182 } | |
| 183 | |
| 184 void NonThrowableExceptionState::throwSecurityError( | |
| 185 const String& sanitizedMessage, | |
| 186 const String&) { | |
| 187 DCHECK_AT(false, m_file, m_line) << "SecurityError should not be thrown."; | |
| 188 } | |
| 189 | |
| 190 void NonThrowableExceptionState::throwTypeError(const String& message) { | |
| 191 DCHECK_AT(false, m_file, m_line) << "TypeError should not be thrown."; | |
| 192 } | |
| 193 | |
| 194 void NonThrowableExceptionState::rethrowV8Exception(v8::Local<v8::Value>) { | |
| 195 DCHECK_AT(false, m_file, m_line) << "An exception should not be rethrown."; | 178 DCHECK_AT(false, m_file, m_line) << "An exception should not be rethrown."; |
| 196 } | 179 } |
| 197 | 180 |
| 198 void DummyExceptionStateForTesting::throwDOMException(ExceptionCode ec, | 181 void DummyExceptionStateForTesting::setException( |
| 199 const String& message) { | 182 ExceptionCode ec, |
| 200 setException(ec, message, v8::Local<v8::Value>()); | 183 const String& message, |
| 201 } | 184 v8::Local<v8::Value> exception) { |
| 202 | 185 // Ignored. |
| 203 void DummyExceptionStateForTesting::throwRangeError(const String& message) { | |
| 204 setException(V8RangeError, message, v8::Local<v8::Value>()); | |
| 205 } | |
| 206 | |
| 207 void DummyExceptionStateForTesting::throwSecurityError( | |
| 208 const String& sanitizedMessage, | |
| 209 const String&) { | |
| 210 setException(SecurityError, sanitizedMessage, v8::Local<v8::Value>()); | |
| 211 } | |
| 212 | |
| 213 void DummyExceptionStateForTesting::throwTypeError(const String& message) { | |
| 214 setException(V8TypeError, message, v8::Local<v8::Value>()); | |
| 215 } | |
| 216 | |
| 217 void DummyExceptionStateForTesting::rethrowV8Exception(v8::Local<v8::Value>) { | |
| 218 setException(kRethrownException, String(), v8::Local<v8::Value>()); | |
| 219 } | 186 } |
| 220 | 187 |
| 221 } // namespace blink | 188 } // namespace blink |
| OLD | NEW |