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 "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/PrivateScriptRunner.h" | 6 #include "bindings/core/v8/PrivateScriptRunner.h" |
7 | 7 |
8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 String messageString; | 235 String messageString; |
236 if (!message.IsEmpty() && message->IsString()) | 236 if (!message.IsEmpty() && message->IsString()) |
237 messageString = toCoreString(v8::Handle<v8::String>::Cast(message)); | 237 messageString = toCoreString(v8::Handle<v8::String>::Cast(message)); |
238 | 238 |
239 String exceptionName = toCoreString(v8::Handle<v8::String>::Cast(name)); | 239 String exceptionName = toCoreString(v8::Handle<v8::String>::Cast(name)); |
240 if (exceptionName == "PrivateScriptException") { | 240 if (exceptionName == "PrivateScriptException") { |
241 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "cod
e")); | 241 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "cod
e")); |
242 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); | 242 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); |
243 ScriptState::Scope scope(scriptStateInUserScript); | 243 ScriptState::Scope scope(scriptStateInUserScript); |
244 ExceptionState exceptionState(errorContext, propertyName, interfaceName,
scriptStateInUserScript->context()->Global(), scriptStateInUserScript->isolate(
)); | 244 ExceptionState exceptionState(errorContext, propertyName, interfaceName,
scriptStateInUserScript->context()->Global(), scriptStateInUserScript->isolate(
)); |
245 exceptionState.throwDOMException(toInt32(code), messageString); | 245 exceptionState.throwDOMException(toInt32(isolate, code), messageString); |
246 exceptionState.throwIfNeeded(); | 246 exceptionState.throwIfNeeded(); |
247 return; | 247 return; |
248 } | 248 } |
249 | 249 |
250 // Standard JS errors thrown by a private script are treated as real errors | 250 // Standard JS errors thrown by a private script are treated as real errors |
251 // of the private script and crash the renderer, except for a stack overflow | 251 // of the private script and crash the renderer, except for a stack overflow |
252 // error. A stack overflow error can happen in a valid private script | 252 // error. A stack overflow error can happen in a valid private script |
253 // if user's script can create a recursion that involves the private script. | 253 // if user's script can create a recursion that involves the private script. |
254 if (exceptionName == "RangeError" && messageString.contains("Maximum call st
ack size exceeded")) { | 254 if (exceptionName == "RangeError" && messageString.contains("Maximum call st
ack size exceeded")) { |
255 ScriptState::Scope scope(scriptStateInUserScript); | 255 ScriptState::Scope scope(scriptStateInUserScript); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 v8::Handle<v8::Value> result = V8ScriptRunner::callFunction(v8::Handle<v8::F
unction>::Cast(method), scriptState->executionContext(), holder, argc, argv, scr
iptState->isolate()); | 330 v8::Handle<v8::Value> result = V8ScriptRunner::callFunction(v8::Handle<v8::F
unction>::Cast(method), scriptState->executionContext(), holder, argc, argv, scr
iptState->isolate()); |
331 if (block.HasCaught()) { | 331 if (block.HasCaught()) { |
332 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); | 332 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); |
333 block.ReThrow(); | 333 block.ReThrow(); |
334 return v8::Handle<v8::Value>(); | 334 return v8::Handle<v8::Value>(); |
335 } | 335 } |
336 return result; | 336 return result; |
337 } | 337 } |
338 | 338 |
339 } // namespace blink | 339 } // namespace blink |
OLD | NEW |