Commit fc64bd47 authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Replace some "assert_throws({'name': 'jserror'}, stuff)" with assert_throws_js

This diff was generated by running:

  find . -type f -print0 | xargs -0 perl -pi -e "BEGIN { \$/ = undef; } s/assert_throws\(([ \n]*)\{ *[\"']?name[\"']? *: *['\"](TypeError|Error)[\"'] *\} *(, *.)/assert_throws_js(\1\2\3/gs"

And then manually fixing up whitespace.

Bug: 1051932
Change-Id: I36cd1e17f36e92fe4a28461189f058f0fb11885e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080432
Auto-Submit: Stephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarLuke Z <lpz@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746022}
parent 38e73541
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
<script> <script>
test(() => { test(() => {
assert_throws({name: 'TypeError'}, () => { assert_throws_js(TypeError, () => {
document.body.animate({left: [{toString:null}]}); document.body.animate({left: [{toString:null}]});
}); });
}, 'Do not crash when passing an unstringable value in a property indexed keyframe'); }, 'Do not crash when passing an unstringable value in a property indexed keyframe');
......
...@@ -121,7 +121,7 @@ test(() => { ...@@ -121,7 +121,7 @@ test(() => {
}, 'Custom iterator with offset specified.'); }, 'Custom iterator with offset specified.');
test(() => { test(() => {
assert_throws({name: 'TypeError'}, () => { assert_throws_js(TypeError, () => {
assertAnimationEffect({ assertAnimationEffect({
keyframes: createIterable([ keyframes: createIterable([
{done: false, value: {left: '100px'}}, {done: false, value: {left: '100px'}},
...@@ -135,7 +135,7 @@ test(() => { ...@@ -135,7 +135,7 @@ test(() => {
}, 'Custom iterator with non object keyframe should throw.'); }, 'Custom iterator with non object keyframe should throw.');
test(() => { test(() => {
assert_throws({name: 'TypeError'}, () => { assert_throws_js(TypeError, () => {
assertAnimationEffect({ assertAnimationEffect({
keyframes: { keyframes: {
left: createIterable([ left: createIterable([
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
test(function() { test(function() {
var div = document.createElement("div"); var div = document.createElement("div");
// Test that "supports()" is throwing TypeError // Test that "supports()" is throwing TypeError
assert_throws( assert_throws_js(
{name: 'TypeError'}, function() { div.classList.supports("bogus"); }, TypeError, function() { div.classList.supports("bogus"); },
'supports method should throw if called on an DOMTokenList with no supported tokens, such as classList'); 'supports method should throw if called on an DOMTokenList with no supported tokens, such as classList');
}, "Make sure that classList throws when supports() is called"); }, "Make sure that classList throws when supports() is called");
</script> </script>
...@@ -47,8 +47,8 @@ promise_test(function(t) { ...@@ -47,8 +47,8 @@ promise_test(function(t) {
assert_equals(dsl.item(1), 'b', 'item method'); assert_equals(dsl.item(1), 'b', 'item method');
assert_equals(dsl.item(2), 'c', 'item method'); assert_equals(dsl.item(2), 'c', 'item method');
assert_equals(dsl.item(3), null, 'item method out of range'); assert_equals(dsl.item(3), null, 'item method out of range');
assert_throws( assert_throws_js(
{name: 'TypeError'}, function() { dsl.item(); }, TypeError, function() { dsl.item(); },
'item method should throw if called without enough args'); 'item method should throw if called without enough args');
assert_equals(dsl[0], 'a', 'indexed getter'); assert_equals(dsl[0], 'a', 'indexed getter');
...@@ -66,8 +66,8 @@ promise_test(function(t) { ...@@ -66,8 +66,8 @@ promise_test(function(t) {
'contains method unmatched'); 'contains method unmatched');
assert_false(dsl.contains('d'), assert_false(dsl.contains('d'),
'contains method unmatched'); 'contains method unmatched');
assert_throws( assert_throws_js(
{name: 'TypeError'}, function(){ dsl.contains(); }, TypeError, function(){ dsl.contains(); },
'contains method should throw if called without enough args'); 'contains method should throw if called without enough args');
}); });
}, 'DOMStringList interface'); }, 'DOMStringList interface');
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<div id="log"></div> <div id="log"></div>
<script> <script>
test(function() { test(function() {
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { new InputEvent(); }, function() { new InputEvent(); },
"Construct InputEvent with no argument."); "Construct InputEvent with no argument.");
}, "Checks for InputEvent constructor with not enough argument"); }, "Checks for InputEvent constructor with not enough argument");
test(function() { test(function() {
......
...@@ -86,9 +86,9 @@ test(function () { ...@@ -86,9 +86,9 @@ test(function () {
test(function () { test(function () {
mediaList.mediaText = "screen, tv"; mediaList.mediaText = "screen, tv";
assert_throws({ name: "TypeError" }, assert_throws_js(TypeError,
function () { document.appendMedium(); }, function () { document.appendMedium(); },
"Not enough arguments"); "Not enough arguments");
}, "Add without argument"); }, "Add without argument");
// - deleteMedium() // - deleteMedium()
...@@ -165,8 +165,8 @@ test(function () { ...@@ -165,8 +165,8 @@ test(function () {
test(function () { test(function () {
mediaList.mediaText = "tv, print, screen"; mediaList.mediaText = "tv, print, screen";
assert_throws({ name: "TypeError" }, assert_throws_js(TypeError,
function () { document.deleteMedium(); }, function () { document.deleteMedium(); },
"Not enough arguments"); "Not enough arguments");
}, "Remove without argument"); }, "Remove without argument");
</script> </script>
...@@ -28,10 +28,10 @@ test(function() { ...@@ -28,10 +28,10 @@ test(function() {
}, 'Constructor can be initialized with output from another constructor'); }, 'Constructor can be initialized with output from another constructor');
test(function() { test(function() {
assert_throws({name: 'TypeError'}, () => new RTCIceCandidate({})); assert_throws_js(TypeError, () => new RTCIceCandidate({}));
assert_throws({name: 'TypeError'}, () => new RTCIceCandidate(5)); assert_throws_js(TypeError, () => new RTCIceCandidate(5));
assert_throws({name: 'TypeError'}, () => new RTCIceCandidate('foobar')); assert_throws_js(TypeError, () => new RTCIceCandidate('foobar'));
assert_throws({name: 'TypeError'}, () => new RTCIceCandidate({candidate: ''})); assert_throws_js(TypeError, () => new RTCIceCandidate({candidate: ''}));
}, 'Constructor throws on invalid input'); }, 'Constructor throws on invalid input');
test(function() { test(function() {
......
...@@ -24,8 +24,8 @@ test(() => { ...@@ -24,8 +24,8 @@ test(() => {
var g = new webkitSpeechGrammar(); var g = new webkitSpeechGrammar();
g.weight = 2; g.weight = 2;
assert_equals(g.weight, 2.0); assert_equals(g.weight, 2.0);
assert_throws({name: "TypeError"}, () => g.weight = NaN); assert_throws_js(TypeError, () => g.weight = NaN);
assert_throws({name: "TypeError"}, () => g.weight = Infinity); assert_throws_js(TypeError, () => g.weight = Infinity);
assert_equals(g.weight, 2.0); assert_equals(g.weight, 2.0);
g.src = "grammar.xml"; g.src = "grammar.xml";
assert_equals(g.src, base + "grammar.xml"); assert_equals(g.src, base + "grammar.xml");
...@@ -70,14 +70,14 @@ test(() => { ...@@ -70,14 +70,14 @@ test(() => {
"data:application/xml,%3Cgrammar%3Efoo%3C/grammar%3E"); "data:application/xml,%3Cgrammar%3Efoo%3C/grammar%3E");
assert_equals(gs[2].weight, 4); assert_equals(gs[2].weight, 4);
assert_throws({name: "TypeError"}, assert_throws_js(TypeError,
() => gs.addFromUri("http://foo.tld/grammar.xml", NaN)); () => gs.addFromUri("http://foo.tld/grammar.xml", NaN));
assert_throws({name: "TypeError"}, assert_throws_js(TypeError,
() => gs.addFromUri("http://foo.tld/grammar.xml", Infinity)); () => gs.addFromUri("http://foo.tld/grammar.xml", Infinity));
assert_throws({name: "TypeError"}, assert_throws_js(TypeError,
() => gs.addFromString("foo", NaN)); () => gs.addFromString("foo", NaN));
assert_throws({name: "TypeError"}, assert_throws_js(TypeError,
() => gs.addFromString("foo", Infinity)); () => gs.addFromString("foo", Infinity));
}, "Creating a grammar list"); }, "Creating a grammar list");
</script> </script>
...@@ -5,38 +5,38 @@ if (self.importScripts) { ...@@ -5,38 +5,38 @@ if (self.importScripts) {
// Tests that invalid names/values throw TypeError. // Tests that invalid names/values throw TypeError.
function testInvalidNamesAndValues(headers) { function testInvalidNamesAndValues(headers) {
INVALID_HEADER_NAMES.forEach(function(name) { INVALID_HEADER_NAMES.forEach(function(name) {
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.append(name, 'a'); }, function() { headers.append(name, 'a'); },
'Headers.append with an invalid name (' + name + 'Headers.append with an invalid name (' + name +
') must throw'); ') must throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.delete(name); }, function() { headers.delete(name); },
'Headers.delete with an invalid name (' + name + 'Headers.delete with an invalid name (' + name +
') must throw'); ') must throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.get(name); }, function() { headers.get(name); },
'Headers.get with an invalid name (' + name + 'Headers.get with an invalid name (' + name +
') must throw'); ') must throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.getAll(name); }, function() { headers.getAll(name); },
'Headers.getAll with an invalid name (' + name + 'Headers.getAll with an invalid name (' + name +
') must throw'); ') must throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.has(name); }, function() { headers.has(name); },
'Headers.has with an invalid name (' + name + 'Headers.has with an invalid name (' + name +
') must throw'); ') must throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.set(name, 'a'); }, function() { headers.set(name, 'a'); },
'Headers.set with an invalid name (' + name + 'Headers.set with an invalid name (' + name +
') must throw'); ') must throw');
}); });
INVALID_HEADER_VALUES.forEach(function(value) { INVALID_HEADER_VALUES.forEach(function(value) {
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.append('a', value); }, function() { headers.append('a', value); },
'Headers.append with an invalid value must throw'); 'Headers.append with an invalid value must throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.set('a', value); }, function() { headers.set('a', value); },
'Headers.set with an invalid value must throw'); 'Headers.set with an invalid value must throw');
}); });
} }
...@@ -383,21 +383,21 @@ promise_test(function(t) { ...@@ -383,21 +383,21 @@ promise_test(function(t) {
.forEach(function(header) { .forEach(function(header) {
var value = headers.get(header); var value = headers.get(header);
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.append(header, 'test'); }, function() { headers.append(header, 'test'); },
'Headers.append(' + header + ') must throw'); 'Headers.append(' + header + ') must throw');
assert_equals(headers.get(header), value, assert_equals(headers.get(header), value,
'header ' + header + ' must be unchanged by append()'); 'header ' + header + ' must be unchanged by append()');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.set(header, 'test'); }, function() { headers.set(header, 'test'); },
'Headers.set(' + header + ') must throw'); 'Headers.set(' + header + ') must throw');
assert_equals(headers.get(header), value, assert_equals(headers.get(header), value,
'header ' + header + ' must be unchanged by set()'); 'header ' + header + ' must be unchanged by set()');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { headers.delete(header); }, function() { headers.delete(header); },
'Headers.delete(' + header + ') must throw'); 'Headers.delete(' + header + ') must throw');
assert_equals(headers.get(header), value, assert_equals(headers.get(header), value,
'header ' + header + ' must be unchanged by delete()'); 'header ' + header + ' must be unchanged by delete()');
}); });
......
...@@ -191,47 +191,47 @@ test(function() { ...@@ -191,47 +191,47 @@ test(function() {
// Throw errors // Throw errors
INVALID_HEADER_NAMES.forEach(function(name) { INVALID_HEADER_NAMES.forEach(function(name) {
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { function() {
var obj = {}; var obj = {};
obj[name] = 'a'; obj[name] = 'a';
var headers = new Headers(obj); var headers = new Headers(obj);
}, },
'new Headers with an invalid name (' + name + 'new Headers with an invalid name (' + name +
') should throw'); ') should throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { var headers = new Headers([[name, 'a']]); }, function() { var headers = new Headers([[name, 'a']]); },
'new Headers with an invalid name (' + name + 'new Headers with an invalid name (' + name +
') should throw'); ') should throw');
}); });
INVALID_HEADER_VALUES.forEach(function(value) { INVALID_HEADER_VALUES.forEach(function(value) {
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { var headers = new Headers({'a': value}); }, function() { var headers = new Headers({'a': value}); },
'new Headers with an invalid value should throw'); 'new Headers with an invalid value should throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { var headers = new Headers([['a', value]]); }, function() { var headers = new Headers([['a', value]]); },
'new Headers with an invalid value should throw'); 'new Headers with an invalid value should throw');
}); });
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { var headers = new Headers([[]]); }, function() { var headers = new Headers([[]]); },
'new Headers with a sequence with less than two strings ' + 'new Headers with a sequence with less than two strings ' +
'should throw'); 'should throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { var headers = new Headers([['a']]); }, function() { var headers = new Headers([['a']]); },
'new Headers with a sequence with less than two strings ' + 'new Headers with a sequence with less than two strings ' +
'should throw'); 'should throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { var headers = new Headers([['a', 'b'], []]); }, function() { var headers = new Headers([['a', 'b'], []]); },
'new Headers with a sequence with less than two strings ' + 'new Headers with a sequence with less than two strings ' +
'should throw'); 'should throw');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { var headers = new Headers([['a', 'b'], function() { var headers = new Headers([['a', 'b'],
['x', 'y', 'z']]); }, ['x', 'y', 'z']]); },
'new Headers with a sequence with more than two strings ' + 'new Headers with a sequence with more than two strings ' +
'should throw'); 'should throw');
}, 'Headers'); }, 'Headers');
test(function(t) { test(function(t) {
......
...@@ -238,8 +238,8 @@ test(function() { ...@@ -238,8 +238,8 @@ test(function() {
if (method1 != undefined) { init1['method'] = method1; } if (method1 != undefined) { init1['method'] = method1; }
if (mode1 != undefined) { init1['mode'] = mode1; } if (mode1 != undefined) { init1['mode'] = mode1; }
if (!isSimpleMethod(method1) && mode1 == 'no-cors') { if (!isSimpleMethod(method1) && mode1 == 'no-cors') {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { request1 = new Request(URL, init1); }, function() { request1 = new Request(URL, init1); },
'new no-cors Request with non simple method (' + method1 + 'new no-cors Request with non simple method (' + method1 +
') should throw'); ') should throw');
...@@ -266,8 +266,8 @@ test(function() { ...@@ -266,8 +266,8 @@ test(function() {
if (mode2 != undefined) { init2['mode'] = mode2; } if (mode2 != undefined) { init2['mode'] = mode2; }
if (!isSimpleMethod(effectiveMethod(method1, method2)) && if (!isSimpleMethod(effectiveMethod(method1, method2)) &&
effectiveMode(mode1, mode2) == 'no-cors') { effectiveMode(mode1, mode2) == 'no-cors') {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { request2 = new Request(request1, init2); }, function() { request2 = new Request(request1, init2); },
'new no-cors Request with non simple method should ' + 'new no-cors Request with non simple method should ' +
'throw'); 'throw');
...@@ -359,8 +359,8 @@ test(function() { ...@@ -359,8 +359,8 @@ test(function() {
test(function() { test(function() {
['same-origin', 'cors', 'no-cors'].forEach(function(mode) { ['same-origin', 'cors', 'no-cors'].forEach(function(mode) {
FORBIDDEN_METHODS.forEach(function(method) { FORBIDDEN_METHODS.forEach(function(method) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
var request = new Request(URL, {mode: mode, method: method}); var request = new Request(URL, {mode: mode, method: method});
}, },
...@@ -368,8 +368,8 @@ test(function() { ...@@ -368,8 +368,8 @@ test(function() {
'throw'); 'throw');
}); });
INVALID_METHOD_NAMES.forEach(function(name) { INVALID_METHOD_NAMES.forEach(function(name) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
var request = new Request(URL, {mode: mode, method: name}); var request = new Request(URL, {mode: mode, method: name});
}, },
...@@ -379,8 +379,8 @@ test(function() { ...@@ -379,8 +379,8 @@ test(function() {
}, 'Request method name throw test'); }, 'Request method name throw test');
test(function() { test(function() {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
var request = new Request(URL, {mode: 'navigate'}); var request = new Request(URL, {mode: 'navigate'});
}, },
...@@ -446,8 +446,8 @@ test(function() { ...@@ -446,8 +446,8 @@ test(function() {
'Request should not be flagged as used if it has not been ' + 'Request should not be flagged as used if it has not been ' +
'consumed.'); 'consumed.');
// See https://crbug.com/501195. // See https://crbug.com/501195.
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { new Request(req); }, function() { new Request(req); },
'Request construction should throw if used.'); 'Request construction should throw if used.');
}, 'POST Request construction without body behavior regardning "bodyUsed"'); }, 'POST Request construction without body behavior regardning "bodyUsed"');
...@@ -457,15 +457,15 @@ test(function() { ...@@ -457,15 +457,15 @@ test(function() {
assert_false(req.bodyUsed, assert_false(req.bodyUsed,
'Request should not be flagged as used if it has not been ' + 'Request should not be flagged as used if it has not been ' +
'consumed.'); 'consumed.');
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { new Request(req, {method: 'GET'}); }, function() { new Request(req, {method: 'GET'}); },
'A get request may not have body.'); 'A get request may not have body.');
assert_false(req.bodyUsed, 'After the GET case'); assert_false(req.bodyUsed, 'After the GET case');
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { new Request(req, {method: 'CONNECT'}); }, function() { new Request(req, {method: 'CONNECT'}); },
'Request() with a forbidden method must throw.'); 'Request() with a forbidden method must throw.');
...@@ -553,7 +553,7 @@ test(function() { ...@@ -553,7 +553,7 @@ test(function() {
test(function() { test(function() {
var referrer = 'invali\0d'; var referrer = 'invali\0d';
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
() => new Request(URL, {referrer: referrer})); () => new Request(URL, {referrer: referrer}));
}, 'Request with an invalid referrer'); }, 'Request with an invalid referrer');
...@@ -577,8 +577,8 @@ test(() => { ...@@ -577,8 +577,8 @@ test(() => {
.referrerPolicy, 'origin-when-cross-origin'); .referrerPolicy, 'origin-when-cross-origin');
assert_equals(new Request('/', {referrerPolicy: 'unsafe-url'}) assert_equals(new Request('/', {referrerPolicy: 'unsafe-url'})
.referrerPolicy, 'unsafe-url'); .referrerPolicy, 'unsafe-url');
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
() => new Request('/', {referrerPolicy: 'invalid'}), () => new Request('/', {referrerPolicy: 'invalid'}),
'Setting invalid referrer policy should be thrown.'); 'Setting invalid referrer policy should be thrown.');
}, 'Referrer policy settings'); }, 'Referrer policy settings');
...@@ -657,8 +657,8 @@ test(function() { ...@@ -657,8 +657,8 @@ test(function() {
var headers = new Headers; var headers = new Headers;
headers.set('Content-Language', 'ja'); headers.set('Content-Language', 'ja');
['GET', 'HEAD'].forEach(function(method) { ['GET', 'HEAD'].forEach(function(method) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
new Request(URL, new Request(URL,
{method: method, {method: method,
...@@ -673,7 +673,7 @@ test(() => { ...@@ -673,7 +673,7 @@ test(() => {
var req = new Request(URL, {method: 'POST', body: 'hello'}); var req = new Request(URL, {method: 'POST', body: 'hello'});
req.text(); req.text();
assert_true(req.bodyUsed); assert_true(req.bodyUsed);
assert_throws({name: 'TypeError'}, () => { req.clone(); }); assert_throws_js(TypeError, () => { req.clone(); });
}, 'Used => clone'); }, 'Used => clone');
test(() => { test(() => {
...@@ -921,8 +921,8 @@ test(function() { ...@@ -921,8 +921,8 @@ test(function() {
// Step 32: // Step 32:
// Fill r's Headers object with headers. Rethrow any exceptions. // Fill r's Headers object with headers. Rethrow any exceptions.
INVALID_HEADER_NAMES.forEach(function(name) { INVALID_HEADER_NAMES.forEach(function(name) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
var obj = {}; var obj = {};
obj[name] = 'a'; obj[name] = 'a';
...@@ -930,8 +930,8 @@ test(function() { ...@@ -930,8 +930,8 @@ test(function() {
}, },
'new Request with headers with an invalid name (' + name + 'new Request with headers with an invalid name (' + name +
') should throw'); ') should throw');
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
new Request('http://localhost/', {headers: [[name, 'a']]}); new Request('http://localhost/', {headers: [[name, 'a']]});
}, },
...@@ -940,15 +940,15 @@ test(function() { ...@@ -940,15 +940,15 @@ test(function() {
}); });
INVALID_HEADER_VALUES.forEach(function(value) { INVALID_HEADER_VALUES.forEach(function(value) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
new Request('http://localhost/', new Request('http://localhost/',
{headers: {'X-Fetch-Test': value}}); {headers: {'X-Fetch-Test': value}});
}, },
'new Request with headers with an invalid value should throw'); 'new Request with headers with an invalid value should throw');
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
new Request('http://localhost/', new Request('http://localhost/',
{headers: [['X-Fetch-Test', value]]}); {headers: [['X-Fetch-Test', value]]});
......
...@@ -181,9 +181,9 @@ promise_test(function() { ...@@ -181,9 +181,9 @@ promise_test(function() {
assert_true(response.bodyUsed, 'bodyUsed should be true when locked.'); assert_true(response.bodyUsed, 'bodyUsed should be true when locked.');
assert_false(response2.bodyUsed, assert_false(response2.bodyUsed,
'Cloned bodies should not share bodyUsed.'); 'Cloned bodies should not share bodyUsed.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { response3 = response.clone(); }, function() { response3 = response.clone(); },
'Response.clone() should throw if the body was used.'); 'Response.clone() should throw if the body was used.');
return p.then(function(text) { return p.then(function(text) {
assert_true(response.bodyUsed); assert_true(response.bodyUsed);
assert_false(response2.bodyUsed); assert_false(response2.bodyUsed);
......
...@@ -144,12 +144,12 @@ test(function() { ...@@ -144,12 +144,12 @@ test(function() {
}); });
[204, 205, 304].forEach(function(status) { [204, 205, 304].forEach(function(status) {
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { function() {
new Response(new Blob(), {status: status}); new Response(new Blob(), {status: status});
}, },
'new Response with null body status = ' + status + 'new Response with null body status = ' + status +
' and body is non-null should throw'); ' and body is non-null should throw');
}); });
[300, 0, 304, 305, 306, 309, 500].forEach(function(status) { [300, 0, 304, 305, 306, 309, 500].forEach(function(status) {
...@@ -162,8 +162,8 @@ test(function() { ...@@ -162,8 +162,8 @@ test(function() {
' should throw'); ' should throw');
}); });
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
Response.redirect('https://', 301); Response.redirect('https://', 301);
}, },
...@@ -171,8 +171,8 @@ test(function() { ...@@ -171,8 +171,8 @@ test(function() {
' and status 301 should throw'); ' and status 301 should throw');
INVALID_URLS.forEach(function(url) { INVALID_URLS.forEach(function(url) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
Response.redirect(url); Response.redirect(url);
}, },
...@@ -180,8 +180,8 @@ test(function() { ...@@ -180,8 +180,8 @@ test(function() {
' and default status value should throw'); ' and default status value should throw');
}); });
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
Response.redirect('https://', 300); Response.redirect('https://', 300);
}, },
...@@ -198,8 +198,8 @@ test(function() { ...@@ -198,8 +198,8 @@ test(function() {
}); });
INVALID_HEADER_NAMES.forEach(function(name) { INVALID_HEADER_NAMES.forEach(function(name) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
var obj = {}; var obj = {};
obj[name] = 'a'; obj[name] = 'a';
...@@ -207,8 +207,8 @@ test(function() { ...@@ -207,8 +207,8 @@ test(function() {
}, },
'new Response with headers with an invalid name (' + name + 'new Response with headers with an invalid name (' + name +
') should throw'); ') should throw');
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
new Response(new Blob(), {headers: [[name, 'a']]}); new Response(new Blob(), {headers: [[name, 'a']]});
}, },
...@@ -216,15 +216,15 @@ test(function() { ...@@ -216,15 +216,15 @@ test(function() {
') should throw'); ') should throw');
}); });
INVALID_HEADER_VALUES.forEach(function(value) { INVALID_HEADER_VALUES.forEach(function(value) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
new Response(new Blob(), new Response(new Blob(),
{headers: {'X-Fetch-Test': value}}); {headers: {'X-Fetch-Test': value}});
}, },
'new Response with headers with an invalid value should throw'); 'new Response with headers with an invalid value should throw');
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
new Response(new Blob(), new Response(new Blob(),
{headers: [['X-Fetch-Test', value]]}); {headers: [['X-Fetch-Test', value]]});
...@@ -240,8 +240,8 @@ test(function() { ...@@ -240,8 +240,8 @@ test(function() {
}); });
INVALID_REASON_PHRASE.forEach(function(text) { INVALID_REASON_PHRASE.forEach(function(text) {
assert_throws( assert_throws_js(
{name: 'TypeError'}, TypeError,
function() { function() {
new Response(new Blob(), {statusText: text}); new Response(new Blob(), {statusText: text});
}, },
...@@ -301,7 +301,7 @@ promise_test(function(t) { ...@@ -301,7 +301,7 @@ promise_test(function(t) {
assert_not_equals(res.body, body); assert_not_equals(res.body, body);
assert_not_equals(res.body, clone.body); assert_not_equals(res.body, clone.body);
assert_not_equals(body, clone.body); assert_not_equals(body, clone.body);
assert_throws({name: 'TypeError'}, function() { body.getReader(); }); assert_throws_js(TypeError, function() { body.getReader(); });
return Promise.all([res.text(), clone.text()]).then(function(r) { return Promise.all([res.text(), clone.text()]).then(function(r) {
assert_equals(r[0], 'hello'); assert_equals(r[0], 'hello');
assert_equals(r[1], 'hello'); assert_equals(r[1], 'hello');
...@@ -317,7 +317,7 @@ promise_test(function(t) { ...@@ -317,7 +317,7 @@ promise_test(function(t) {
assert_not_equals(res.body, body); assert_not_equals(res.body, body);
assert_not_equals(res.body, clone.body); assert_not_equals(res.body, clone.body);
assert_not_equals(body, clone.body); assert_not_equals(body, clone.body);
assert_throws({name: 'TypeError'}, function() { body.getReader(); }); assert_throws_js(TypeError, function() { body.getReader(); });
return Promise.all( return Promise.all(
[readableStreamToArray(res.body), readableStreamToArray(clone.body)]) [readableStreamToArray(res.body), readableStreamToArray(clone.body)])
.then(r => { .then(r => {
...@@ -330,14 +330,14 @@ test(() => { ...@@ -330,14 +330,14 @@ test(() => {
var res = new Response('hello'); var res = new Response('hello');
res.body.cancel(); res.body.cancel();
assert_true(res.bodyUsed); assert_true(res.bodyUsed);
assert_throws({name: 'TypeError'}, () => res.clone()); assert_throws_js(TypeError, () => res.clone());
}, 'Used => clone'); }, 'Used => clone');
test(() => { test(() => {
var res = new Response('hello'); var res = new Response('hello');
const reader = res.body.getReader(); const reader = res.body.getReader();
assert_false(res.bodyUsed); assert_false(res.bodyUsed);
assert_throws({name: 'TypeError'}, () => res.clone()); assert_throws_js(TypeError, () => res.clone());
reader.releaseLock(); reader.releaseLock();
}, 'Locked => clone'); }, 'Locked => clone');
...@@ -440,11 +440,11 @@ promise_test(function() { ...@@ -440,11 +440,11 @@ promise_test(function() {
assert_equals(response.headers.get('location'), assert_equals(response.headers.get('location'),
'https://www.example.com/test.html', 'https://www.example.com/test.html',
'Location header should be correct absoulte URL'); 'Location header should be correct absoulte URL');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { function() {
response.headers.append('Accept-Language', 'test'); response.headers.append('Accept-Language', 'test');
}, },
'response.headers must throw since guard is immutable'); 'response.headers must throw since guard is immutable');
}); });
}, 'Response.redirect() with default status value'); }, 'Response.redirect() with default status value');
......
...@@ -7,7 +7,7 @@ promise_test(function(t) { ...@@ -7,7 +7,7 @@ promise_test(function(t) {
return fetch('/fetch/resources/doctype.html').then(function(res) { return fetch('/fetch/resources/doctype.html').then(function(res) {
var stream = res.body; var stream = res.body;
var reader = stream.getReader(); var reader = stream.getReader();
assert_throws({name: 'TypeError'}, function() { stream.getReader() }); assert_throws_js(TypeError, function() { stream.getReader() });
reader.releaseLock(); reader.releaseLock();
var another = stream.getReader(); var another = stream.getReader();
assert_not_equals(another, reader); assert_not_equals(another, reader);
......
...@@ -544,7 +544,7 @@ ...@@ -544,7 +544,7 @@
test.expectEvent(sourceBuffer, 'update', 'Append success.'); test.expectEvent(sourceBuffer, 'update', 'Append success.');
test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
assert_throws( { name: 'TypeError'} , assert_throws_js( TypeError,
function() { sourceBuffer.appendBuffer(null); }, function() { sourceBuffer.appendBuffer(null); },
'appendBuffer(null) throws an exception.'); 'appendBuffer(null) throws an exception.');
test.done(); test.done();
...@@ -559,7 +559,7 @@ ...@@ -559,7 +559,7 @@
test.expectEvent(sourceBuffer, 'update', 'Append success.'); test.expectEvent(sourceBuffer, 'update', 'Append success.');
test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
assert_throws( { name: 'TypeError'} , assert_throws_js( TypeError,
function() { sourceBuffer.appendBuffer(new Uint8Array(new SharedArrayBuffer(16))); }, function() { sourceBuffer.appendBuffer(new Uint8Array(new SharedArrayBuffer(16))); },
'appendBuffer() of SharedArrayBuffer view throws an exception.'); 'appendBuffer() of SharedArrayBuffer view throws an exception.');
test.done(); test.done();
......
...@@ -32,51 +32,51 @@ ...@@ -32,51 +32,51 @@
assert_true(sourceBuffer != null, 'New SourceBuffer returned'); assert_true(sourceBuffer != null, 'New SourceBuffer returned');
sourceBuffer.appendWindowEnd = 500.0; sourceBuffer.appendWindowEnd = 500.0;
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowStart = Number.NEGATIVE_INFINITY; }, function() { sourceBuffer.appendWindowStart = Number.NEGATIVE_INFINITY; },
'set appendWindowStart throws an exception for Number.NEGATIVE_INFINITY.'); 'set appendWindowStart throws an exception for Number.NEGATIVE_INFINITY.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowStart = Number.POSITIVE_INFINITY; }, function() { sourceBuffer.appendWindowStart = Number.POSITIVE_INFINITY; },
'set appendWindowStart throws an exception for Number.POSITIVE_INFINITY.'); 'set appendWindowStart throws an exception for Number.POSITIVE_INFINITY.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowStart = Number.NaN; }, function() { sourceBuffer.appendWindowStart = Number.NaN; },
'set appendWindowStart throws an exception for Number.NaN.'); 'set appendWindowStart throws an exception for Number.NaN.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowStart = 600.0; }, function() { sourceBuffer.appendWindowStart = 600.0; },
'set appendWindowStart throws an exception when greater than appendWindowEnd.'); 'set appendWindowStart throws an exception when greater than appendWindowEnd.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowStart = sourceBuffer.appendWindowEnd; }, function() { sourceBuffer.appendWindowStart = sourceBuffer.appendWindowEnd; },
'set appendWindowStart throws an exception when equal to appendWindowEnd.'); 'set appendWindowStart throws an exception when equal to appendWindowEnd.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowEnd = sourceBuffer.appendWindowStart; }, function() { sourceBuffer.appendWindowEnd = sourceBuffer.appendWindowStart; },
'set appendWindowEnd throws an exception when equal to appendWindowStart.'); 'set appendWindowEnd throws an exception when equal to appendWindowStart.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowEnd = sourceBuffer.appendWindowStart - 1; }, function() { sourceBuffer.appendWindowEnd = sourceBuffer.appendWindowStart - 1; },
'set appendWindowEnd throws an exception if less than appendWindowStart.'); 'set appendWindowEnd throws an exception if less than appendWindowStart.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowStart = -100.0; }, function() { sourceBuffer.appendWindowStart = -100.0; },
'set appendWindowStart throws an exception when less than 0.'); 'set appendWindowStart throws an exception when less than 0.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowEnd = -100.0; }, function() { sourceBuffer.appendWindowEnd = -100.0; },
'set appendWindowEnd throws an exception when less than 0.'); 'set appendWindowEnd throws an exception when less than 0.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowEnd = Number.NaN; }, function() { sourceBuffer.appendWindowEnd = Number.NaN; },
'set appendWindowEnd throws an exception if NaN.'); 'set appendWindowEnd throws an exception if NaN.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowEnd = undefined; }, function() { sourceBuffer.appendWindowEnd = undefined; },
'set appendWindowEnd throws an exception if undefined.'); 'set appendWindowEnd throws an exception if undefined.');
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.appendWindowStart = undefined; }, function() { sourceBuffer.appendWindowStart = undefined; },
'set appendWindowStart throws an exception if undefined.'); 'set appendWindowStart throws an exception if undefined.');
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
test.waitForExpectedEvents(function() test.waitForExpectedEvents(function()
{ {
if (expectTypeError) { if (expectTypeError) {
assert_throws({name: "TypeError"}, assert_throws_js(TypeError,
function() { mediaSource.duration = testDurationValue; }, function() { mediaSource.duration = testDurationValue; },
"mediaSource.duration assignment throws an exception for " + testDurationValue); "mediaSource.duration assignment throws an exception for " + testDurationValue);
test.done(); test.done();
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type); var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type);
if (expected == 'TypeError') { if (expected == 'TypeError') {
assert_throws({name: 'TypeError'}, assert_throws_js(TypeError,
function() { sourceBuffer.timestampOffset = value; }, function() { sourceBuffer.timestampOffset = value; },
'setting timestampOffset to ' + description + ' throws an exception.'); 'setting timestampOffset to ' + description + ' throws an exception.');
} else { } else {
......
...@@ -3,7 +3,7 @@ importScripts('../../serviceworker/resources/worker-testharness.js'); ...@@ -3,7 +3,7 @@ importScripts('../../serviceworker/resources/worker-testharness.js');
test(function() { test(function() {
assert_true('Notification' in self); assert_true('Notification' in self);
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
new Notification(); new Notification();
}); });
......
...@@ -15,47 +15,47 @@ window.screen.orientation.addEventListener('change', test.step_func(onOrientatio ...@@ -15,47 +15,47 @@ window.screen.orientation.addEventListener('change', test.step_func(onOrientatio
test.step(function() { test.step(function() {
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock('invalid-orientation'); screen.lock('invalid-orientation');
}); });
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock(null); screen.lock(null);
}); });
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock(undefined); screen.lock(undefined);
}); });
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock(undefined); screen.lock(undefined);
}); });
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock(123); screen.lock(123);
}); });
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock(window); screen.lock(window);
}); });
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock(['portrait-primary']); screen.lock(['portrait-primary']);
}); });
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock(['portrait-primary', 'landscape-primary']); screen.lock(['portrait-primary', 'landscape-primary']);
}); });
assert_equals(screen.orientation.type, 'portrait-primary'); assert_equals(screen.orientation.type, 'portrait-primary');
assert_throws({ name: 'TypeError' }, function() { assert_throws_js(TypeError, function() {
screen.lock(); screen.lock();
}); });
}); });
......
...@@ -19,7 +19,7 @@ test(() => { ...@@ -19,7 +19,7 @@ test(() => {
assert_equals(Object.getPrototypeOf(root2), ShadowRoot.prototype, assert_equals(Object.getPrototypeOf(root2), ShadowRoot.prototype,
'ShadowRoot object should be returned by attachShadow({mode:"closed"}).'); 'ShadowRoot object should be returned by attachShadow({mode:"closed"}).');
assert_throws({name: 'TypeError'}, () => { host3.attachShadow({mode: 'illegal'}); }, assert_throws_js(TypeError, () => { host3.attachShadow({mode: 'illegal'}); },
'Attach shadow root whose mode is neither open nor closed should throw TypeError.'); 'Attach shadow root whose mode is neither open nor closed should throw TypeError.');
assert_throws_dom('NotSupportedError', () => { host1.attachShadow({mode: 'open'}); }, assert_throws_dom('NotSupportedError', () => { host1.attachShadow({mode: 'open'}); },
......
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