Make sure RTCIceCandidateStats address is undefined for host and peer reflexive case
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 15:56:59 +0000 (15:56 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 15:56:59 +0000 (15:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191263

Reviewed by Eric Carlson.

Source/WebCore:

Test: webrtc/datachannel/getStats-no-prflx-remote-candidate.html

* Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
(WebCore::fillRTCIceCandidateStats):

LayoutTests:

* webrtc/datachannel/getStats-no-prflx-remote-candidate-expected.txt: Added.
* webrtc/datachannel/getStats-no-prflx-remote-candidate.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/webrtc/datachannel/getStats-no-prflx-remote-candidate-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/datachannel/getStats-no-prflx-remote-candidate.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp

index 492c981..4df7c2d 100644 (file)
@@ -1,5 +1,15 @@
 2018-11-06  Youenn Fablet  <youenn@apple.com>
 
+        Make sure RTCIceCandidateStats address is undefined for host and peer reflexive case
+        https://bugs.webkit.org/show_bug.cgi?id=191263
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/datachannel/getStats-no-prflx-remote-candidate-expected.txt: Added.
+        * webrtc/datachannel/getStats-no-prflx-remote-candidate.html: Added.
+
+2018-11-06  Youenn Fablet  <youenn@apple.com>
+
         Layout Test imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setRemoteDescription-tracks.https.html is flaky
         https://bugs.webkit.org/show_bug.cgi?id=191278
 
diff --git a/LayoutTests/webrtc/datachannel/getStats-no-prflx-remote-candidate-expected.txt b/LayoutTests/webrtc/datachannel/getStats-no-prflx-remote-candidate-expected.txt
new file mode 100644 (file)
index 0000000..500f523
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Make sure remote peer reflexive candidates are not exposed in stats 
+
diff --git a/LayoutTests/webrtc/datachannel/getStats-no-prflx-remote-candidate.html b/LayoutTests/webrtc/datachannel/getStats-no-prflx-remote-candidate.html
new file mode 100644 (file)
index 0000000..8647976
--- /dev/null
@@ -0,0 +1,59 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Make sure remote peer reflexive candidates are not exposed in stats</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+  'use strict';
+const localPc = new RTCPeerConnection();
+const remotePc = new RTCPeerConnection();
+
+async function doSignalingHandshake(localPc, remotePc) {
+    const offer = await localPc.createOffer();
+    await localPc.setLocalDescription(offer);
+    await remotePc.setRemoteDescription(offer);
+
+    const answer = await remotePc.createAnswer();
+    await remotePc.setLocalDescription(answer);
+    await localPc.setRemoteDescription(answer);
+}
+
+function getRequiredStats(statsReport, type) {
+    for(const stats of statsReport.values()) {
+        if(stats.type === type)
+            return stats;
+    }
+}
+
+async function doTest()
+{
+    const promiseDataChannel = new Promise(resolve => {
+        remotePc.addEventListener('datachannel', (event) => {
+             resolve(event.channel);
+        });
+    });
+
+    const localDataChannel = localPc.createDataChannel('test');
+
+    localPc.addEventListener('icecandidate', event => {
+        remotePc.addIceCandidate(event.candidate);
+    });
+    doSignalingHandshake(localPc, remotePc);
+
+    const remoteDataChannel = await promiseDataChannel;
+
+    assert_true(!!remoteDataChannel, "remoteDataChannel is defined");
+    await new Promise(resolve => {
+        remoteDataChannel.onmessage = resolve;
+        localDataChannel.send("test");
+    });
+
+    const remoteCandidateStats = getRequiredStats(await localPc.getStats(), "remote-candidate");
+    assert_equals(remoteCandidateStats.address, undefined, "address should remain undefined");
+
+    done();
+}
+
+doTest();
+
+</script>
index fa95ed6..00bd449 100644 (file)
@@ -1,3 +1,15 @@
+2018-11-06  Youenn Fablet  <youenn@apple.com>
+
+        Make sure RTCIceCandidateStats address is undefined for host and peer reflexive case
+        https://bugs.webkit.org/show_bug.cgi?id=191263
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/datachannel/getStats-no-prflx-remote-candidate.html
+
+        * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+        (WebCore::fillRTCIceCandidateStats):
+
 2018-11-06  Thibault Saunier  <tsaunier@igalia.com>
 
         [GStreamer][WebRTC] Handle setting max number of frame between keyframes
index 278d40f..e3f50a7 100644 (file)
@@ -310,9 +310,7 @@ static inline void fillRTCIceCandidateStats(RTCStatsReport::IceCandidateStats& s
     if (rtcStats.candidate_type.is_defined())
         stats.candidateType = iceCandidateState(*rtcStats.candidate_type);
 
-    if (stats.candidateType == RTCStatsReport::IceCandidateType::Prflx)
-        stats.candidateType = { };
-    if (stats.candidateType == RTCStatsReport::IceCandidateType::Prflx || stats.candidateType == RTCStatsReport::IceCandidateType::Host)
+    if (!stats.candidateType || stats.candidateType == RTCStatsReport::IceCandidateType::Prflx || stats.candidateType == RTCStatsReport::IceCandidateType::Host)
         stats.address = { };
 
     if (rtcStats.priority.is_defined())