summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-offer.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-offer.html')
-rw-r--r--testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-offer.html37
1 files changed, 33 insertions, 4 deletions
diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-offer.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-offer.html
index d5acb7e1c9..d95ecafc33 100644
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-offer.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription-offer.html
@@ -4,6 +4,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
+<script src="/webrtc/third_party/sdp/sdp.js"></script>
<script>
'use strict';
@@ -211,7 +212,7 @@
assert_equals(raceValue, "have-remote-offer", "signalingstatechange event should fire before sRD resolves");
assert_not_equals(pc2.pendingRemoteDescription, null, "pendingRemoteDescription should be updated before the signalingstatechange event");
assert_equals(pc2.pendingRemoteDescription.type, "offer");
- assert_equals(pc2.pendingRemoteDescription.sdp, pc2.remoteDescription.sdp);
+ assert_equals(pc2.pendingRemoteDescription, pc2.remoteDescription);
assert_equals(pc2.currentRemoteDescription, null, "currentRemoteDescription should not be set after a call to sRD(offer)");
await srdPromise;
@@ -235,7 +236,7 @@
assert_equals(pc2.pendingRemoteDescription, null, "pendingRemoteDescription should not be set synchronously after a call to sRD");
assert_not_equals(pc2.pendingLocalDescription, null, "pendingLocalDescription should not be set synchronously after a call to sRD");
assert_equals(pc2.pendingLocalDescription.type, "offer");
- assert_equals(pc2.pendingLocalDescription.sdp, pc2.localDescription.sdp);
+ assert_equals(pc2.pendingLocalDescription, pc2.localDescription);
// First, we should go through stable (the implicit rollback part)
const stablePromise = new Promise(resolve => {
@@ -259,7 +260,8 @@
assert_equals(raceValue, "have-remote-offer", "signalingstatechange event should fire before sRD resolves");
assert_not_equals(pc2.pendingRemoteDescription, null, "pendingRemoteDescription should be updated before the signalingstatechange event");
assert_equals(pc2.pendingRemoteDescription.type, "offer");
- assert_equals(pc2.pendingRemoteDescription.sdp, pc2.remoteDescription.sdp);
+ assert_equals(pc2.pendingRemoteDescription, pc2.remoteDescription);
+ assert_equals(pc2.pendingRemoteDescription, pc2.pendingRemoteDescription);
assert_equals(pc2.pendingLocalDescription, null, "pendingLocalDescription should be updated before the signalingstatechange event");
await srdPromise;
@@ -303,8 +305,20 @@
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
await pc1.setLocalDescription(await pc1.createOffer());
+ const statePromise = new Promise(r => pc1.onsignalingstatechange = r);
+ // SRD with invalid SDP causes rollback.
const p = pc1.setRemoteDescription({type: 'offer', sdp: 'Invalid SDP'});
- await new Promise(r => pc1.onsignalingstatechange = r);
+ // Ensure that p is eventually awaited for
+ t.add_cleanup(async () => Promise.allSettled([p]));
+ // Ensure that the test will fail rather than timing out if state
+ // does not change.
+ const timeoutPromise = new Promise(
+ (resolve, reject) => t.step_timeout(reject, 1000));
+ try {
+ await Promise.any(statePromise, timeoutPromise);
+ } catch (error) {
+ assert_unreached('State should have changed');
+ }
assert_equals(pc1.signalingState, 'stable');
assert_equals(pc1.pendingLocalDescription, null);
assert_equals(pc1.pendingRemoteDescription, null);
@@ -353,4 +367,19 @@
assert_equals(pc2.getTransceivers().length, 1);
}, 'Transceivers added by sRD(offer) should not show up until sRD resolves');
+ promise_test(async t => {
+ const pc1 = new RTCPeerConnection();
+ const pc2 = new RTCPeerConnection();
+ t.add_cleanup(() => pc1.close());
+ t.add_cleanup(() => pc2.close());
+ pc1.addTransceiver('video');
+ const description = await pc1.createOffer();
+ const sections = SDPUtils.splitSections(description.sdp);
+ // Compose SDP with a duplicated media section (equal MSID lines)
+ // This is not permitted according to RFC 8830 section 2.
+ const sdp = sections[0] + sections[1] + sections[1].replace('a=mid:', 'a=mid:unique');
+ const p = pc2.setRemoteDescription({type: 'offer', sdp: sdp});
+ await promise_rejects_dom(t, 'OperationError', p);
+ }, 'setRemoteDescription(section with duplicate msid) rejects');
+
</script>