OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/PrivateScriptRunner.h" | 5 #include "bindings/core/v8/PrivateScriptRunner.h" |
6 | 6 |
7 #include "bindings/core/v8/DOMWrapperWorld.h" | 7 #include "bindings/core/v8/DOMWrapperWorld.h" |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
10 #include "bindings/core/v8/V8PerContextData.h" | 10 #include "bindings/core/v8/V8PerContextData.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 messageString = toCoreString(v8::Local<v8::String>::Cast(message)); | 260 messageString = toCoreString(v8::Local<v8::String>::Cast(message)); |
261 | 261 |
262 String exceptionName = toCoreString(v8::Local<v8::String>::Cast(name)); | 262 String exceptionName = toCoreString(v8::Local<v8::String>::Cast(name)); |
263 if (exceptionName == "PrivateScriptException") { | 263 if (exceptionName == "PrivateScriptException") { |
264 v8::Local<v8::Value> code = exceptionObject->Get(context, v8String(isola
te, "code")).ToLocalChecked(); | 264 v8::Local<v8::Value> code = exceptionObject->Get(context, v8String(isola
te, "code")).ToLocalChecked(); |
265 RELEASE_ASSERT(code->IsInt32()); | 265 RELEASE_ASSERT(code->IsInt32()); |
266 int exceptionCode = code.As<v8::Int32>()->Value(); | 266 int exceptionCode = code.As<v8::Int32>()->Value(); |
267 ScriptState::Scope scope(scriptStateInUserScript); | 267 ScriptState::Scope scope(scriptStateInUserScript); |
268 ExceptionState exceptionState(errorContext, propertyName, interfaceName,
context->Global(), scriptStateInUserScript->isolate()); | 268 ExceptionState exceptionState(errorContext, propertyName, interfaceName,
context->Global(), scriptStateInUserScript->isolate()); |
269 exceptionState.throwDOMException(exceptionCode, messageString); | 269 exceptionState.throwDOMException(exceptionCode, messageString); |
270 exceptionState.throwIfNeeded(); | |
271 return; | 270 return; |
272 } | 271 } |
273 | 272 |
274 // Standard JS errors thrown by a private script are treated as real errors | 273 // Standard JS errors thrown by a private script are treated as real errors |
275 // of the private script and crash the renderer, except for a stack overflow | 274 // of the private script and crash the renderer, except for a stack overflow |
276 // error. A stack overflow error can happen in a valid private script | 275 // error. A stack overflow error can happen in a valid private script |
277 // if user's script can create a recursion that involves the private script. | 276 // if user's script can create a recursion that involves the private script. |
278 if (exceptionName == "RangeError" && messageString.contains("Maximum call st
ack size exceeded")) { | 277 if (exceptionName == "RangeError" && messageString.contains("Maximum call st
ack size exceeded")) { |
279 ScriptState::Scope scope(scriptStateInUserScript); | 278 ScriptState::Scope scope(scriptStateInUserScript); |
280 ExceptionState exceptionState(errorContext, propertyName, interfaceName,
scriptStateInUserScript->context()->Global(), scriptStateInUserScript->isolate(
)); | 279 ExceptionState exceptionState(errorContext, propertyName, interfaceName,
scriptStateInUserScript->context()->Global(), scriptStateInUserScript->isolate(
)); |
281 exceptionState.throwDOMException(V8RangeError, messageString); | 280 exceptionState.throwDOMException(V8RangeError, messageString); |
282 exceptionState.throwIfNeeded(); | |
283 return; | 281 return; |
284 } | 282 } |
285 | 283 |
286 fprintf(stderr, "Private script error: %s was thrown.\n", exceptionName.utf8
().data()); | 284 fprintf(stderr, "Private script error: %s was thrown.\n", exceptionName.utf8
().data()); |
287 dumpV8Message(context, tryCatchMessage); | 285 dumpV8Message(context, tryCatchMessage); |
288 RELEASE_NOTREACHED(); | 286 RELEASE_NOTREACHED(); |
289 } | 287 } |
290 | 288 |
291 } // namespace | 289 } // namespace |
292 | 290 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 v8::Local<v8::Value> result; | 352 v8::Local<v8::Value> result; |
355 if (!V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(method), scr
iptState->getExecutionContext(), holder, argc, argv, scriptState->isolate()).ToL
ocal(&result)) { | 353 if (!V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(method), scr
iptState->getExecutionContext(), holder, argc, argv, scriptState->isolate()).ToL
ocal(&result)) { |
356 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); | 354 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); |
357 block.ReThrow(); | 355 block.ReThrow(); |
358 return v8::Local<v8::Value>(); | 356 return v8::Local<v8::Value>(); |
359 } | 357 } |
360 return result; | 358 return result; |
361 } | 359 } |
362 | 360 |
363 } // namespace blink | 361 } // namespace blink |
OLD | NEW |