mirror of
https://github.com/servo/servo.git
synced 2025-10-14 15:30:27 +01:00
84 lines
2.8 KiB
HTML
84 lines
2.8 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('message', {errorDetail:'data-channel-failure'});
|
|
assert_equals(error.message, 'message');
|
|
assert_equals(error.errorDetail, 'data-channel-failure');
|
|
}, 'RTCError constructor with message and errorDetail');
|
|
|
|
test(() => {
|
|
assert_throws(new TypeError(), () => {
|
|
new RTCError('message');
|
|
});
|
|
assert_throws(new TypeError(), () => {
|
|
new RTCError();
|
|
});
|
|
}, 'RTCError constructor throws TypeError if any argument is missing');
|
|
|
|
test(() => {
|
|
assert_throws(new TypeError(), () => {
|
|
new RTCError('message', {errorDetail:'invalid-error-detail'});
|
|
});
|
|
}, 'RTCError constructor throws TypeError if the errorDetail is invalid');
|
|
|
|
test(() => {
|
|
const error = new RTCError('message', {errorDetail:'data-channel-failure'});
|
|
assert_equals(error.name, 'RTCError');
|
|
}, 'RTCError.name is \'RTCError\'');
|
|
|
|
test(() => {
|
|
const error = new RTCError('message', {errorDetail:'data-channel-failure'});
|
|
assert_equals(error.code, 0);
|
|
}, 'RTCError.code is 0');
|
|
|
|
test(() => {
|
|
const error = new RTCError('message', {errorDetail:'data-channel-failure'});
|
|
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('message', {errorDetail:'data-channel-failure'});
|
|
}, '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('message', {errorDetail:'data-channel-failure'});
|
|
assert_equals(error[attribute], null);
|
|
}, 'RTCError.' + attribute + ' is null by default');
|
|
|
|
test(() => {
|
|
const error = new RTCError('message', {errorDetail:'data-channel-failure',
|
|
[attribute]: 0});
|
|
assert_equals(error[attribute], 0);
|
|
}, 'RTCError.' + attribute + ' is settable by constructor');
|
|
|
|
test(() => {
|
|
const error = new RTCError('message', {errorDetail:'data-channel-failure'});
|
|
assert_throws(new TypeError(), () => {
|
|
error[attribute] = 42;
|
|
});
|
|
}, 'RTCError.' + attribute + ' is readonly');
|
|
});
|
|
|
|
</script>
|