Skip to content

Commit

Permalink
Fail when calling createOffer in the wrong signaling state (web-platf…
Browse files Browse the repository at this point in the history
…orm-tests#20845)

* Fail when calling createOffer in the wrong signaling state

close web-platform-tests#16188 per w3c/webrtc-pc#2145
  • Loading branch information
dontcallmedom authored Jan 15, 2020
1 parent 213a760 commit 841671e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion webrtc/RTCPeerConnection-createOffer.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

return generateVideoReceiveOnlyOffer(pc)
.then(offer =>
pc.setLocalDescription(offer)
pc.setLocalDescription(offer)
.then(() => {
assert_equals(pc.signalingState, 'have-local-offer');
assert_session_desc_similar(pc.localDescription, offer);
Expand Down Expand Up @@ -93,6 +93,26 @@
});
}, 'When media stream is added when createOffer() is running in parallel, the result offer should contain the new media stream');

/*
If connection's signaling state is neither "stable" nor "have-local-offer", return a promise rejected with a newly created InvalidStateError.
*/
promise_test(t => {
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());

const states = [];
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));

return generateVideoReceiveOnlyOffer(pc)
.then(offer =>
pc.setRemoteDescription(offer)
.then(() => {
assert_equals(pc.signalingState, 'have-remote-offer');
return promise_rejects(t, 'InvalidStateError',
pc.createOffer());
})
)
}, 'createOffer() should fail when signaling state is not stable or have-local-offer');
/*
* TODO
* 4.3.2 createOffer
Expand Down

0 comments on commit 841671e

Please sign in to comment.