OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/testing/CallbackFunctionTest.h" | 5 #include "core/testing/CallbackFunctionTest.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "bindings/core/v8/V8TestCallback.h" | 9 #include "bindings/core/v8/V8TestCallback.h" |
10 #include "bindings/core/v8/V8TestInterfaceCallback.h" | 10 #include "bindings/core/v8/V8TestInterfaceCallback.h" |
11 #include "bindings/core/v8/V8TestReceiverObjectCallback.h" | 11 #include "bindings/core/v8/V8TestReceiverObjectCallback.h" |
| 12 #include "bindings/core/v8/V8TestSequenceCallback.h" |
12 #include "core/html/HTMLDivElement.h" | 13 #include "core/html/HTMLDivElement.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 DEFINE_TRACE(CallbackFunctionTest) | 17 DEFINE_TRACE(CallbackFunctionTest) |
17 { | 18 { |
18 } | 19 } |
19 | 20 |
20 String CallbackFunctionTest::testCallback(ScriptState* scriptState, V8TestCallba
ck* callback, const String& message1, const String& message2, ExceptionState& ex
ceptionState) | 21 String CallbackFunctionTest::testCallback(ScriptState* scriptState, V8TestCallba
ck* callback, const String& message1, const String& message2, ExceptionState& ex
ceptionState) |
21 { | 22 { |
22 ScriptWrappable* scriptWrappable; | 23 ScriptWrappable* scriptWrappable; |
23 String returnValue; | 24 String returnValue; |
24 | 25 |
25 if (callback->call(scriptState, scriptWrappable = nullptr, message1, message
2, returnValue)) { | 26 if (callback->call(scriptState, scriptWrappable = nullptr, exceptionState, m
essage1, message2, returnValue)) { |
26 return String("SUCCESS: ") + returnValue; | 27 return String("SUCCESS: ") + returnValue; |
27 } | 28 } |
28 return String("Error!"); | 29 return String("Error!"); |
29 } | 30 } |
30 | 31 |
31 void CallbackFunctionTest::testInterfaceCallback(ScriptState* scriptState, V8Tes
tInterfaceCallback* callback, HTMLDivElement* divElement, ExceptionState& except
ionState) | 32 void CallbackFunctionTest::testInterfaceCallback(ScriptState* scriptState, V8Tes
tInterfaceCallback* callback, HTMLDivElement* divElement, ExceptionState& except
ionState) |
32 { | 33 { |
33 ScriptWrappable* scriptWrappable; | 34 ScriptWrappable* scriptWrappable; |
34 | 35 |
35 callback->call(scriptState, scriptWrappable = nullptr, divElement); | 36 callback->call(scriptState, scriptWrappable = nullptr, exceptionState, divEl
ement); |
36 return; | 37 return; |
37 } | 38 } |
38 | 39 |
39 void CallbackFunctionTest::testReceiverObjectCallback(ScriptState* scriptState,
V8TestReceiverObjectCallback* callback, ExceptionState& exceptionState) | 40 void CallbackFunctionTest::testReceiverObjectCallback(ScriptState* scriptState,
V8TestReceiverObjectCallback* callback, ExceptionState& exceptionState) |
40 { | 41 { |
41 callback->call(scriptState, this); | 42 callback->call(scriptState, this, exceptionState); |
42 return; | 43 return; |
43 } | 44 } |
44 | 45 |
| 46 Vector<String> CallbackFunctionTest::testSequenceCallback(ScriptState* scriptSta
te, V8TestSequenceCallback* callback, const Vector<int>& numbers, ExceptionState
& exceptionState) |
| 47 { |
| 48 Vector<String> returnValue; |
| 49 if (callback->call(scriptState, nullptr, exceptionState, numbers, returnValu
e)) { |
| 50 return returnValue; |
| 51 } |
| 52 return Vector<String>(); |
| 53 } |
| 54 |
45 } // namespace blink | 55 } // namespace blink |
OLD | NEW |