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