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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/idl-callback-function-unittest.html

Issue 2350813005: bindings: Support sequence in callback function arguments (Closed)
Patch Set: Pass ExceptionState Created 4 years, 3 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script> 2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script> 3 <script src="../../resources/testharnessreport.js"></script>
4 <script> 4 <script>
5 var callbackFunctionTest = internals.callbackFunctionTest();
6
5 test(function() { 7 test(function() {
6 var callbackFunctionTest = internals.callbackFunctionTest();
7 var callback1 = function(msg1, msg2) { 8 var callback1 = function(msg1, msg2) {
8 return msg1 + ', ' + msg2; 9 return msg1 + ', ' + msg2;
9 }; 10 };
10 assert_equals(callbackFunctionTest.testCallback(callback1, 'hello', 'world') , 'SUCCESS: hello, world'); 11 assert_equals(callbackFunctionTest.testCallback(callback1, 'hello', 'world') , 'SUCCESS: hello, world');
11 12
12 var callback2 = function(msg1, msg2) { 13 var callback2 = function(msg1, msg2) {
13 return msg1 + msg1 + ' ' + msg2 + msg2; 14 return msg1 + msg1 + ' ' + msg2 + msg2;
14 }; 15 };
15 assert_equals(callbackFunctionTest.testCallback(callback2, 'hello', 'world') , 'SUCCESS: hellohello worldworld'); 16 assert_equals(callbackFunctionTest.testCallback(callback2, 'hello', 'world') , 'SUCCESS: hellohello worldworld');
16 }, 'Callback function which takes two strings'); 17 }, 'Callback function which takes two strings');
18
19 test(function() {
20 var squareStringNumbers = function(numbers) {
21 return numbers.map(n => (n * n).toString());
22 };
23 var results = callbackFunctionTest.testSequenceCallback(squareStringNumbers, [1, 2, 3]);
24 assert_equals(3, results.length);
25 assert_equals('1', results[0]);
26 assert_equals('4', results[1]);
27 assert_equals('9', results[2]);
28
29 var exception = new TypeError();
30 assert_throws(exception, function() {
31 var throwException = function() {
32 throw exception;
33 };
34 callbackFunctionTest.testSequenceCallback(throwException, [1, 2, 3]);
35 });
36 }, 'Callback function which takes a number sequence');
17 </script> 37 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698