RTCPeerConnection returns RTCSessionDescription where RTCSessionDescriptionInit would...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jun 2017 16:24:20 +0000 (16:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jun 2017 16:24:20 +0000 (16:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173118
<rdar://problem/32746761>

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-15
Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

* web-platform-tests/webrtc/RTCPeerConnection-createOffer-expected.txt:

Source/WebCore:

Test: webrtc/createOfferAnswer.html

Making the promise return a RTCSessionDescription::Init instead of a RTCSessionDescription.
This aligns with the spec and is more optimal.

* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::PeerConnectionBackend::createOfferSucceeded):
(WebCore::PeerConnectionBackend::createAnswerSucceeded):
* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/RTCSessionDescription.idl:

LayoutTests:

* fast/mediastream/RTCPeerConnection-setLocalDescription-offer-expected.txt:
* fast/mediastream/RTCPeerConnection-setRemoteDescription-offer-expected.txt:
* webrtc/createOfferAnswer-expected.txt: Added.
* webrtc/createOfferAnswer.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218335 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/RTCPeerConnection-setLocalDescription-offer-expected.txt
LayoutTests/fast/mediastream/RTCPeerConnection-setRemoteDescription-offer-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-createOffer-expected.txt
LayoutTests/webrtc/createOfferAnswer-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/createOfferAnswer.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
Source/WebCore/Modules/mediastream/RTCSessionDescription.idl

index 2f00b92..4726733 100644 (file)
@@ -1,3 +1,16 @@
+2017-06-15  Youenn Fablet  <youenn@apple.com>
+
+        RTCPeerConnection returns RTCSessionDescription where RTCSessionDescriptionInit would be appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=173118
+        <rdar://problem/32746761>
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/RTCPeerConnection-setLocalDescription-offer-expected.txt:
+        * fast/mediastream/RTCPeerConnection-setRemoteDescription-offer-expected.txt:
+        * webrtc/createOfferAnswer-expected.txt: Added.
+        * webrtc/createOfferAnswer.html: Added.
+
 2017-06-15  Matt Lewis  <jlewis3@apple.com>
 
         Marked imported/w3c/web-platform-tests/dom/nodes/Document-constructor-svg.svg as skip.
index 3ac1ede..e97470d 100644 (file)
@@ -19,8 +19,8 @@ PASS audioTransceiver.mid is null
 
 PASS firstOffer set as local description
 FAIL pc.signalingState should be have-local-offer. Was stable.
-FAIL pc.localDescription should be [object RTCSessionDescription]. Was null.
-FAIL pc.pendingLocalDescription should be [object RTCSessionDescription]. Was null.
+FAIL pc.localDescription should be [object Object]. Was null.
+FAIL pc.pendingLocalDescription should be [object Object]. Was null.
 PASS pc.currentLocalDescription is null
 FAIL Error caught in promise chain: TypeError: null is not an object (evaluating 'pc.localDescription.type')
 PASS successfullyParsed is true
index 88e75e1..82b0ce4 100644 (file)
@@ -12,8 +12,8 @@ PASS pc.currentRemoteDescription is null
 
 PASS remoteOffer1 set as remote description
 FAIL pc.signalingState should be have-remote-offer. Was stable.
-FAIL pc.remoteDescription should be [object RTCSessionDescription]. Was null.
-FAIL pc.pendingRemoteDescription should be [object RTCSessionDescription]. Was null.
+FAIL pc.remoteDescription should be [object Object]. Was null.
+FAIL pc.pendingRemoteDescription should be [object Object]. Was null.
 PASS pc.currentRemoteDescription is null
 
 PASS remoteOffer1 set as remote description (again)
@@ -29,8 +29,8 @@ FAIL pc.signalingState should be have-remote-offer. Was stable.
 
 PASS remoteOffer2 set as remote description
 FAIL pc.signalingState should be have-remote-offer. Was stable.
-FAIL pc.remoteDescription should be [object RTCSessionDescription]. Was null.
-FAIL pc.pendingRemoteDescription should be [object RTCSessionDescription]. Was null.
+FAIL pc.remoteDescription should be [object Object]. Was null.
+FAIL pc.pendingRemoteDescription should be [object Object]. Was null.
 PASS pc.currentRemoteDescription is null
 
 PASS successfullyParsed is true
index 8c739b6..124d7c2 100644 (file)
@@ -1,3 +1,13 @@
+2017-06-15  Youenn Fablet  <youenn@apple.com>
+
+        RTCPeerConnection returns RTCSessionDescription where RTCSessionDescriptionInit would be appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=173118
+        <rdar://problem/32746761>
+
+        Reviewed by Eric Carlson.
+
+        * web-platform-tests/webrtc/RTCPeerConnection-createOffer-expected.txt:
+
 2017-06-14  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
 
         MediaSource duration attribute should not be equal to Infinity when set to a value greater than 2^64
index c6d5779..db2bcd6 100644 (file)
@@ -1,5 +1,5 @@
 
-FAIL createOffer() with no argument from newly created RTCPeerConnection should succeed assert_false: Expect offer to not be instance of RTCSessionDescription expected false got true
+PASS createOffer() with no argument from newly created RTCPeerConnection should succeed 
 FAIL createOffer() and then setLocalDescription() should succeed assert_not_equals: Expect session description to be defined, but got undefined got disallowed value undefined
 PASS createOffer() after connection is closed should reject with InvalidStateError 
 PASS createOffer() when connection is closed halfway should never resolve 
diff --git a/LayoutTests/webrtc/createOfferAnswer-expected.txt b/LayoutTests/webrtc/createOfferAnswer-expected.txt
new file mode 100644 (file)
index 0000000..6b45279
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS Ensuring that offer is a RTCSessionDescriptionInit 
+PASS Ensuring that answer is a RTCSessionDescriptionInit 
+
diff --git a/LayoutTests/webrtc/createOfferAnswer.html b/LayoutTests/webrtc/createOfferAnswer.html
new file mode 100644 (file)
index 0000000..fdda59a
--- /dev/null
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing createOffer/createAnswer</title>
+        <script src="../resources/testharness.js"></script>
+        <script src="../resources/testharnessreport.js"></script>
+    </head>
+    <body>
+        <script>
+
+var pc1 = new RTCPeerConnection();
+var pc1Offer;
+promise_test((test) => {
+    pc1.addTransceiver("video");
+
+    return pc1.createOffer().then((offer) => {
+        pc1Offer = offer;
+        assert_false(offer instanceof RTCSessionDescription);
+    });
+}, "Ensuring that offer is a RTCSessionDescriptionInit");
+
+
+promise_test((test) => {
+    var pc2 = new RTCPeerConnection();
+    pc2.addTransceiver("video");
+
+    return pc2.setRemoteDescription(pc1Offer).then(() => {
+        return pc2.createAnswer();
+    }).then((answer) => {
+        assert_false(pc1Offer instanceof RTCSessionDescription);
+        pc1Offer.sdp = "";
+        answer.sdp = "";
+    });
+}, "Ensuring that answer is a RTCSessionDescriptionInit");
+
+        </script>
+    </body>
+</html>
index c724129..040da3b 100644 (file)
@@ -1,3 +1,22 @@
+2017-06-15  Youenn Fablet  <youenn@apple.com>
+
+        RTCPeerConnection returns RTCSessionDescription where RTCSessionDescriptionInit would be appropriate
+        https://bugs.webkit.org/show_bug.cgi?id=173118
+        <rdar://problem/32746761>
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/createOfferAnswer.html
+
+        Making the promise return a RTCSessionDescription::Init instead of a RTCSessionDescription.
+        This aligns with the spec and is more optimal.
+
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::PeerConnectionBackend::createOfferSucceeded):
+        (WebCore::PeerConnectionBackend::createAnswerSucceeded):
+        * Modules/mediastream/PeerConnectionBackend.h:
+        * Modules/mediastream/RTCSessionDescription.idl:
+
 2017-06-15 Emilio Cobos Ãlvarez  <ecobos@igalia.com>
 
         Don't always recalc the style of display: contents elements.
