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

Side by Side Diff: Source/bindings/tests/results/V8TestInterface.cpp

Issue 68563003: Create DOM exceptions in the correct context. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased onto df9a982fbe97 Created 7 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 557 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
558 } 558 }
559 559
560 static void implementsMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& i nfo) 560 static void implementsMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& i nfo)
561 { 561 {
562 if (UNLIKELY(info.Length() < 2)) { 562 if (UNLIKELY(info.Length() < 2)) {
563 throwTypeError(ExceptionMessages::failedToExecute("implementsMethod2", " TestInterface", ExceptionMessages::notEnoughArguments(2, info.Length())), info.G etIsolate()); 563 throwTypeError(ExceptionMessages::failedToExecute("implementsMethod2", " TestInterface", ExceptionMessages::notEnoughArguments(2, info.Length())), info.G etIsolate());
564 return; 564 return;
565 } 565 }
566 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 566 TestInterface* imp = V8TestInterface::toNative(info.Holder());
567 ExceptionState exceptionState(info.GetIsolate()); 567 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
568 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); 568 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]);
569 V8TRYCATCH_VOID(TestObj*, objArg, V8TestObject::hasInstance(info[1], info.Ge tIsolate(), worldType(info.GetIsolate())) ? V8TestObject::toNative(v8::Handle<v8 ::Object>::Cast(info[1])) : 0); 569 V8TRYCATCH_VOID(TestObj*, objArg, V8TestObject::hasInstance(info[1], info.Ge tIsolate(), worldType(info.GetIsolate())) ? V8TestObject::toNative(v8::Handle<v8 ::Object>::Cast(info[1])) : 0);
570 ExecutionContext* scriptContext = getExecutionContext(); 570 ExecutionContext* scriptContext = getExecutionContext();
571 RefPtr<TestObj> result = TestImplements::implementsMethod2(scriptContext, im p, strArg, objArg, exceptionState); 571 RefPtr<TestObj> result = TestImplements::implementsMethod2(scriptContext, im p, strArg, objArg, exceptionState);
572 if (exceptionState.throwIfNeeded()) 572 if (exceptionState.throwIfNeeded())
573 return; 573 return;
574 v8SetReturnValue(info, result.release()); 574 v8SetReturnValue(info, result.release());
575 } 575 }
576 576
577 static void implementsMethod2MethodCallback(const v8::FunctionCallbackInfo<v8::V alue>& info) 577 static void implementsMethod2MethodCallback(const v8::FunctionCallbackInfo<v8::V alue>& info)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 #endif // ENABLE(Condition11) || ENABLE(Condition12) 618 #endif // ENABLE(Condition11) || ENABLE(Condition12)
619 619
620 #if ENABLE(Condition11) || ENABLE(Condition12) 620 #if ENABLE(Condition11) || ENABLE(Condition12)
621 static void supplementalMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info) 621 static void supplementalMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info)
622 { 622 {
623 if (UNLIKELY(info.Length() < 2)) { 623 if (UNLIKELY(info.Length() < 2)) {
624 throwTypeError(ExceptionMessages::failedToExecute("supplementalMethod2", "TestInterface", ExceptionMessages::notEnoughArguments(2, info.Length())), info .GetIsolate()); 624 throwTypeError(ExceptionMessages::failedToExecute("supplementalMethod2", "TestInterface", ExceptionMessages::notEnoughArguments(2, info.Length())), info .GetIsolate());
625 return; 625 return;
626 } 626 }
627 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 627 TestInterface* imp = V8TestInterface::toNative(info.Holder());
628 ExceptionState exceptionState(info.GetIsolate()); 628 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
629 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); 629 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]);
630 V8TRYCATCH_VOID(TestObj*, objArg, V8TestObject::hasInstance(info[1], info.Ge tIsolate(), worldType(info.GetIsolate())) ? V8TestObject::toNative(v8::Handle<v8 ::Object>::Cast(info[1])) : 0); 630 V8TRYCATCH_VOID(TestObj*, objArg, V8TestObject::hasInstance(info[1], info.Ge tIsolate(), worldType(info.GetIsolate())) ? V8TestObject::toNative(v8::Handle<v8 ::Object>::Cast(info[1])) : 0);
631 ExecutionContext* scriptContext = getExecutionContext(); 631 ExecutionContext* scriptContext = getExecutionContext();
632 RefPtr<TestObj> result = TestPartialInterface::supplementalMethod2(scriptCon text, imp, strArg, objArg, exceptionState); 632 RefPtr<TestObj> result = TestPartialInterface::supplementalMethod2(scriptCon text, imp, strArg, objArg, exceptionState);
633 if (exceptionState.throwIfNeeded()) 633 if (exceptionState.throwIfNeeded())
634 return; 634 return;
635 v8SetReturnValue(info, result.release()); 635 v8SetReturnValue(info, result.release());
636 } 636 }
637 #endif // ENABLE(Condition11) || ENABLE(Condition12) 637 #endif // ENABLE(Condition11) || ENABLE(Condition12)
638 638
(...skipping 30 matching lines...) Expand all
669 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 669 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
670 } 670 }
671 #endif // ENABLE(Condition11) || ENABLE(Condition12) 671 #endif // ENABLE(Condition11) || ENABLE(Condition12)
672 672
673 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 673 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
674 { 674 {
675 if (UNLIKELY(info.Length() < 1)) { 675 if (UNLIKELY(info.Length() < 1)) {
676 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestIn terface", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsol ate()); 676 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestIn terface", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsol ate());
677 return; 677 return;
678 } 678 }
679 ExceptionState exceptionState(info.GetIsolate()); 679 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
680 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str1, info[0]); 680 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str1, info[0]);
681 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str2, info[1]); 681 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str2, info[1]);
682 682
683 ExecutionContext* context = getExecutionContext(); 683 ExecutionContext* context = getExecutionContext();
684 RefPtr<TestInterface> impl = TestInterface::create(context, str1, str2, exce ptionState); 684 RefPtr<TestInterface> impl = TestInterface::create(context, str1, str2, exce ptionState);
685 v8::Handle<v8::Object> wrapper = info.Holder(); 685 v8::Handle<v8::Object> wrapper = info.Holder();
686 if (exceptionState.throwIfNeeded()) 686 if (exceptionState.throwIfNeeded())
687 return; 687 return;
688 688
689 V8DOMWrapper::associateObjectWithWrapper<V8TestInterface>(impl.release(), &V 8TestInterface::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguratio n::Dependent); 689 V8DOMWrapper::associateObjectWithWrapper<V8TestInterface>(impl.release(), &V 8TestInterface::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguratio n::Dependent);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 729
730 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8 ::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) 730 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8 ::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)
731 { 731 {
732 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 732 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
733 V8TestInterface::namedPropertySetterCustom(name, jsValue, info); 733 V8TestInterface::namedPropertySetterCustom(name, jsValue, info);
734 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 734 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
735 } 735 }
736 736
737 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) 737 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo)
738 { 738 {
739 ExceptionState exceptionState(info.GetIsolate()); 739 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
740 TestInterface* collection = V8TestInterface::toNative(info.Holder()); 740 TestInterface* collection = V8TestInterface::toNative(info.Holder());
741 Vector<String> names; 741 Vector<String> names;
742 collection->namedPropertyEnumerator(names, exceptionState); 742 collection->namedPropertyEnumerator(names, exceptionState);
743 if (exceptionState.throwIfNeeded()) 743 if (exceptionState.throwIfNeeded())
744 return; 744 return;
745 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); 745 v8::Handle<v8::Array> v8names = v8::Array::New(names.size());
746 for (size_t i = 0; i < names.size(); ++i) 746 for (size_t i = 0; i < names.size(); ++i)
747 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate())); 747 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate()));
748 v8SetReturnValue(info, v8names); 748 v8SetReturnValue(info, v8names);
749 } 749 }
750 750
751 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info) 751 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info)
752 { 752 {
753 TestInterface* collection = V8TestInterface::toNative(info.Holder()); 753 TestInterface* collection = V8TestInterface::toNative(info.Holder());
754 AtomicString propertyName = toWebCoreAtomicString(name); 754 AtomicString propertyName = toWebCoreAtomicString(name);
755 ExceptionState exceptionState(info.GetIsolate()); 755 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
756 bool result = collection->namedPropertyQuery(propertyName, exceptionState); 756 bool result = collection->namedPropertyQuery(propertyName, exceptionState);
757 if (exceptionState.throwIfNeeded()) 757 if (exceptionState.throwIfNeeded())
758 return; 758 return;
759 if (!result) 759 if (!result)
760 return; 760 return;
761 v8SetReturnValueInt(info, v8::None); 761 v8SetReturnValueInt(info, v8::None);
762 } 762 }
763 763
764 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A rray>& info) 764 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A rray>& info)
765 { 765 {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 } 983 }
984 984
985 void V8TestInterface::derefObject(void* object) 985 void V8TestInterface::derefObject(void* object)
986 { 986 {
987 fromInternalPointer(object)->deref(); 987 fromInternalPointer(object)->deref();
988 } 988 }
989 989
990 } // namespace WebCore 990 } // namespace WebCore
991 991
992 #endif // ENABLE(Condition1) || ENABLE(Condition2) 992 #endif // ENABLE(Condition1) || ENABLE(Condition2)
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestEventTarget.cpp ('k') | Source/bindings/tests/results/V8TestNamedConstructor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698