Automatic update from web-platform-tests Replace assert_true(x === y) with assert_equals -- Replace assert_false(x === y) with assert_not_equals -- Replace assert_true(x !== y) with assert_not_equals -- Replace assert_true(x == y) with assert_equals -- Replace assert_false(x == y) with assert_not_equals -- Replace assert_true(x != y) with assert_not_equals -- Fix actual/expected argument order Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com> -- wpt-commits: e2ddf48b78209d0aef4fa513b53a9f28243c9335, d80a3bccd7b88a7810522c6a1e317a53b0daad57, 54ee81d1501b46e990bc1a1cde162949f7d0ba71, d4beec831b7484382a25bca41b1449b68c235d0a, 278cf9fd6cfb113fd72dc5186534db239cde9e29, e1f3c83b5abc4d122e92db3c390aa8c9b8b4b792, 3cabe516b8e1234ccafd4f5e8aef7f9663b2f53f wpt-pr: 25086
72 lines
2.5 KiB
HTML
72 lines
2.5 KiB
HTML
<!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 getNoiseStream({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());
|
|
const events = [];
|
|
pc2.onsignalingstatechange = t.step_func(e => {
|
|
const [transceiver] = pc2.getTransceivers();
|
|
assert_equals(transceiver.currentDirection, null);
|
|
events.push(pc2.signalingState);
|
|
});
|
|
await pc2.setRemoteDescription(pc1.localDescription);
|
|
assert_equals(events.length, 1, "event fired");
|
|
assert_equals(events[0], "have-remote-offer");
|
|
|
|
pc2.onsignalingstatechange = t.step_func(e => {
|
|
const [transceiver] = pc2.getTransceivers();
|
|
assert_equals(transceiver.currentDirection, "recvonly");
|
|
events.push(pc2.signalingState);
|
|
});
|
|
await pc2.setLocalDescription(await pc2.createAnswer());
|
|
assert_equals(events.length, 2, "event fired");
|
|
assert_equals(events[1], "stable");
|
|
}, 'Negotiation methods fire signalingstatechange events');
|
|
|
|
promise_test(async t => {
|
|
const pc1 = new RTCPeerConnection();
|
|
t.add_cleanup(() => pc1.close());
|
|
const pc2 = new RTCPeerConnection();
|
|
const stream = await getNoiseStream({ audio: true });
|
|
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
|
|
|
|
stream.getTracks().forEach(track => pc1.addTrack(track, stream));
|
|
exchangeIceCandidates(pc1, pc2);
|
|
exchangeOfferAnswer(pc1, pc2);
|
|
await listenToIceConnected(pc2);
|
|
|
|
pc2.onsignalingstatechange = t.unreached_func();
|
|
pc2.close();
|
|
assert_equals(pc2.signalingState, 'closed');
|
|
await new Promise(r => t.step_timeout(r, 100));
|
|
}, 'Closing a PeerConnection should not fire signalingstatechange event');
|
|
|
|
promise_test(async t => {
|
|
const pc1 = new RTCPeerConnection();
|
|
t.add_cleanup(() => pc1.close());
|
|
const pc2 = new RTCPeerConnection();
|
|
t.add_cleanup(() => pc2.close());
|
|
|
|
pc2.addTransceiver('video');
|
|
|
|
pc1.ontrack = t.unreached_func();
|
|
pc1.onsignalingstatechange = t.step_func(e => {
|
|
pc1.ontrack = null;
|
|
});
|
|
await pc1.setRemoteDescription(await pc2.createOffer());
|
|
}, 'signalingstatechange is the first event to fire');
|
|
|
|
</script>
|