mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 13:18:45 +02:00
Automatic update from web-platform-tests RTCError: Make "message" optional and be the last argument. Based on https://github.com/w3c/webrtc-pc/pull/2112. Bug: 937844 Change-Id: I7ad149f47fb394f15055cc8fd77e79b4e5e0f317 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1499613 Commit-Queue: Henrik Boström <hbos@chromium.org> Reviewed-by: Marina Ciocea <marinaciocea@chromium.org> Cr-Commit-Position: refs/heads/master@{#638192} -- wpt-commits: e8831d9d354972a39ccfe388dd99eb5e2a6249a8 wpt-pr: 15651
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(new TypeError(), () => {
|
|
new RTCError();
|
|
});
|
|
assert_throws(new TypeError(), () => {
|
|
new RTCError({}); // {errorDetail} is missing.
|
|
});
|
|
}, 'RTCError constructor throws TypeError if arguments are missing');
|
|
|
|
test(() => {
|
|
assert_throws(new 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, 'RTCError');
|
|
}, 'RTCError.name is \'RTCError\'');
|
|
|
|
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(new 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(new 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(new TypeError(), () => {
|
|
error[attribute] = 42;
|
|
});
|
|
}, 'RTCError.' + attribute + ' is readonly');
|
|
});
|
|
|
|
</script>
|