mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 05:39:41 +02:00
Automatic update from web-platform-tests Replace some "assert_throws(new FooError(), stuff)" calls with assert_throws_js. (#21354) This diff was generated by running: find . -type f -print0 | xargs -0 perl -pi -e 'BEGIN { $/ = undef; } s/assert_throws\(([ \n]*)new ([A-Za-z]*Error) *\(\) *(, *.)/assert_throws_js(\1\2\3/gs' and then: 1) Manually adjusting fullscreen/rendering/fullscreen-pseudo-class-support.html to test for the right sort of exceptions ("SyntaxError" DOMException, not a JS SyntaxError). 2) Manually adjusting performance-timeline/po-observe-type.any.js to test for the right sort of exceptions ("SyntaxError" DOMException, not a JS SyntaxError). 3) Manually adjusting performance-timeline/po-observe.any.js to test for the right sort of exceptions ("SyntaxError" DOMException, not a JS SyntaxError). 4) Manually adjusting user-timing/mark_exceptions.html to test for the right sort of exceptions ("SyntaxError" DOMException, not a JS SyntaxError). 5) Manually adjusting user-timing/measure_syntax_err.any.js to test for the right sort of exceptions ("SyntaxError" DOMException, not a JS SyntaxError). 6) Manually adjusting domxpath/lexical-structure.html to test for a "SyntaxError" DOMException, since that's what all browsers throw and there is no clear spec for this. 7) Manually adjusting workers/constructors/Worker/Worker-constructor.html to test for the right sort of exceptions ("SyntaxError" DOMException, not a JS SyntaxError). 8) Backing out the changes to resources/idlharness.js because some tests pass objects from a different window to it, and we end up with the wrong TypeError constructor in those cases. This does affect indentation poorly in cases when the first arg was on the same line as the assert_throws, there was a newline after the ',' after the first arg, and the following args were lined up with the first arg. Fixing that, especially when there are multiple lines after the first arg, is not trivial with a regexp. Co-authored-by: Boris Zbarsky <bzbarsky@mit.edu> Co-authored-by: Stephen McGruer <smcgruer@chromium.org> -- wpt-commits: 2c5c3c4c27d27a419c1fdba3e9879c2d22037074 wpt-pr: 21354
89 lines
2.9 KiB
HTML
89 lines
2.9 KiB
HTML
<!doctype html>
|
|
<meta charset=utf-8>
|
|
<title>RTCError and RTCErrorInit</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="RTCPeerConnection-helper.js"></script>
|
|
<script>
|
|
'use strict';
|
|
|
|
test(() => {
|
|
const error = new RTCError({errorDetail:'data-channel-failure'}, 'message');
|
|
assert_equals(error.message, 'message');
|
|
assert_equals(error.errorDetail, 'data-channel-failure');
|
|
}, 'RTCError constructor with errorDetail and message');
|
|
|
|
test(() => {
|
|
const error = new RTCError({errorDetail:'data-channel-failure'});
|
|
assert_equals(error.message, '');
|
|
}, 'RTCError constructor\'s message argument is optional');
|
|
|
|
test(() => {
|
|
assert_throws_js(TypeError, () => {
|
|
new RTCError();
|
|
});
|
|
assert_throws_js(TypeError, () => {
|
|
new RTCError({}); // {errorDetail} is missing.
|
|
});
|
|
}, 'RTCError constructor throws TypeError if arguments are missing');
|
|
|
|
test(() => {
|
|
assert_throws_js(TypeError, () => {
|
|
new RTCError({errorDetail:'invalid-error-detail'}, 'message');
|
|
});
|
|
}, 'RTCError constructor throws TypeError if the errorDetail is invalid');
|
|
|
|
test(() => {
|
|
const error = new RTCError({errorDetail:'data-channel-failure'}, 'message');
|
|
assert_equals(error.name, 'OperationError');
|
|
}, 'RTCError.name is \'OperationError\'');
|
|
|
|
test(() => {
|
|
const error = new RTCError({errorDetail:'data-channel-failure'}, 'message');
|
|
assert_equals(error.code, 0);
|
|
}, 'RTCError.code is 0');
|
|
|
|
test(() => {
|
|
const error = new RTCError({errorDetail:'data-channel-failure'}, 'message');
|
|
assert_throws_js(TypeError, () => {
|
|
error.errorDetail = 'dtls-failure';
|
|
});
|
|
}, 'RTCError.errorDetail is readonly.');
|
|
|
|
test(() => {
|
|
// Infers what are valid RTCErrorInit objects by passing them to the RTCError
|
|
// constructor.
|
|
assert_throws_js(TypeError, () => {
|
|
new RTCError({}, 'message');
|
|
});
|
|
new RTCError({errorDetail:'data-channel-failure'}, 'message');
|
|
}, 'RTCErrorInit.errorDetail is the only required attribute');
|
|
|
|
// All of these are number types (long or unsigned long).
|
|
const nullableAttributes = ['sdpLineNumber',
|
|
'httpRequestStatusCode',
|
|
'sctpCauseCode',
|
|
'receivedAlert',
|
|
'sentAlert'];
|
|
|
|
nullableAttributes.forEach(attribute => {
|
|
test(() => {
|
|
const error = new RTCError({errorDetail:'data-channel-failure'}, 'message');
|
|
assert_equals(error[attribute], null);
|
|
}, 'RTCError.' + attribute + ' is null by default');
|
|
|
|
test(() => {
|
|
const error = new RTCError(
|
|
{errorDetail:'data-channel-failure', [attribute]: 0}, 'message');
|
|
assert_equals(error[attribute], 0);
|
|
}, 'RTCError.' + attribute + ' is settable by constructor');
|
|
|
|
test(() => {
|
|
const error = new RTCError({errorDetail:'data-channel-failure'}, 'message');
|
|
assert_throws_js(TypeError, () => {
|
|
error[attribute] = 42;
|
|
});
|
|
}, 'RTCError.' + attribute + ' is readonly');
|
|
});
|
|
|
|
</script>
|