Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: Source/bindings/core/v8/PrivateScriptRunner.cpp

Issue 1011093002: [bindings] Pass NormalConversion to to[U]Int{8/16/32/64}(...) in v8_types.py and reduce conversion … (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing after review comments! :) Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698