mirror of
https://github.com/servo/servo.git
synced 2025-08-16 10:55:34 +01:00
Update web-platform-tests to revision ab64b78a8f6777a1d95d8d1d4bba9ccdbecf94ea
This commit is contained in:
parent
da36740f0b
commit
394aced19f
713 changed files with 12430 additions and 12632 deletions
|
@ -17,7 +17,7 @@ function makeIceTransport(t) {
|
|||
|
||||
test(() => {
|
||||
const iceTransport = new RTCIceTransport();
|
||||
}, 'RTCIceTransport constructor does not throw.');
|
||||
}, 'RTCIceTransport constructor does not throw');
|
||||
|
||||
test(() => {
|
||||
const iceTransport = new RTCIceTransport();
|
||||
|
@ -35,7 +35,7 @@ test(() => {
|
|||
'Expect local parameters generated');
|
||||
assert_equals(iceTransport.getRemoteParameters(), null,
|
||||
'Expect no remote parameters');
|
||||
}, 'RTCIceTransport initial properties are set.');
|
||||
}, 'RTCIceTransport initial properties are set');
|
||||
|
||||
test(t => {
|
||||
const iceTransport = makeIceTransport(t);
|
||||
|
@ -125,4 +125,147 @@ promise_test(async t => {
|
|||
}, `gather() returns no candidates with { gatherPolicy: 'relay'} and no turn` +
|
||||
' servers');
|
||||
|
||||
const dummyRemoteParameters = {
|
||||
usernameFragment: 'dummyUsernameFragment',
|
||||
password: 'dummyPassword',
|
||||
};
|
||||
|
||||
test(() => {
|
||||
const iceTransport = new RTCIceTransport();
|
||||
iceTransport.stop();
|
||||
assert_throws('InvalidStateError',
|
||||
() => iceTransport.start(dummyRemoteParameters));
|
||||
assert_equals(iceTransport.getRemoteParameters(), null);
|
||||
}, `start() throws if closed`);
|
||||
|
||||
test(() => {
|
||||
const iceTransport = new RTCIceTransport();
|
||||
assert_throws(new TypeError(), () => iceTransport.start({}));
|
||||
assert_throws(new TypeError(),
|
||||
() => iceTransport.start({ usernameFragment: 'dummy' }));
|
||||
assert_throws(new TypeError(),
|
||||
() => iceTransport.start({ password: 'dummy' }));
|
||||
assert_equals(iceTransport.getRemoteParameters(), null);
|
||||
}, 'start() throws if usernameFragment or password not set');
|
||||
|
||||
const assert_ice_parameters_equals = (a, b) => {
|
||||
assert_equals(a.usernameFragment, b.usernameFragment,
|
||||
'usernameFragments are equal');
|
||||
assert_equals(a.password, b.password, 'passwords are equal');
|
||||
};
|
||||
|
||||
test(t => {
|
||||
const iceTransport = makeIceTransport(t);
|
||||
iceTransport.start(dummyRemoteParameters);
|
||||
assert_equals(iceTransport.state, 'new');
|
||||
assert_ice_parameters_equals(iceTransport.getRemoteParameters(),
|
||||
dummyRemoteParameters);
|
||||
}, `start() does not transition state to 'checking' if no remote candidates ` +
|
||||
'added');
|
||||
|
||||
test(t => {
|
||||
const iceTransport = makeIceTransport(t);
|
||||
iceTransport.start(dummyRemoteParameters);
|
||||
assert_equals(iceTransport.role, 'controlled');
|
||||
}, `start() with default role sets role attribute to 'controlled'`);
|
||||
|
||||
test(t => {
|
||||
const iceTransport = makeIceTransport(t);
|
||||
iceTransport.start(dummyRemoteParameters, 'controlling');
|
||||
assert_equals(iceTransport.role, 'controlling');
|
||||
}, `start() sets role attribute to 'controlling'`);
|
||||
|
||||
const candidate1 = new RTCIceCandidate({
|
||||
candidate: 'candidate:1 1 udp 2113929471 203.0.113.100 10100 typ host',
|
||||
});
|
||||
|
||||
test(() => {
|
||||
const iceTransport = new RTCIceTransport();
|
||||
iceTransport.stop();
|
||||
assert_throws('InvalidStateError',
|
||||
() => iceTransport.addRemoteCandidate(candidate1));
|
||||
assert_array_equals(iceTransport.getRemoteCandidates(), []);
|
||||
}, 'addRemoteCandidate() throws if closed');
|
||||
|
||||
test(() => {
|
||||
const iceTransport = new RTCIceTransport();
|
||||
assert_throws('OperationError',
|
||||
() => iceTransport.addRemoteCandidate(
|
||||
new RTCIceCandidate({ candidate: 'invalid' })));
|
||||
assert_array_equals(iceTransport.getRemoteCandidates(), []);
|
||||
}, 'addRemoteCandidate() throws on invalid candidate');
|
||||
|
||||
test(t => {
|
||||
const iceTransport = makeIceTransport(t);
|
||||
iceTransport.addRemoteCandidate(candidate1);
|
||||
iceTransport.start(dummyRemoteParameters);
|
||||
assert_equals(iceTransport.state, 'checking');
|
||||
assert_array_equals(iceTransport.getRemoteCandidates(), [candidate1]);
|
||||
}, `start() transitions state to 'checking' if one remote candidate had been ` +
|
||||
'added');
|
||||
|
||||
test(t => {
|
||||
const iceTransport = makeIceTransport(t);
|
||||
iceTransport.start(dummyRemoteParameters);
|
||||
iceTransport.addRemoteCandidate(candidate1);
|
||||
assert_equals(iceTransport.state, 'checking');
|
||||
assert_array_equals(iceTransport.getRemoteCandidates(), [candidate1]);
|
||||
}, `addRemoteCandidate() transitions state to 'checking' if start() had been ` +
|
||||
'called before');
|
||||
|
||||
test(t => {
|
||||
const iceTransport = makeIceTransport(t);
|
||||
iceTransport.start(dummyRemoteParameters);
|
||||
assert_throws('InvalidStateError',
|
||||
() => iceTransport.start(dummyRemoteParameters, 'controlling'));
|
||||
}, 'start() throws if later called with a different role');
|
||||
|
||||
test(t => {
|
||||
const iceTransport = makeIceTransport(t);
|
||||
iceTransport.start({
|
||||
usernameFragment: 'user',
|
||||
password: 'pass',
|
||||
});
|
||||
iceTransport.addRemoteCandidate(candidate1);
|
||||
const changedRemoteParameters = {
|
||||
usernameFragment: 'user2',
|
||||
password: 'pass',
|
||||
};
|
||||
iceTransport.start(changedRemoteParameters);
|
||||
assert_equals(iceTransport.state, 'new');
|
||||
assert_array_equals(iceTransport.getRemoteCandidates(), []);
|
||||
assert_ice_parameters_equals(iceTransport.getRemoteParameters(),
|
||||
changedRemoteParameters);
|
||||
}, `start() flushes remote candidates and transitions state to 'new' if ` +
|
||||
'later called with different remote parameters');
|
||||
|
||||
promise_test(async t => {
|
||||
const localTransport = makeIceTransport(t);
|
||||
const remoteTransport = makeIceTransport(t);
|
||||
localTransport.onicecandidate = e => {
|
||||
if (e.candidate) {
|
||||
remoteTransport.addRemoteCandidate(e.candidate);
|
||||
}
|
||||
};
|
||||
remoteTransport.onicecandidate = e => {
|
||||
if (e.candidate) {
|
||||
localTransport.addRemoteCandidate(e.candidate);
|
||||
}
|
||||
};
|
||||
localTransport.gather({});
|
||||
remoteTransport.gather({});
|
||||
localTransport.start(remoteTransport.getLocalParameters(), 'controlling');
|
||||
remoteTransport.start(localTransport.getLocalParameters(), 'controlled');
|
||||
const localWatcher = new EventWatcher(t, localTransport, 'statechange');
|
||||
const remoteWatcher = new EventWatcher(t, remoteTransport, 'statechange');
|
||||
await Promise.all([
|
||||
localWatcher.wait_for('statechange').then(() => {
|
||||
assert_equals(localTransport.state, 'connected');
|
||||
}),
|
||||
remoteWatcher.wait_for('statechange').then(() => {
|
||||
assert_equals(remoteTransport.state, 'connected');
|
||||
}),
|
||||
]);
|
||||
}, 'Two RTCIceTransports connect to each other');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>RTCQuicTransport.https.html</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
// These tests are based on the following specification:
|
||||
// https://w3c.github.io/webrtc-quic/
|
||||
|
||||
function makeQuicTransport(t, certificates) {
|
||||
const iceTransport = new RTCIceTransport();
|
||||
t.add_cleanup(() => iceTransport.stop());
|
||||
const quicTransport = new RTCQuicTransport(iceTransport, certificates);
|
||||
t.add_cleanup(() => quicTransport.stop());
|
||||
return quicTransport;
|
||||
}
|
||||
|
||||
function generateCertificate(keygenAlgorithm) {
|
||||
return RTCPeerConnection.generateCertificate({
|
||||
name: 'ECDSA',
|
||||
namedCurve: 'P-256',
|
||||
...keygenAlgorithm,
|
||||
});
|
||||
}
|
||||
|
||||
test(t => {
|
||||
// Don't use the makeQuicTransport helper so that the transport property can
|
||||
// be verified.
|
||||
const iceTransport = new RTCIceTransport();
|
||||
const quicTransport = new RTCQuicTransport(iceTransport, []);
|
||||
t.add_cleanup(() => {
|
||||
quicTransport.stop();
|
||||
iceTransport.stop();
|
||||
});
|
||||
assert_equals(quicTransport.transport, iceTransport,
|
||||
'Expect transport to be the same as the one passed in the constructor.');
|
||||
assert_equals(quicTransport.state, 'new', `Expect state to be 'new'.`);
|
||||
assert_object_equals(quicTransport.getLocalParameters(),
|
||||
{ role: 'auto', fingerprints: [] },
|
||||
'Expect local parameters to be initialized.');
|
||||
assert_equals(quicTransport.getRemoteParameters(), null,
|
||||
'Expect no remote parameters.');
|
||||
assert_array_equals(quicTransport.getCertificates(), [],
|
||||
'Expect not certificates.');
|
||||
assert_array_equals(quicTransport.getRemoteCertificates(), [],
|
||||
'Expect no remote certificates.');
|
||||
}, 'RTCQuicTransport initial properties are set.');
|
||||
|
||||
promise_test(async t => {
|
||||
const [ firstCertificate, secondCertificate ] =
|
||||
await Promise.all([ generateCertificate(), generateCertificate() ]);
|
||||
const quicTransport =
|
||||
makeQuicTransport(t, [ firstCertificate, secondCertificate ]);
|
||||
assert_array_equals(quicTransport.getCertificates(),
|
||||
[ firstCertificate, secondCertificate ]);
|
||||
}, 'getCertificates() returns the certificates passed in the constructor.');
|
||||
|
||||
promise_test(async t => {
|
||||
const [ firstCertificate, secondCertificate ] =
|
||||
await Promise.all([ generateCertificate(), generateCertificate() ]);
|
||||
const quicTransport =
|
||||
makeQuicTransport(t, [ firstCertificate, secondCertificate ]);
|
||||
assert_object_equals(quicTransport.getLocalParameters(), {
|
||||
role: 'auto',
|
||||
fingerprints: [ firstCertificate.getFingerprints()[0],
|
||||
secondCertificate.getFingerprints()[0] ],
|
||||
});
|
||||
assert_array_equals(quicTransport.getCertificates(),
|
||||
[ firstCertificate, secondCertificate ]);
|
||||
}, 'getLocalParameters() has fingerprints for all certificates passed in the ' +
|
||||
'constructor.');
|
||||
|
||||
promise_test(async t => {
|
||||
const expiredCertificate = await generateCertificate({ expires: 0 });
|
||||
assert_throws(new TypeError(),
|
||||
() => makeQuicTransport(t, [ expiredCertificate ]));
|
||||
}, 'RTCQuicTransport constructor throws if passed an expired certificate.');
|
||||
|
||||
test(t => {
|
||||
const iceTransport = new RTCIceTransport();
|
||||
iceTransport.stop();
|
||||
assert_throws('InvalidStateError',
|
||||
() => new RTCQuicTransport(iceTransport, []));
|
||||
}, 'RTCQuicTransport constructor throws if passed a closed RTCIceTransport.');
|
||||
|
||||
test(t => {
|
||||
const quicTransport = makeQuicTransport(t, []);
|
||||
quicTransport.stop();
|
||||
assert_equals(quicTransport.state, 'closed');
|
||||
}, `stop() changes state to 'closed'.`);
|
||||
|
||||
</script>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue