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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 v8::Handle<v8::Message> tryCatchMessage = block.Message(); | 233 v8::Handle<v8::Message> tryCatchMessage = block.Message(); |
234 v8::Handle<v8::Value> message = exceptionObject->Get(v8String(isolate, "mess
age")); | 234 v8::Handle<v8::Value> message = exceptionObject->Get(v8String(isolate, "mess
age")); |
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 NonThrowableExceptionState nonThrowableExceptionState; |
| 244 int exceptionCode = toInt32(isolate, code, NormalConversion, nonThrowabl
eExceptionState); |
243 ScriptState::Scope scope(scriptStateInUserScript); | 245 ScriptState::Scope scope(scriptStateInUserScript); |
244 ExceptionState exceptionState(errorContext, propertyName, interfaceName,
scriptStateInUserScript->context()->Global(), scriptStateInUserScript->isolate(
)); | 246 ExceptionState exceptionState(errorContext, propertyName, interfaceName,
scriptStateInUserScript->context()->Global(), scriptStateInUserScript->isolate(
)); |
245 exceptionState.throwDOMException(toInt32(isolate, code), messageString); | 247 exceptionState.throwDOMException(exceptionCode, messageString); |
246 exceptionState.throwIfNeeded(); | 248 exceptionState.throwIfNeeded(); |
247 return; | 249 return; |
248 } | 250 } |
249 | 251 |
250 // Standard JS errors thrown by a private script are treated as real errors | 252 // 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 | 253 // 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 | 254 // 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. | 255 // 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")) { | 256 if (exceptionName == "RangeError" && messageString.contains("Maximum call st
ack size exceeded")) { |
255 ScriptState::Scope scope(scriptStateInUserScript); | 257 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()); | 332 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()) { | 333 if (block.HasCaught()) { |
332 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); | 334 rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptSta
teInUserScript, ExceptionState::ExecutionContext, methodName, className); |
333 block.ReThrow(); | 335 block.ReThrow(); |
334 return v8::Handle<v8::Value>(); | 336 return v8::Handle<v8::Value>(); |
335 } | 337 } |
336 return result; | 338 return result; |
337 } | 339 } |
338 | 340 |
339 } // namespace blink | 341 } // namespace blink |
OLD | NEW |