Commit 074288a0 authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

[PeerConnection] Fire signalingstatechange event at the right time

Prior to this CL, the event was fired before the transceiver state was
updated, in contradiction with the spec, which says it should be fired
after the transceiver state is updated.

Bug: 920200
Change-Id: I757cc0161a5da4888cd628619180e24a54dc732b
Reviewed-on: https://chromium-review.googlesource.com/c/1458203
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634609}
parent a77f654a
...@@ -683,9 +683,6 @@ class RTCPeerConnectionHandler::WebRtcSetDescriptionObserverImpl ...@@ -683,9 +683,6 @@ class RTCPeerConnectionHandler::WebRtcSetDescriptionObserverImpl
} }
if (handler_) { if (handler_) {
// |handler_| can become null after this call.
handler_->OnSignalingChange(states.signaling_state);
// Process the rest of the state changes differently depending on SDP // Process the rest of the state changes differently depending on SDP
// semantics. // semantics.
if (sdp_semantics_ == webrtc::SdpSemantics::kPlanB) { if (sdp_semantics_ == webrtc::SdpSemantics::kPlanB) {
...@@ -695,6 +692,9 @@ class RTCPeerConnectionHandler::WebRtcSetDescriptionObserverImpl ...@@ -695,6 +692,9 @@ class RTCPeerConnectionHandler::WebRtcSetDescriptionObserverImpl
ProcessStateChangesUnifiedPlan(std::move(states)); ProcessStateChangesUnifiedPlan(std::move(states));
} }
// |handler_| can become null after this call.
handler_->OnSignalingChange(states.signaling_state);
if (tracker_ && handler_) { if (tracker_ && handler_) {
tracker_->TrackSessionDescriptionCallback(handler_.get(), action_, tracker_->TrackSessionDescriptionCallback(handler_.get(), action_,
"OnSuccess", ""); "OnSuccess", "");
......
<!doctype html>
<meta charset=utf-8>
<title>RTCPeerConnection onsignalingstatechanged</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script>
promise_test(async t => {
const [track] = (await navigator.mediaDevices.getUserMedia({video: true})).getTracks();
t.add_cleanup(() => track.stop());
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
pc1.addTrack(track, new MediaStream());
await pc1.setLocalDescription(await pc1.createOffer());
await pc2.setRemoteDescription(pc1.localDescription);
const signalingStateChangeResolver = new Resolver();
pc2.onsignalingstatechange = t.step_func(e => {
const transceiver = pc2.getTransceivers()[0];
assert_equals(pc2.signalingState, "stable");
assert_equals(transceiver.currentDirection, "recvonly");
signalingStateChangeResolver.resolve();
});
await pc2.setLocalDescription(await pc2.createAnswer());
await signalingStateChangeResolver;
});
</script>
This is a testharness.js-based test.
FAIL RTCPeerConnection onsignalingstatechanged Cannot read property 'currentDirection' of undefined
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment