Commit 2decb2db authored by Stephen McGruer's avatar Stephen McGruer Committed by Commit Bot

Change 'assert_throws' --> 'assert_throws_{js, dom}' in http/

Tackling the set of calls that avoided the automated refactor (for
various reasons). There are about 50 in total, split up into a few CLs
to make reviewing it easier.

Bug: 1051932
Change-Id: Ie8cb346bcd4104c11dcb41f001b26cdc260948b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2082905
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746557}
parent 38fa0002
......@@ -11,7 +11,7 @@ test(() => {
const response = new Response(rs);
try {
// This throws different errors depending on how Blink is built, so
// assert_throws() cannot be used.
// assert_throws_{js, dom}() cannot be used.
fillStackAndRun(() => response.clone(), 784);
assert_unreached('stack should overflow');
} catch (e) {
......
......@@ -714,33 +714,33 @@ test(() => {
// functionality here. We now generate RequestInit with the IDL compiler,
// but it's still good to keep these around.
const e = Error();
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get method() { throw e; }})}, 'method');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get headers() { throw e; }})}, 'headers');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get body() { throw e; }})}, 'body');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get referrer() { throw e; }})}, 'referrer');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get referrerPolicy() { throw e; }})}, 'referrerPolicy');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get mode() { throw e; }})}, 'mode');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get credentials() { throw e; }})}, 'credentials');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get cache() { throw e; }})}, 'cache');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get redirect() { throw e; }})}, 'redirect');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get integrity() { throw e; }})}, 'integrity');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get keepalive() { throw e; }})}, 'keepalive');
assert_throws(e, () => {
assert_throws_exactly(e, () => {
new Request('/', {get signal() { throw e; }})}, 'signal');
// Not implemented
// assert_throws(e, () => {
// assert_throws_exactly(e, () => {
// new Request('/', {get window() { throw e; }})}, 'window');
}, 'Getter exceptions should not be silently ignored');
......@@ -752,14 +752,13 @@ test(() => {
// instead of `AbortSignal` due to a bug in the IDL compiler, and performed
// conversions manually. This test ensures that conversion were carried out
// properly.
const e = TypeError();
assert_throws(e, () => {
assert_throws_js(TypeError, () => {
new Request('/', {signal: {}})},
'An empty object as RequestInit\'s signal member should fail type conversion');
assert_throws(e, () => {
assert_throws_js(TypeError, () => {
new Request('/', {signal: new Request('/')})},
'A Request object as RequestInit\'s signal member should fail type conversion');
assert_throws(e, () => {
assert_throws_js(TypeError, () => {
new Request('/', {signal: new Response('/')})},
'A Response object as RequestInit\'s signal member should fail type conversion');
}, 'TypeError should be thrown when RequestInit\'s signal member does not implement the AbortSignal interface');
......
......@@ -135,12 +135,12 @@ test(function() {
test(function() {
[0, 1, 100, 101, 199, 600, 700].forEach(function(status) {
assert_throws({name: 'RangeError'},
function() {
new Response(new Blob(), {status: status});
},
'new Response with status = ' + status +
' should throw');
assert_throws_js(RangeError,
function() {
new Response(new Blob(), {status: status});
},
'new Response with status = ' + status +
' should throw');
});
[204, 205, 304].forEach(function(status) {
......@@ -153,13 +153,13 @@ test(function() {
});
[300, 0, 304, 305, 306, 309, 500].forEach(function(status) {
assert_throws({name: 'RangeError'},
function() {
Response.redirect('https://www.example.com/test.html',
status);
},
'Response.redirect() with invalid status = ' + status +
' should throw');
assert_throws_js(RangeError,
function() {
Response.redirect('https://www.example.com/test.html',
status);
},
'Response.redirect() with invalid status = ' + status +
' should throw');
});
assert_throws_js(
......
......@@ -21,7 +21,7 @@
sourceBuffer.appendBuffer(mediaData);
test.waitForExpectedEvents(function()
{
assert_throws({name: "QuotaExceededError"},
assert_throws_dom("QuotaExceededError",
function() { mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE); },
"addSourceBuffer must throw an exception if the MediaSource has already received init segments for all sourcebuffers added at the time");
test.done();
......@@ -51,7 +51,7 @@
{
// MediaSource is fully initialized now, so adding new SourceBuffers is no longer possible.
assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_METADATA);
assert_throws({name: "QuotaExceededError"},
assert_throws_dom("QuotaExceededError",
function() { mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE); },
"addSourceBuffer must throw an exception if the media element has already reached HAVE_METADATA");
test.done();
......
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