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

Side by Side Diff: third_party/WebKit/Source/core/testing/CallbackFunctionTest.cpp

Issue 2617653002: bindings: Don't throw a TypeError when 'null' is passed to nullable callback function (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
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/TestCallback.h" 7 #include "bindings/core/v8/TestCallback.h"
8 #include "bindings/core/v8/TestInterfaceCallback.h" 8 #include "bindings/core/v8/TestInterfaceCallback.h"
9 #include "bindings/core/v8/TestReceiverObjectCallback.h" 9 #include "bindings/core/v8/TestReceiverObjectCallback.h"
10 #include "bindings/core/v8/TestSequenceCallback.h" 10 #include "bindings/core/v8/TestSequenceCallback.h"
(...skipping 11 matching lines...) Expand all
22 ScriptWrappable* scriptWrappable; 22 ScriptWrappable* scriptWrappable;
23 String returnValue; 23 String returnValue;
24 24
25 if (callback->call(scriptWrappable = nullptr, message1, message2, 25 if (callback->call(scriptWrappable = nullptr, message1, message2,
26 returnValue)) { 26 returnValue)) {
27 return String("SUCCESS: ") + returnValue; 27 return String("SUCCESS: ") + returnValue;
28 } 28 }
29 return String("Error!"); 29 return String("Error!");
30 } 30 }
31 31
32 String CallbackFunctionTest::testNullableCallback(
33 TestCallback* callback,
34 const String& message1,
35 const String& message2,
36 ExceptionState& exceptionState) {
37 if (!callback)
38 return String("Empty callback");
39 return testCallback(callback, message1, message2, exceptionState);
40 }
41
32 void CallbackFunctionTest::testInterfaceCallback( 42 void CallbackFunctionTest::testInterfaceCallback(
33 TestInterfaceCallback* callback, 43 TestInterfaceCallback* callback,
34 HTMLDivElement* divElement, 44 HTMLDivElement* divElement,
35 ExceptionState& exceptionState) { 45 ExceptionState& exceptionState) {
36 ScriptWrappable* scriptWrappable; 46 ScriptWrappable* scriptWrappable;
37 47
38 callback->call(scriptWrappable = nullptr, divElement); 48 callback->call(scriptWrappable = nullptr, divElement);
39 return; 49 return;
40 } 50 }
41 51
42 void CallbackFunctionTest::testReceiverObjectCallback( 52 void CallbackFunctionTest::testReceiverObjectCallback(
43 TestReceiverObjectCallback* callback, 53 TestReceiverObjectCallback* callback,
44 ExceptionState& exceptionState) { 54 ExceptionState& exceptionState) {
45 callback->call(this); 55 callback->call(this);
46 return; 56 return;
47 } 57 }
48 58
49 Vector<String> CallbackFunctionTest::testSequenceCallback( 59 Vector<String> CallbackFunctionTest::testSequenceCallback(
50 TestSequenceCallback* callback, 60 TestSequenceCallback* callback,
51 const Vector<int>& numbers, 61 const Vector<int>& numbers,
52 ExceptionState& exceptionState) { 62 ExceptionState& exceptionState) {
53 Vector<String> returnValue; 63 Vector<String> returnValue;
54 if (callback->call(nullptr, numbers, returnValue)) { 64 if (callback->call(nullptr, numbers, returnValue)) {
55 return returnValue; 65 return returnValue;
56 } 66 }
57 return Vector<String>(); 67 return Vector<String>();
58 } 68 }
59 69
60 } // namespace blink 70 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698