mirror of
https://github.com/servo/servo.git
synced 2025-09-09 22:48:21 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
|
@ -8,7 +8,7 @@
|
|||
'use strict';
|
||||
|
||||
// Test is based on the following editor draft:
|
||||
// https://w3c.github.io/webrtc-pc/archives/20170515/webrtc.html
|
||||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer()
|
||||
|
@ -16,86 +16,37 @@
|
|||
// assert_session_desc_not_equals()
|
||||
// assert_session_desc_equals()
|
||||
// test_state_change_event()
|
||||
// test_never_resolve()
|
||||
|
||||
/*
|
||||
* 4.3.2. setRemoteDescription(offer)
|
||||
4.3.2. Interface Definition
|
||||
[Constructor(optional RTCConfiguration configuration)]
|
||||
interface RTCPeerConnection : EventTarget {
|
||||
Promise<void> setRemoteDescription(
|
||||
RTCSessionDescriptionInit description);
|
||||
|
||||
readonly attribute RTCSessionDescription? remoteDescription;
|
||||
readonly attribute RTCSessionDescription? currentRemoteDescription;
|
||||
readonly attribute RTCSessionDescription? pendingRemoteDescription;
|
||||
...
|
||||
};
|
||||
|
||||
4.6.2. RTCSessionDescription Class
|
||||
dictionary RTCSessionDescriptionInit {
|
||||
required RTCSdpType type;
|
||||
DOMString sdp = "";
|
||||
};
|
||||
|
||||
4.6.1. RTCSdpType
|
||||
enum RTCSdpType {
|
||||
"offer",
|
||||
"pranswer",
|
||||
"answer",
|
||||
"rollback"
|
||||
};
|
||||
*/
|
||||
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
test_state_change_event(t, pc, ['have-remote-offer']);
|
||||
|
||||
return generateOffer({ data: true })
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(offer => {
|
||||
assert_equals(pc.signalingState, 'have-remote-offer');
|
||||
assert_session_desc_equals(pc.remoteDescription, offer);
|
||||
assert_session_desc_equals(pc.pendingRemoteDescription, offer);
|
||||
assert_equals(pc.currentRemoteDescription, null);
|
||||
}));
|
||||
}, 'setRemoteDescription with valid offer should succeed');
|
||||
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
// have-remote-offer event should only fire once
|
||||
test_state_change_event(t, pc, ['have-remote-offer']);
|
||||
|
||||
return Promise.all([
|
||||
generateOffer({ audio: true }),
|
||||
generateOffer({ data: true })
|
||||
]).then(([offer1, offer2]) =>
|
||||
pc.setRemoteDescription(offer1)
|
||||
.then(() => pc.setRemoteDescription(offer2))
|
||||
.then(() => {
|
||||
assert_equals(pc.signalingState, 'have-remote-offer');
|
||||
assert_session_desc_equals(pc.remoteDescription, offer2);
|
||||
assert_session_desc_equals(pc.pendingRemoteDescription, offer2);
|
||||
assert_equals(pc.currentRemoteDescription, null);
|
||||
}));
|
||||
}, 'Setting remote description multiple times with different offer should succeed');
|
||||
|
||||
test_never_resolve(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
return generateOffer()
|
||||
.then(offer => {
|
||||
const promise = pc.setRemoteDescription(offer);
|
||||
pc.close();
|
||||
return promise;
|
||||
});
|
||||
}, 'setRemoteDescription(offer) should never resolve if connection is closed in parallel')
|
||||
|
||||
/*
|
||||
* 4.3.1. Setting an RTCSessionDescription
|
||||
* 2.4. If the content of description is not valid SDP syntax, then reject p
|
||||
* with an RTCError (with errorDetail set to "sdp-syntax-error" and the
|
||||
* sdpLineNumber attribute set to the line number in the SDP where the
|
||||
* syntax error was detected) and abort these steps.
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
return pc.setRemoteDescription({
|
||||
type: 'offer',
|
||||
sdp: 'Invalid SDP'
|
||||
})
|
||||
.then(() => {
|
||||
assert_unreached('Expect promise to be rejected');
|
||||
}, err => {
|
||||
assert_equals(err.errorDetail, 'sdp-syntax-error',
|
||||
'Expect error detail field to set to sdp-syntax-error');
|
||||
|
||||
assert_true(err instanceof RTCError,
|
||||
'Expect err to be instance of RTCError');
|
||||
});
|
||||
}, 'setRemoteDescription(offer) with invalid SDP should reject with RTCError');
|
||||
|
||||
/*
|
||||
* 4.6.1. enum RTCSdpType
|
||||
4.6.1. enum RTCSdpType
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
@ -106,7 +57,7 @@
|
|||
type: 'bogus',
|
||||
sdp: 'bogus'
|
||||
}));
|
||||
}, 'setRemoteDescription with invalid type and invalid SDP should reject with TypeError')
|
||||
}, 'setRemoteDescription with invalid type and invalid SDP should reject with TypeError');
|
||||
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
@ -117,71 +68,9 @@
|
|||
type: 'answer',
|
||||
sdp: 'invalid'
|
||||
}));
|
||||
}, 'setRemoteDescription() with invalid SDP and stable state should reject with InvalidStateError')
|
||||
}, 'setRemoteDescription() with invalid SDP and stable state should reject with InvalidStateError');
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* Setting an RTCSessionDescription
|
||||
* 2.1.5. If the content of description is invalid, then reject p with
|
||||
* a newly created InvalidAccessError and abort these steps.
|
||||
* 2.2.5-10
|
||||
* setRemoteDescription(rollback)
|
||||
* setRemoteDescription(pranswer)
|
||||
*
|
||||
* Non-testable
|
||||
* Setting an RTCSessionDescription
|
||||
* 6. For all other errors, for example if description cannot be
|
||||
* applied at the media layer, reject p with a newly created OperationError.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 4.3.2. setRemoteDescription(answer)
|
||||
*/
|
||||
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
test_state_change_event(t, pc, ['have-local-offer', 'stable']);
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
.then(offer =>
|
||||
pc.setLocalDescription(offer)
|
||||
.then(() => generateAnswer(offer))
|
||||
.then(answer =>
|
||||
pc.setRemoteDescription(answer)
|
||||
.then(() => {
|
||||
assert_session_desc_equals(pc.localDescription, offer);
|
||||
assert_session_desc_equals(pc.remoteDescription, answer);
|
||||
|
||||
assert_session_desc_equals(pc.currentLocalDescription, offer);
|
||||
assert_session_desc_equals(pc.currentRemoteDescription, answer);
|
||||
|
||||
assert_equals(pc.pendingLocalDescription, null);
|
||||
assert_equals(pc.pendingRemoteDescription, null);
|
||||
})));
|
||||
}, 'setRemoteDescription() with valid state and answer should succeed');
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* 4.3.2 setRemoteDescription
|
||||
* If an a=identity attribute is present in the session description,
|
||||
* the browser validates the identity assertion.
|
||||
*
|
||||
* If the "peerIdentity" configuration is applied to the RTCPeerConnection,
|
||||
* this establishes a target peer identity of the provided value. Alternatively,
|
||||
* if the RTCPeerConnection has previously authenticated the identity of the
|
||||
* peer (that is, there is a current value for peerIdentity ), then this also
|
||||
* establishes a target peer identity.
|
||||
*
|
||||
* The target peer identity cannot be changed once set. Once set,
|
||||
* if a different value is provided, the user agent must reject
|
||||
* the returned promise with a newly created InvalidModificationError
|
||||
* and abort this operation. The RTCPeerConnection must be closed if
|
||||
* the validated peer identity does not match the target peer identity.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Operations after returning to stable state
|
||||
*/
|
||||
/* Operations after returning to stable state */
|
||||
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
@ -190,21 +79,22 @@
|
|||
test_state_change_event(t, pc,
|
||||
['have-remote-offer', 'stable', 'have-remote-offer']);
|
||||
|
||||
return generateOffer({ audio: true })
|
||||
return pc2.createOffer({ offerToReceiveAudio: true })
|
||||
.then(offer1 =>
|
||||
pc.setRemoteDescription(offer1)
|
||||
.then(() => pc.createAnswer())
|
||||
.then(answer => pc.setLocalDescription(answer))
|
||||
.then(() => generateOffer({ data: true }))
|
||||
.then(offer2 =>
|
||||
pc.setRemoteDescription(offer2)
|
||||
.then(() => pc2.createOffer({ offerToReceiveVideo: true }))
|
||||
.then(offer2 => {
|
||||
return pc.setRemoteDescription(offer2)
|
||||
.then(() => {
|
||||
assert_equals(pc.signalingState, 'have-remote-offer');
|
||||
assert_session_desc_not_equals(offer1, offer2);
|
||||
assert_session_desc_equals(pc.remoteDescription, offer2);
|
||||
assert_session_desc_equals(pc.currentRemoteDescription, offer1);
|
||||
assert_session_desc_equals(pc.pendingRemoteDescription, offer2);
|
||||
})));
|
||||
});
|
||||
}));
|
||||
}, 'Calling setRemoteDescription() again after one round of remote-offer/local-answer should succeed');
|
||||
|
||||
promise_test(t => {
|
||||
|
@ -219,7 +109,7 @@
|
|||
.then(() => generateAnswer(offer)))
|
||||
.then(answer =>
|
||||
pc.setRemoteDescription(answer)
|
||||
.then(() => generateOffer({ data: true }))
|
||||
.then(() => generateOffer({ pc, data: true }))
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(() => {
|
||||
|
@ -231,97 +121,10 @@
|
|||
}, 'Switching role from offerer to answerer after going back to stable state should succeed');
|
||||
|
||||
/*
|
||||
* InvalidStateError
|
||||
* [webrtc-pc] 4.3.1. Setting the RTCSessionDescription
|
||||
* 2.3. If the description's type is invalid for the current signaling state
|
||||
* of connection, then reject p with a newly created InvalidStateError
|
||||
* and abort these steps.
|
||||
TODO
|
||||
4.3.2. setRemoteDescription
|
||||
- If an a=identity attribute is present in the session description, the browser
|
||||
validates the identity assertion.
|
||||
*/
|
||||
|
||||
/*
|
||||
* [jsep] 5.6. If the type is "pranswer" or "answer", the PeerConnection
|
||||
* state MUST be either "have-local-offer" or "have-remote-pranswer".
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
return generateOffer()
|
||||
.then(offer =>
|
||||
promise_rejects(t, 'InvalidStateError',
|
||||
pc.setRemoteDescription({ type: 'answer', sdp: offer.sdp })));
|
||||
}, 'Calling setRemoteDescription(answer) from stable state should reject with InvalidStateError');
|
||||
|
||||
|
||||
/*
|
||||
* [jsep] 5.6. If the type is "offer", the PeerConnection state
|
||||
* MUST be either "stable" or "have-remote-offer".
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
return pc.createOffer()
|
||||
.then(offer => pc.setLocalDescription(offer))
|
||||
.then(() => generateOffer())
|
||||
.then(offer =>
|
||||
promise_rejects(t, 'InvalidStateError',
|
||||
pc.setRemoteDescription(offer)));
|
||||
}, 'Calling setRemoteDescription(offer) from have-local-offer state should reject with InvalidStateError');
|
||||
|
||||
/*
|
||||
* [jsep] 5.6. If the type is "pranswer" or "answer", the PeerConnection
|
||||
* state MUST be either "have-local-offer" or "have-remote-pranswer".
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
return generateOffer()
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(() => generateAnswer(offer)))
|
||||
.then(answer =>
|
||||
promise_rejects(t, 'InvalidStateError',
|
||||
pc.setRemoteDescription(answer)));
|
||||
|
||||
}, 'Calling setRemoteDescription(answer) from have-remote-offer state should reject with InvalidStateError');
|
||||
|
||||
// tests that ontrack is called and parses the msid information from the SDP and creates
|
||||
// the streams with matching identifiers.
|
||||
async_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
// Fail the test if the ontrack event handler is not implemented
|
||||
assert_own_property(pc, 'ontrack', 'Expect pc to have ontrack event handler attribute');
|
||||
|
||||
const sdp = `v=0
|
||||
o=- 166855176514521964 2 IN IP4 127.0.0.1
|
||||
s=-
|
||||
t=0 0
|
||||
a=msid-semantic:WMS *
|
||||
m=audio 9 UDP/TLS/RTP/SAVPF 111
|
||||
c=IN IP4 0.0.0.0
|
||||
a=rtcp:9 IN IP4 0.0.0.0
|
||||
a=ice-ufrag:someufrag
|
||||
a=ice-pwd:somelongpwdwithenoughrandomness
|
||||
a=fingerprint:sha-256 8C:71:B3:8D:A5:38:FD:8F:A4:2E:A2:65:6C:86:52:BC:E0:6E:94:F2:9F:7C:4D:B5:DF:AF:AA:6F:44:90:8D:F4
|
||||
a=setup:actpass
|
||||
a=rtcp-mux
|
||||
a=mid:mid1
|
||||
a=sendonly
|
||||
a=rtpmap:111 opus/48000/2
|
||||
a=msid:stream1 track1
|
||||
a=ssrc:1001 cname:some
|
||||
`;
|
||||
|
||||
pc.ontrack = t.step_func(event => {
|
||||
assert_equals(event.streams.length, 1, 'the track belongs to one MediaStream');
|
||||
assert_equals(event.streams[0].id, 'stream1', 'the stream name is parsed from the MSID line');
|
||||
t.done();
|
||||
});
|
||||
|
||||
pc.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp}))
|
||||
.catch(t.step_func(err => {
|
||||
assert_unreached('Error ' + err.name + ': ' + err.message);
|
||||
}));
|
||||
}, 'setRemoteDescription should trigger ontrack event when the MSID of the stream is is parsed.');
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue