Commit 03bb5469 authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Migrate some assert_throws calls that missed the earlier work

These were discovered when trying to roll testharness.js; missed in
earlier work because they didn't have an opening parenthesis after the
function name.

Bug: 1051932
Change-Id: I09b7a25b093636bfca58b4e1067a3a10ffcdc9b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132138Reviewed-by: default avatarLuke Z <lpz@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755400}
parent ae1fc684
...@@ -115,9 +115,9 @@ coroutine(function*() { ...@@ -115,9 +115,9 @@ coroutine(function*() {
[ 'clip5', yield clickOrTouch(100, 50), 'clip' ], [ 'clip5', yield clickOrTouch(100, 50), 'clip' ],
]); ]);
generate_tests(assert_throws, [ generate_tests(assert_throws_dom, [
[ 'no pixel test1', { name : 'NotSupportedError' }, no_pixel_test1 ], [ 'no pixel test1', 'NotSupportedError', no_pixel_test1 ],
[ 'no pixel test2', { name : 'NotSupportedError' }, no_pixel_test2 ], [ 'no pixel test2', 'NotSupportedError', no_pixel_test2 ],
]); ]);
done(); done();
......
...@@ -9,19 +9,22 @@ ...@@ -9,19 +9,22 @@
var canvas = document.querySelector('canvas'); var canvas = document.querySelector('canvas');
var context = canvas.getContext('2d'); var context = canvas.getContext('2d');
generate_tests(assert_throws, [ generate_tests(assert_throws_dom, [
[ 'context.addHitRegion()', { name : 'NotSupportedError' }, function() { context.addHitRegion(); } ], [ 'context.addHitRegion()', 'NotSupportedError', function() { context.addHitRegion(); } ],
[ 'context.addHitRegion({ id : \'\' })', { name : 'NotSupportedError' }, function() { context.addHitRegion({ id : '' }); } ], [ 'context.addHitRegion({ id : \'\' })', 'NotSupportedError', function() { context.addHitRegion({ id : '' }); } ],
[ 'context.addHitRegion({ id : undefined })', { name : 'NotSupportedError' }, function() { context.addHitRegion({ id : undefined }); } ], [ 'context.addHitRegion({ id : undefined })', 'NotSupportedError', function() { context.addHitRegion({ id : undefined }); } ],
[ 'context.addHitRegion({ control : {} })', { name : 'TypeError' }, function() { context.addHitRegion({ control : {} }); } ], [ 'context.addHitRegion({ control : null })', 'NotSupportedError', function() { context.addHitRegion({ control : null }); } ],
[ 'context.addHitRegion({ control : null })', { name : 'NotSupportedError' }, function() { context.addHitRegion({ control : null }); } ], [ 'context.addHitRegion({ control : undefined })', 'NotSupportedError', function() { context.addHitRegion({ control : undefined }); } ],
[ 'context.addHitRegion({ control : undefined })', { name : 'NotSupportedError' }, function() { context.addHitRegion({ control : undefined }); } ], [ 'context.addHitRegion({ id : \'\', control : null })', 'NotSupportedError', function() { context.addHitRegion({ id : '', control : null }); } ],
[ 'context.addHitRegion({ id : \'\', control : {} })', { name : 'TypeError' }, function() { context.addHitRegion({ id : '', control : {} }); } ], [ 'context.addHitRegion({ id : undefined, control : null })', 'NotSupportedError', function() { context.addHitRegion({ id : undefined, control : null }); } ],
[ 'context.addHitRegion({ id : undefined, control : {} })', { name : 'TypeError' }, function() { context.addHitRegion({ id : undefined, control : {} }); } ], [ 'context.addHitRegion({ id : \'\', control : undefined })', 'NotSupportedError', function() { context.addHitRegion({ id : '', control : undefined }); } ],
[ 'context.addHitRegion({ id : \'\', control : null })', { name : 'NotSupportedError' }, function() { context.addHitRegion({ id : '', control : null }); } ], [ 'context.addHitRegion({ id : undefined, control : undefined )', 'NotSupportedError', function() { context.addHitRegion({ id : undefined, control : undefined }); } ],
[ 'context.addHitRegion({ id : undefined, control : null })', { name : 'NotSupportedError' }, function() { context.addHitRegion({ id : undefined, control : null }); } ], ]);
[ 'context.addHitRegion({ id : \'\', control : undefined })', { name : 'NotSupportedError' }, function() { context.addHitRegion({ id : '', control : undefined }); } ],
[ 'context.addHitRegion({ id : undefined, control : undefined )', { name : 'NotSupportedError' }, function() { context.addHitRegion({ id : undefined, control : undefined }); } ], generate_tests(assert_throws_js, [
[ 'context.addHitRegion({ control : {} })', TypeError, function() { context.addHitRegion({ control : {} }); } ],
[ 'context.addHitRegion({ id : \'\', control : {} })', TypeError, function() { context.addHitRegion({ id : '', control : {} }); } ],
[ 'context.addHitRegion({ id : undefined, control : {} })', TypeError, function() { context.addHitRegion({ id : undefined, control : {} }); } ],
]); ]);
</script> </script>
...@@ -241,13 +241,13 @@ test(function(t) { ...@@ -241,13 +241,13 @@ test(function(t) {
}, "Test clamping of dirtyX/Y/Width/Height."); }, "Test clamping of dirtyX/Y/Width/Height.");
var testInvalidParams = [ var testInvalidParams = [
['TestInvalidParam 1', new TypeError, function() {context.putImageData({}, 0, 0);}], ['TestInvalidParam 1', TypeError, function() {context.putImageData({}, 0, 0);}],
['TestInvalidParam 2', new TypeError, function() {context.putImageData(null, 0, 0, 0, 0, 0, 0);}], ['TestInvalidParam 2', TypeError, function() {context.putImageData(null, 0, 0, 0, 0, 0, 0);}],
['TestInvalidParam 3', new TypeError, function() {context.putImageData(undefined, 0, 0, 0, 0, 0, 0);}], ['TestInvalidParam 3', TypeError, function() {context.putImageData(undefined, 0, 0, 0, 0, 0, 0);}],
]; ];
generate_tests(assert_throws, testInvalidParams); generate_tests(assert_throws_js, testInvalidParams);
test(function(t) { test(function(t) {
var smallbuffer = context.createImageData(10, 10); var smallbuffer = context.createImageData(10, 10);
......
...@@ -357,53 +357,53 @@ generate_tests(assert_throws, [ ...@@ -357,53 +357,53 @@ generate_tests(assert_throws, [
var detailNames = ['total', 'displayItems.0', 'shippingOptions.0', 'modifiers.0.total', 'modifiers.0.additionalDisplayItems.0']; var detailNames = ['total', 'displayItems.0', 'shippingOptions.0', 'modifiers.0.total', 'modifiers.0.additionalDisplayItems.0'];
for (var i in detailNames) { for (var i in detailNames) {
generate_tests(assert_throws, [ generate_tests(assert_throws_js, [
// Invalid currency code formats. // Invalid currency code formats.
['Undefined currency code in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Undefined currency code in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'currency': undefined}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'currency': undefined}), {requestShipping: true})
}], }],
// Invalid amount formats. // Invalid amount formats.
['Invalid amount "-" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "-" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '-'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '-'}), {requestShipping: true})
}], }],
['Invalid amount "notdigits" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "notdigits" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': 'notdigits'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': 'notdigits'}), {requestShipping: true})
}], }],
['Invalid amount "ALSONOTDIGITS" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "ALSONOTDIGITS" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': 'ALSONOTDIGITS'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': 'ALSONOTDIGITS'}), {requestShipping: true})
}], }],
['Invalid amount "10." in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "10." in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '10.'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '10.'}), {requestShipping: true})
}], }],
['Invalid amount ".99" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount ".99" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '.99'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '.99'}), {requestShipping: true})
}], }],
['Invalid amount "-10." in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "-10." in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '-10.'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '-10.'}), {requestShipping: true})
}], }],
['Invalid amount "-.99" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "-.99" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '-.99'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '-.99'}), {requestShipping: true})
}], }],
['Invalid amount "10-" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "10-" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '10-'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '10-'}), {requestShipping: true})
}], }],
['Invalid amount "1-0" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "1-0" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '1-0'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '1-0'}), {requestShipping: true})
}], }],
['Invalid amount "1.0.0" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "1.0.0" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '1.0.0'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '1.0.0'}), {requestShipping: true})
}], }],
['Invalid amount "1/3" in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Invalid amount "1/3" in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '1/3'}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': '1/3'}), {requestShipping: true})
}], }],
['Empty amount in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Empty amount in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': ''}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': ''}), {requestShipping: true})
}], }],
['Null amount in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Null amount in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': null}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': null}), {requestShipping: true})
}], }],
['Undefined amount in ' + detailNames[i] + ' should throw', new TypeError(), function() { ['Undefined amount in ' + detailNames[i] + ' should throw', TypeError, function() {
new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': undefined}), {requestShipping: true}) new PaymentRequest([{'supportedMethods': 'foo'}], buildDetails(detailNames[i], {'value': undefined}), {requestShipping: true})
}], }],
]); ]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment