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

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

Issue 2607433002: bindings: Throw a TypeError when a given callback function isn't callable (Closed)
Patch Set: Created 3 years, 12 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(); 5 var callbackFunctionTest = internals.callbackFunctionTest();
6 6
7 test(function() { 7 test(function() {
8 var callback1 = function(msg1, msg2) { 8 var callback1 = function(msg1, msg2) {
9 return msg1 + ', ' + msg2; 9 return msg1 + ', ' + msg2;
10 }; 10 };
(...skipping 24 matching lines...) Expand all
35 test(function() { 35 test(function() {
36 var squareStringNumbers = function(numbers) { 36 var squareStringNumbers = function(numbers) {
37 return numbers.map(n => (n * n).toString()); 37 return numbers.map(n => (n * n).toString());
38 }; 38 };
39 var results = callbackFunctionTest.testSequenceCallback(squareStringNumbers, [1, 2, 3]); 39 var results = callbackFunctionTest.testSequenceCallback(squareStringNumbers, [1, 2, 3]);
40 assert_equals(3, results.length); 40 assert_equals(3, results.length);
41 assert_equals('1', results[0]); 41 assert_equals('1', results[0]);
42 assert_equals('4', results[1]); 42 assert_equals('4', results[1]);
43 assert_equals('9', results[2]); 43 assert_equals('9', results[2]);
44 }, 'Callback function which takes a number sequence'); 44 }, 'Callback function which takes a number sequence');
45
46 test(function() {
47 assert_throws(new TypeError(), function() {
48 callbackFunctionTest.testCallback(null, 'hello', 'world');
49 });
50 assert_throws(new TypeError(), function() {
51 callbackFunctionTest.testCallback({}, 'hello', 'world');
52 });
53 assert_throws(new TypeError(), function() {
54 callbackFunctionTest.testCallback(1, 'hello', 'world');
55 });
56 }, 'Passing non-callable values should throw a TypeError');
45 </script> 57 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698