OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 v8::Local<v8::Signature> signature, | 298 v8::Local<v8::Signature> signature, |
299 const Configuration& method, | 299 const Configuration& method, |
300 const DOMWrapperWorld& world) { | 300 const DOMWrapperWorld& world) { |
301 if (method.exposeConfiguration == | 301 if (method.exposeConfiguration == |
302 V8DOMConfiguration::OnlyExposedToPrivateScript && | 302 V8DOMConfiguration::OnlyExposedToPrivateScript && |
303 !world.isPrivateScriptIsolatedWorld()) | 303 !world.isPrivateScriptIsolatedWorld()) |
304 return; | 304 return; |
305 | 305 |
306 v8::Local<v8::Name> name = method.methodName(isolate); | 306 v8::Local<v8::Name> name = method.methodName(isolate); |
307 v8::FunctionCallback callback = method.callbackForWorld(world); | 307 v8::FunctionCallback callback = method.callbackForWorld(world); |
| 308 // Promise-returning DOM operations need to return a reject promise when |
| 309 // an exception occurs. This includes a case that the receiver object is not |
| 310 // of the type. So, we disable the type check of the receiver object on V8 |
| 311 // side so that V8 won't throw. Instead, we do the check on Blink side and |
| 312 // convert an exception to a reject promise. |
| 313 if (method.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) |
| 314 signature = v8::Local<v8::Signature>(); |
308 | 315 |
309 DCHECK(method.propertyLocationConfiguration); | 316 DCHECK(method.propertyLocationConfiguration); |
310 if (method.propertyLocationConfiguration & | 317 if (method.propertyLocationConfiguration & |
311 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { | 318 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { |
312 v8::Local<v8::FunctionTemplate> functionTemplate = | 319 v8::Local<v8::FunctionTemplate> functionTemplate = |
313 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), | 320 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), |
314 signature, method.length); | 321 signature, method.length); |
315 functionTemplate->RemovePrototype(); | 322 functionTemplate->RemovePrototype(); |
316 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInstance) | 323 if (method.propertyLocationConfiguration & V8DOMConfiguration::OnInstance) |
317 instanceTemplate->Set( | 324 instanceTemplate->Set( |
(...skipping 26 matching lines...) Expand all Loading... |
344 v8::Local<v8::Signature> signature, | 351 v8::Local<v8::Signature> signature, |
345 const V8DOMConfiguration::MethodConfiguration& method, | 352 const V8DOMConfiguration::MethodConfiguration& method, |
346 const DOMWrapperWorld& world) { | 353 const DOMWrapperWorld& world) { |
347 if (method.exposeConfiguration == | 354 if (method.exposeConfiguration == |
348 V8DOMConfiguration::OnlyExposedToPrivateScript && | 355 V8DOMConfiguration::OnlyExposedToPrivateScript && |
349 !world.isPrivateScriptIsolatedWorld()) | 356 !world.isPrivateScriptIsolatedWorld()) |
350 return; | 357 return; |
351 | 358 |
352 v8::Local<v8::Name> name = method.methodName(isolate); | 359 v8::Local<v8::Name> name = method.methodName(isolate); |
353 v8::FunctionCallback callback = method.callbackForWorld(world); | 360 v8::FunctionCallback callback = method.callbackForWorld(world); |
| 361 // Promise-returning DOM operations need to return a reject promise when |
| 362 // an exception occurs. This includes a case that the receiver object is not |
| 363 // of the type. So, we disable the type check of the receiver object on V8 |
| 364 // side so that V8 won't throw. Instead, we do the check on Blink side and |
| 365 // convert an exception to a reject promise. |
| 366 if (method.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) |
| 367 signature = v8::Local<v8::Signature>(); |
354 | 368 |
355 DCHECK(method.propertyLocationConfiguration); | 369 DCHECK(method.propertyLocationConfiguration); |
356 if (method.propertyLocationConfiguration & | 370 if (method.propertyLocationConfiguration & |
357 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { | 371 (V8DOMConfiguration::OnInstance | V8DOMConfiguration::OnPrototype)) { |
358 v8::Local<v8::FunctionTemplate> functionTemplate = | 372 v8::Local<v8::FunctionTemplate> functionTemplate = |
359 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), | 373 v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), |
360 signature, method.length); | 374 signature, method.length); |
361 functionTemplate->RemovePrototype(); | 375 functionTemplate->RemovePrototype(); |
362 v8::Local<v8::Function> function = | 376 v8::Local<v8::Function> function = |
363 functionTemplate->GetFunction(isolate->GetCurrentContext()) | 377 functionTemplate->GetFunction(isolate->GetCurrentContext()) |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 void V8DOMConfiguration::setClassString( | 616 void V8DOMConfiguration::setClassString( |
603 v8::Isolate* isolate, | 617 v8::Isolate* isolate, |
604 v8::Local<v8::ObjectTemplate> objectTemplate, | 618 v8::Local<v8::ObjectTemplate> objectTemplate, |
605 const char* classString) { | 619 const char* classString) { |
606 objectTemplate->Set( | 620 objectTemplate->Set( |
607 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), | 621 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), |
608 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); | 622 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); |
609 } | 623 } |
610 | 624 |
611 } // namespace blink | 625 } // namespace blink |
OLD | NEW |