Bug 1592723 [wpt PR 20001] - [RTCPeerConnection] Ship parameterless setLocalDescription()., a=testonly
authorHenrik Boström <hbos@chromium.org>
Mon, 04 Nov 2019 11:45:29 +0000
changeset 564805 cab0f916a2260616b9ad4c1da1451a7a3070039e
parent 564804 0aee8b728e0424c1909239b36d21ebb6547e17b1
child 564806 0b40ae893b4965e6720f8c6056d38a6cb85ed611
push id12351
push userffxbld-merge
push dateMon, 02 Dec 2019 11:32:26 +0000
treeherdermozilla-beta@dba4410526a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1592723, 20001, 980885, 1890420, 711445
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1592723 [wpt PR 20001] - [RTCPeerConnection] Ship parameterless setLocalDescription()., a=testonly Automatic update from web-platform-tests [RTCPeerConnection] Ship parameterless setLocalDescription(). Intent to Implement and Ship: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/OqPfCpC5RYU For background, motivation, requirements and implementation notes, see https://docs.google.com/document/d/1XLwNN2kUIGGTwz9LQ0NwJNkcybi9oKnynUEZB1jGA14/edit?usp=sharing Parameterless setLocalDescription() implicitly creates an offer or answer as appropriate based on the current signaling state. This is already implemented in third_party/webrtc using an operations chain. This CL reuses existing plumbing (used by SLD/SRD already) to surface state changes when invoking the new SetLocalDescription variety. The PeerConnectionTracker is updated to track parameterless SLD so that it shows up in chrome://webrtc-internals/. The old SLD and SRD showed up as events as follow: - When SLD(sdp) is called, a "setLocalDescription" event shows up with the SDP as the event's value. - When SLD(sdp) resolves, a "setLocalDescriptionOnSuccess" event shows up without a value. The parameterless setLocalDescription() instead shows up in chrome://webrtc-internals/ as: - When SLD() is called, a "setLocalDescriptionImplicitCreateOfferOrAnswer" event shows up without a value. - When SLD() resolves, a "setLocalDescriptionImplicitCreateOfferOrAnswerOnComplete" event shows up with the resulting SDP as the event's value. As such, chrome://webrtc-internals/ remains useful for debugging even if parameterless SLD is used. Bug: chromium:980885 Change-Id: I469f63cdaab83991749d5a0d47fe751666304fe6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890420 Reviewed-by: Guido Urdaneta <guidou@chromium.org> Reviewed-by: Steve Anton <steveanton@chromium.org> Commit-Queue: Henrik Boström <hbos@chromium.org> Cr-Commit-Position: refs/heads/master@{#711445} -- wpt-commits: f7b4aa0021ecf0c1470205f110b40eb40a0a1667 wpt-pr: 20001 Differential Revision: https://phabricator.services.mozilla.com/D53595
testing/web-platform/tests/webrtc/RTCPeerConnection-setLocalDescription-parameterless.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-setLocalDescription-parameterless.https.html
@@ -0,0 +1,142 @@
+<!doctype html>
+<meta charset=utf-8>
+<title></title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="RTCPeerConnection-helper.js"></script>
+<script>
+"use strict";
+
+const kSmallTimeoutMs = 10;
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+
+  const signalingStateChangeEvent
+      = new EventWatcher(t, offerer, 'signalingstatechange')
+      .wait_for('signalingstatechange');
+  await offerer.setLocalDescription();
+  await signalingStateChangeEvent;
+  assert_equals(offerer.signalingState, 'have-local-offer');
+}, "Parameterless SLD() in 'stable' goes to 'have-local-offer'");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+
+  await offerer.setLocalDescription();
+  assert_not_equals(offerer.pendingLocalDescription, null);
+}, "Parameterless SLD() in 'stable' sets pendingLocalDescription");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+
+  const transceiver = offerer.addTransceiver('audio');
+  await offerer.setLocalDescription();
+  assert_not_equals(transceiver.mid, null);
+}, "Parameterless SLD() in 'stable' assigns transceiver.mid");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+  const answerer = new RTCPeerConnection();
+  t.add_cleanup(() => answerer.close());
+
+  await answerer.setRemoteDescription(await offerer.createOffer());
+  const signalingStateChangeEvent
+      = new EventWatcher(t, answerer, 'signalingstatechange')
+      .wait_for('signalingstatechange');
+  await answerer.setLocalDescription();
+  await signalingStateChangeEvent;
+  assert_equals(answerer.signalingState, 'stable');
+}, "Parameterless SLD() in 'have-remote-offer' goes to 'stable'");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+  const answerer = new RTCPeerConnection();
+  t.add_cleanup(() => answerer.close());
+
+  await answerer.setRemoteDescription(await offerer.createOffer());
+  await answerer.setLocalDescription();
+  assert_not_equals(answerer.currentLocalDescription, null);
+}, "Parameterless SLD() in 'have-remote-offer' sets currentLocalDescription");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+  const answerer = new RTCPeerConnection();
+  t.add_cleanup(() => answerer.close());
+
+  offerer.addTransceiver('audio');
+  const onTransceiverPromise = new Promise(resolve =>
+      answerer.ontrack = e => resolve(e.transceiver));
+  await answerer.setRemoteDescription(await offerer.createOffer());
+  const transceiver = await onTransceiverPromise;
+  await answerer.setLocalDescription();
+  assert_equals(transceiver.currentDirection, 'recvonly');
+}, "Parameterless SLD() in 'have-remote-offer' sets " +
+   "transceiver.currentDirection");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+
+  const offer = await offerer.createOffer();
+  await offerer.setLocalDescription();
+  // assert_true() is used rather than assert_equals() so that if the assertion
+  // fails, the -expected.txt file is not different on each run.
+  assert_true(offerer.pendingLocalDescription.sdp == offer.sdp,
+              "offerer.pendingLocalDescription.sdp == offer.sdp");
+}, "Parameterless SLD() uses [[LastCreatedOffer]] if it is still valid");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+  const answerer = new RTCPeerConnection();
+  t.add_cleanup(() => answerer.close());
+
+  await answerer.setRemoteDescription(await offerer.createOffer());
+  const answer = await answerer.createAnswer();
+  await answerer.setLocalDescription();
+  // assert_true() is used rather than assert_equals() so that if the assertion
+  // fails, the -expected.txt file is not different on each run.
+  assert_true(answerer.currentLocalDescription.sdp == answer.sdp,
+              "answerer.currentLocalDescription.sdp == answer.sdp");
+}, "Parameterless SLD() uses [[LastCreatedAnswer]] if it is still valid");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  offerer.close();
+
+  offerer.setLocalDescription().then(t.step_func(() => assert_not_reached()));
+  await new Promise(resolve => t.step_timeout(resolve, kSmallTimeoutMs));
+}, "Parameterless SLD() never resolves if already closed");
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+
+  offerer.setLocalDescription().then(t.step_func(() => assert_not_reached()));
+  offerer.close();
+  await new Promise(resolve => t.step_timeout(resolve, kSmallTimeoutMs));
+}, "Parameterless SLD() never resolves if closed while pending");
+
+
+promise_test(async t => {
+  const offerer = new RTCPeerConnection();
+  t.add_cleanup(() => offerer.close());
+  const answerer = new RTCPeerConnection();
+  t.add_cleanup(() => answerer.close());
+
+  // Implicitly create an offer.
+  await offerer.setLocalDescription();
+  await answerer.setRemoteDescription(offerer.pendingLocalDescription);
+  // Implicitly create an answer.
+  await answerer.setLocalDescription();
+  await offerer.setRemoteDescription(answerer.currentLocalDescription);
+}, "Parameterless SLD() in a full O/A exchange succeeds");
+
+</script>
\ No newline at end of file