index 154ef2e..fc11a75 100644 (file)
@@ -62,7 +62,7 @@ void PeerConnectionBackend::createOfferSucceeded(String&& sdp)
         return;
 
     ASSERT(m_offerAnswerPromise);
-    m_offerAnswerPromise->resolve(RTCSessionDescription::create(RTCSdpType::Offer, filterSDP(WTFMove(sdp))));
+    m_offerAnswerPromise->resolve(RTCSessionDescription::Init { RTCSdpType::Offer, filterSDP(WTFMove(sdp)) });
     m_offerAnswerPromise = std::nullopt;
 }
 
@@ -97,7 +97,7 @@ void PeerConnectionBackend::createAnswerSucceeded(String&& sdp)
         return;
 
     ASSERT(m_offerAnswerPromise);
-    m_offerAnswerPromise->resolve(RTCSessionDescription::create(RTCSdpType::Answer, WTFMove(sdp)));
+    m_offerAnswerPromise->resolve(RTCSessionDescription::Init { RTCSdpType::Answer, WTFMove(sdp) });
     m_offerAnswerPromise = std::nullopt;
 }
 
index 87b38cc..ce9c745 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "JSDOMPromiseDeferred.h"
 #include "RTCRtpParameters.h"
+#include "RTCSessionDescription.h"
 #include "RTCSignalingState.h"
 
 namespace WebCore {
@@ -56,7 +57,7 @@ struct RTCDataChannelInit;
 struct RTCOfferOptions;
 
 namespace PeerConnection {
-using SessionDescriptionPromise = DOMPromiseDeferred<IDLInterface<RTCSessionDescription>>;
+using SessionDescriptionPromise = DOMPromiseDeferred<IDLDictionary<RTCSessionDescription::Init>>;
 using StatsPromise = DOMPromiseDeferred<IDLInterface<RTCStatsReport>>;
 }
 
index 7dec946..9279055 100644 (file)
     PrivateIdentifier,
     PublicIdentifier,
 ] interface RTCSessionDescription {
-    [SetterMayThrowException] readonly attribute RTCSdpType type;
+    readonly attribute RTCSdpType type;
     readonly attribute DOMString sdp;
 
     serializer = {type, sdp};
 };
 
-dictionary RTCSessionDescriptionInit {
+[
+    Conditional=WEB_RTC,
+    JSGenerateToJSObject
+] dictionary RTCSessionDescriptionInit {
     required RTCSdpType type;
     DOMString sdp = "";
 };