Title: [231352] trunk
Revision
231352
Author
[email protected]
Date
2018-05-04 08:18:34 -0700 (Fri, 04 May 2018)

Log Message

PeerConnection should have its connectionState closed even if doing gathering
https://bugs.webkit.org/show_bug.cgi?id=185267

Reviewed by Darin Adler.

Source/WebCore:

Test: webrtc/addICECandidate-closed.html

In case m_iceConnectionState is closed, m_connectionState should also be set to closed
and RTCPeerConnection should be closed so as to reject any other call.

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::close):
(WebCore::RTCPeerConnection::updateConnectionState):

LayoutTests:

* webrtc/addICECandidate-closed-expected.txt: Added.
* webrtc/addICECandidate-closed.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231351 => 231352)


--- trunk/LayoutTests/ChangeLog	2018-05-04 13:26:13 UTC (rev 231351)
+++ trunk/LayoutTests/ChangeLog	2018-05-04 15:18:34 UTC (rev 231352)
@@ -1,3 +1,13 @@
+2018-05-04  Youenn Fablet  <[email protected]>
+
+        PeerConnection should have its connectionState closed even if doing gathering
+        https://bugs.webkit.org/show_bug.cgi?id=185267
+
+        Reviewed by Darin Adler.
+
+        * webrtc/addICECandidate-closed-expected.txt: Added.
+        * webrtc/addICECandidate-closed.html: Added.
+
 2018-05-04  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Some event tests failing after r230817

Added: trunk/LayoutTests/webrtc/addICECandidate-closed-expected.txt (0 => 231352)


--- trunk/LayoutTests/webrtc/addICECandidate-closed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/addICECandidate-closed-expected.txt	2018-05-04 15:18:34 UTC (rev 231352)
@@ -0,0 +1,3 @@
+
+PASS Close a peer connection in the middle of gathering 
+

Added: trunk/LayoutTests/webrtc/addICECandidate-closed.html (0 => 231352)


--- trunk/LayoutTests/webrtc/addICECandidate-closed.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/addICECandidate-closed.html	2018-05-04 15:18:34 UTC (rev 231352)
@@ -0,0 +1,43 @@
+<!doctype html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+</head>
+<body>
+<script type="application/_javascript_">
+window._onunhandledrejection_ = () => false;
+promise_test(async (test) => {
+    const sender = new RTCPeerConnection();
+    const receiver = new RTCPeerConnection();
+    try {
+        const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
+        const localTracks = stream.getTracks();
+        [[sender, receiver], [receiver, sender]].forEach(([pc1, pc2]) => {
+            pc1._onicecandidate_ = ({ candidate }) => {
+                if (candidate)
+                    pc2.addIceCandidate(candidate);
+                pc1.close();
+            };
+        });
+        localTracks.forEach(track => sender.addTrack(track, stream));
+        receiver.addTransceiver('audio');
+        receiver.addTransceiver('video');
+        const offer1 = await sender.createOffer();
+        await sender.setLocalDescription(offer1);
+        await receiver.setRemoteDescription(offer1);
+        const answer1 = await receiver.createAnswer();
+        await receiver.setLocalDescription(answer1);
+        await sender.setRemoteDescription(answer1);
+        const offer2 = await sender.createOffer();
+        await sender.setLocalDescription(offer2);
+        await receiver.setRemoteDescription(offer2);
+        const answer2 = await receiver.createAnswer();
+        await receiver.setLocalDescription(answer2);
+        await sender.setRemoteDescription(answer2);
+    } catch (e) {
+    }
+}, "Close a peer connection in the middle of gathering");
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (231351 => 231352)


--- trunk/Source/WebCore/ChangeLog	2018-05-04 13:26:13 UTC (rev 231351)
+++ trunk/Source/WebCore/ChangeLog	2018-05-04 15:18:34 UTC (rev 231352)
@@ -1,3 +1,19 @@
+2018-05-04  Youenn Fablet  <[email protected]>
+
+        PeerConnection should have its connectionState closed even if doing gathering
+        https://bugs.webkit.org/show_bug.cgi?id=185267
+
+        Reviewed by Darin Adler.
+
+        Test: webrtc/addICECandidate-closed.html
+
+        In case m_iceConnectionState is closed, m_connectionState should also be set to closed
+        and RTCPeerConnection should be closed so as to reject any other call.
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::close):
+        (WebCore::RTCPeerConnection::updateConnectionState):
+
 2018-05-04  Yacine Bandou  <[email protected]>
 
         [MSE][GStreamer] Delete properly the stream from the WebKitMediaSource

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (231351 => 231352)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2018-05-04 13:26:13 UTC (rev 231351)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2018-05-04 15:18:34 UTC (rev 231352)
@@ -423,6 +423,7 @@
         return;
 
     updateConnectionState();
+    ASSERT(isClosed());
     scriptExecutionContext()->postTask([protectedThis = makeRef(*this)](ScriptExecutionContext&) {
         protectedThis->doStop();
     });
@@ -524,19 +525,18 @@
 {
     RTCPeerConnectionState state;
 
-    // FIXME: In case m_iceGatheringState is RTCIceGatheringState::Gathering, and m_iceConnectionState is Closed, we should have the connection state be Closed.
-    if (m_iceConnectionState == RTCIceConnectionState::New && m_iceGatheringState == RTCIceGatheringState::New)
+    if (m_iceConnectionState == RTCIceConnectionState::Closed)
+        state = RTCPeerConnectionState::Closed;
+    else if (m_iceConnectionState == RTCIceConnectionState::Disconnected)
+        state = RTCPeerConnectionState::Disconnected;
+    else if (m_iceConnectionState == RTCIceConnectionState::Failed)
+        state = RTCPeerConnectionState::Failed;
+    else if (m_iceConnectionState == RTCIceConnectionState::New && m_iceGatheringState == RTCIceGatheringState::New)
         state = RTCPeerConnectionState::New;
     else if (m_iceConnectionState == RTCIceConnectionState::Checking || m_iceGatheringState == RTCIceGatheringState::Gathering)
         state = RTCPeerConnectionState::Connecting;
     else if ((m_iceConnectionState == RTCIceConnectionState::Completed || m_iceConnectionState == RTCIceConnectionState::Connected) && m_iceGatheringState == RTCIceGatheringState::Complete)
         state = RTCPeerConnectionState::Connected;
-    else if (m_iceConnectionState == RTCIceConnectionState::Disconnected)
-        state = RTCPeerConnectionState::Disconnected;
-    else if (m_iceConnectionState == RTCIceConnectionState::Failed)
-        state = RTCPeerConnectionState::Failed;
-    else if (m_iceConnectionState == RTCIceConnectionState::Closed)
-        state = RTCPeerConnectionState::Closed;
     else
         return;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to