Title: [219331] trunk
Revision
219331
Author
[email protected]
Date
2017-07-11 08:32:38 -0700 (Tue, 11 Jul 2017)

Log Message

We should do ICE candidate filtering at the Document level
https://bugs.webkit.org/show_bug.cgi?id=173861
<rdar://problem/33122058>

Patch by Youenn Fablet <[email protected]> on 2017-07-11
Reviewed by Eric Carlson.

Source/WebCore:

Tests: http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html
       http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html
       http/tests/webrtc/filtering-ice-candidate-same-origin-frame2.html
       webrtc/filtering-ice-candidate-after-reload.html

Making UserMediaRequest disable the ICE candidate filtering for the page RTCController.
All RTCPeerConnection of the page that are created on a document that are same-origin as the top document
are now registered to the RTCController.
This allows disabling filtering to only these RTCPeerConnection.

The page keeps the default ICE candidate filtering policy.
This policy allows disabling ICE candidate filtering for all RTCPeerConnection.

When the top document is changing, the RTCController filtering policy is reset
and its list of RTCPeerConnection is emptied.

Internals no longer disables ICE candidate filtering by default.
This allows finer grained testing.
ICE candidate filtering is disabled for tests including testharnessreport.js
to enable web-platform-tests to run without modifications.

* Modules/mediastream/RTCController.cpp:
(WebCore::RTCController::reset):
* Modules/mediastream/RTCController.h:
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::allow):
* page/Frame.cpp:
(WebCore::Frame::setDocument):
* page/Page.cpp:
(WebCore::Page::disableICECandidateFiltering):
* page/Page.h:
(WebCore::Page::shouldEnableICECandidateFilteringByDefault):
(WebCore::Page::disableICECandidateFiltering): Deleted.
(WebCore::Page::enableICECandidateFiltering): Deleted.
(WebCore::Page::isICECandidateFilteringEnabled): Deleted.
* testing/Internals.cpp:
(WebCore::Internals::Internals):
(WebCore::Internals::setICECandidateFiltering):
(WebCore::Internals::setEnumeratingAllNetworkInterfacesEnabled):
(WebCore::Internals::isICECandidateFilteringEnabled): Deleted.
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

Removing ICE candidate filtering handling at UIProcess level.
ICE candidate filtering is now disabled at UserMediaRequest level.
WebPage forwards the ICE candidate filtering option to the page so as to set
the default option correctly for every document of the page.

* UIProcess/UserMediaProcessManager.cpp:
(WebKit::UserMediaProcessManager::willCreateMediaStream):
(WebKit::UserMediaProcessManager::endedCaptureSession):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::disableICECandidateFiltering):
(WebKit::WebPage::enableICECandidateFiltering):

LayoutTests:

* http/tests/webrtc/filtering-ice-candidate-cross-origin-frame-expected.txt: Added.
* http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html: Added.
* http/tests/webrtc/filtering-ice-candidate-same-origin-frame-expected.txt: Added.
* http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html: Added.
* http/tests/webrtc/filtering-ice-candidate-same-origin-frame2-expected.txt: Added.
* http/tests/webrtc/filtering-ice-candidate-same-origin-frame2.html: Added.
* http/tests/webrtc/resources/check-ice-candidate-filtering.html: Added.
* http/tests/webrtc/resources/do-get-user-media.html: Added.
* platform/mac-wk1/TestExpectations: Disable http/tests/webrtc tests.
* resources/testharnessreport.js: Disabled ICE candidate filtering by default.
* webrtc/filtering-ice-candidate-after-reload-expected.txt: Added.
* webrtc/filtering-ice-candidate-after-reload.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219330 => 219331)


--- trunk/LayoutTests/ChangeLog	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/LayoutTests/ChangeLog	2017-07-11 15:32:38 UTC (rev 219331)
@@ -1,3 +1,24 @@
+2017-07-11  Youenn Fablet  <[email protected]>
+
+        We should do ICE candidate filtering at the Document level
+        https://bugs.webkit.org/show_bug.cgi?id=173861
+        <rdar://problem/33122058>
+
+        Reviewed by Eric Carlson.
+
+        * http/tests/webrtc/filtering-ice-candidate-cross-origin-frame-expected.txt: Added.
+        * http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html: Added.
+        * http/tests/webrtc/filtering-ice-candidate-same-origin-frame-expected.txt: Added.
+        * http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html: Added.
+        * http/tests/webrtc/filtering-ice-candidate-same-origin-frame2-expected.txt: Added.
+        * http/tests/webrtc/filtering-ice-candidate-same-origin-frame2.html: Added.
+        * http/tests/webrtc/resources/check-ice-candidate-filtering.html: Added.
+        * http/tests/webrtc/resources/do-get-user-media.html: Added.
+        * platform/mac-wk1/TestExpectations: Disable http/tests/webrtc tests.
+        * resources/testharnessreport.js: Disabled ICE candidate filtering by default.
+        * webrtc/filtering-ice-candidate-after-reload-expected.txt: Added.
+        * webrtc/filtering-ice-candidate-after-reload.html: Added.
+
 2017-07-11  Sergio Villar Senin  <[email protected]>
 
         Unreviewed, rolling out r219325.

Added: trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-cross-origin-frame-expected.txt (0 => 219331)


--- trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-cross-origin-frame-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-cross-origin-frame-expected.txt	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,3 @@
+PASS
+
+

Added: trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html (0 => 219331)


--- trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<body>
+  <script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+window.addEventListener("message", (event) => {
+    if (event.data ="" "getUserMedia done") {
+        check.innerHTML = "<iframe src=''></iframe>";
+        return;
+    }
+    result.innerHTML = event.data ="" "filtering enabled" ? "PASS" : "FAIL";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, false);
+
+  </script>
+  <div id="result"></div>
+  <iframe id="frame" src=""
+  <div id="check"></div>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame-expected.txt (0 => 219331)


--- trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame-expected.txt	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,2 @@
+PASS
+

Added: trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html (0 => 219331)


--- trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<body>
+  <script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+var didGetUserMedia = false;
+window.addEventListener("message", (event) => {
+    if (!didGetUserMedia && event.data ="" "filtering enabled") {
+        check2.innerHTML = "<iframe src=''></iframe>";
+        return;
+    }
+    if (event.data ="" "getUserMedia done") {
+        didGetUserMedia = true;
+        frame1.postMessage("check filtering", "*");
+        return;
+    }
+    check1.innerHTML = "";
+    check2.innerHTML = "";
+    result.innerHTML = event.data ="" "filtering disabled" ? "PASS" : "FAIL";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, false);
+
+  </script>
+  <div id="result"></div>
+  <div id="check1">
+    <iframe id="frame1" src=''></iframe>
+  </div>
+  <div id="check2">
+  </div>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame2-expected.txt (0 => 219331)


--- trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame2-expected.txt	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,2 @@
+PASS
+

Added: trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame2.html (0 => 219331)


--- trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame2.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/webrtc/filtering-ice-candidate-same-origin-frame2.html	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<body>
+  <script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+window.addEventListener("message", (event) => {
+    if (event.data ="" "getUserMedia done") {
+        check.innerHTML = "<iframe src=''></iframe>";
+        return;
+    }
+    check.innerHTML = "";
+    result.innerHTML = event.data ="" "filtering disabled" ? "PASS" : "FAIL";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}, false);
+
+  </script>
+  <div id="result"></div>
+  <div id="check">
+    <iframe id="frame" src=""
+  </div>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/webrtc/resources/check-ice-candidate-filtering.html (0 => 219331)


--- trunk/LayoutTests/http/tests/webrtc/resources/check-ice-candidate-filtering.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/webrtc/resources/check-ice-candidate-filtering.html	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+function gatherCandidates()
+{
+    var pc = new RTCPeerConnection();
+    pc.createDataChannel("");
+
+    var candidates = [];
+    return new Promise((resolve, reject) => {
+        pc._onicecandidate_ = (event) => {
+            if (event.candidate === null) {
+                resolve(candidates);
+                return;
+            }
+            candidates.push(event.candidate.candidate);
+        };
+        pc.createOffer().then((offer) => {
+            pc.setLocalDescription(offer);
+        });
+    });
+}
+
+function checkFiltering()
+{
+    gatherCandidates().then((candidates) => {
+        parent.postMessage(candidates.length ? "filtering disabled" : "filtering enabled", "*");
+    });
+}
+
+window.addEventListener("message", (event) => {
+    checkFiltering();
+});
+
+checkFiltering();
+
+</script>
+<div>Checking ICE candidate filtering</div>
+</body>
+</html>
+
+

Added: trunk/LayoutTests/http/tests/webrtc/resources/do-get-user-media.html (0 => 219331)


--- trunk/LayoutTests/http/tests/webrtc/resources/do-get-user-media.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/webrtc/resources/do-get-user-media.html	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+navigator.mediaDevices.getUserMedia({audio:true, video:true}).then(() => {
+    parent.postMessage("getUserMedia done", "*");
+});
+</script>
+<div>Calling getUserMedia, please grant access</div>
+</body>
+</html>
+
+

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (219330 => 219331)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2017-07-11 15:32:38 UTC (rev 219331)
@@ -97,6 +97,7 @@
 # Skip WebRTC for now in WK1
 imported/w3c/web-platform-tests/webrtc [ Skip ]
 webrtc [ Skip ]
+http/tests/webrtc [ Skip ]
 webrtc/datachannel [ Pass ]
 webrtc/captureCanvas-webrtc.html [ Failure Pass ]
 

Modified: trunk/LayoutTests/resources/testharnessreport.js (219330 => 219331)


--- trunk/LayoutTests/resources/testharnessreport.js	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/LayoutTests/resources/testharnessreport.js	2017-07-11 15:32:38 UTC (rev 219331)
@@ -23,6 +23,9 @@
         setTimeout(timeout, testRunner.timeout * 0.9);
 }
 
+if (self.internals)
+    internals.setICECandidateFiltering(false);
+
 // Function used to convert the test status code into
 // the corresponding string
 function convertResult(resultStatus)

Added: trunk/LayoutTests/webrtc/filtering-ice-candidate-after-reload-expected.txt (0 => 219331)


--- trunk/LayoutTests/webrtc/filtering-ice-candidate-after-reload-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/filtering-ice-candidate-after-reload-expected.txt	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,2 @@
+This test requires internals. It checks that after reload, we are back to filtering ice candidate.
+PASS

Added: trunk/LayoutTests/webrtc/filtering-ice-candidate-after-reload.html (0 => 219331)


--- trunk/LayoutTests/webrtc/filtering-ice-candidate-after-reload.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/filtering-ice-candidate-after-reload.html	2017-07-11 15:32:38 UTC (rev 219331)
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function isFilteringEnabled()
+{
+    var pc = new RTCPeerConnection();
+    pc.createDataChannel("");
+
+    var candidates = [];
+    return new Promise((resolve, reject) => {
+        pc._onicecandidate_ = (event) => {
+            if (event.candidate === null) {
+                resolve(!candidates.length);
+                return;
+            }
+            candidates.push(event.candidate.candidate);
+        };
+        pc.createOffer().then((offer) => {
+            pc.setLocalDescription(offer);
+        });
+    });
+}
+
+function endTest(message)
+{
+    result.innerHTML = message;
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+function test() {
+    if (window.localStorage.getItem("after-reload") == null) {
+        window.localStorage.setItem("after-reload", "true")
+        isFilteringEnabled().then((filtering) => {
+            if (!filtering) {
+                endTest("FAIL, initial ice candidate filtering is off");
+                return;
+            }
+            navigator.mediaDevices.getUserMedia({audio:true, video:true}).then(() => { return isFilteringEnabled(); }).then((filtering) => {
+                if (filtering) {
+                    endTest("FAIL, initial ice candidate filtering after getUserMedia is on");
+                    return;
+                }
+                internals.forceReload(true);
+            });
+        });
+    } else {
+        window.localStorage.clear();
+        isFilteringEnabled().then((filtering) => { endTest(filtering ? "PASS" : "FAIL"); });
+    }
+}
+</script>
+</head>
+<body _onload_="setTimeout(test, 0);">
+  <div>This test requires internals. It checks that after reload, we are back to filtering ice candidate.</div>
+  <div id="result"></div>
+</body>
+</html>
+
+

Modified: trunk/Source/WebCore/ChangeLog (219330 => 219331)


--- trunk/Source/WebCore/ChangeLog	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/ChangeLog	2017-07-11 15:32:38 UTC (rev 219331)
@@ -1,3 +1,54 @@
+2017-07-11  Youenn Fablet  <[email protected]>
+
+        We should do ICE candidate filtering at the Document level
+        https://bugs.webkit.org/show_bug.cgi?id=173861
+        <rdar://problem/33122058>
+
+        Reviewed by Eric Carlson.
+
+        Tests: http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html
+               http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html
+               http/tests/webrtc/filtering-ice-candidate-same-origin-frame2.html
+               webrtc/filtering-ice-candidate-after-reload.html
+
+        Making UserMediaRequest disable the ICE candidate filtering for the page RTCController.
+        All RTCPeerConnection of the page that are created on a document that are same-origin as the top document
+        are now registered to the RTCController.
+        This allows disabling filtering to only these RTCPeerConnection.
+
+        The page keeps the default ICE candidate filtering policy.
+        This policy allows disabling ICE candidate filtering for all RTCPeerConnection.
+
+        When the top document is changing, the RTCController filtering policy is reset
+        and its list of RTCPeerConnection is emptied.
+
+        Internals no longer disables ICE candidate filtering by default.
+        This allows finer grained testing.
+        ICE candidate filtering is disabled for tests including testharnessreport.js
+        to enable web-platform-tests to run without modifications.
+
+        * Modules/mediastream/RTCController.cpp:
+        (WebCore::RTCController::reset):
+        * Modules/mediastream/RTCController.h:
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::allow):
+        * page/Frame.cpp:
+        (WebCore::Frame::setDocument):
+        * page/Page.cpp:
+        (WebCore::Page::disableICECandidateFiltering):
+        * page/Page.h:
+        (WebCore::Page::shouldEnableICECandidateFilteringByDefault):
+        (WebCore::Page::disableICECandidateFiltering): Deleted.
+        (WebCore::Page::enableICECandidateFiltering): Deleted.
+        (WebCore::Page::isICECandidateFilteringEnabled): Deleted.
+        * testing/Internals.cpp:
+        (WebCore::Internals::Internals):
+        (WebCore::Internals::setICECandidateFiltering):
+        (WebCore::Internals::setEnumeratingAllNetworkInterfacesEnabled):
+        (WebCore::Internals::isICECandidateFilteringEnabled): Deleted.
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2017-07-11  Sergio Villar Senin  <[email protected]>
 
         Unreviewed, rolling out r219325.

Modified: trunk/Source/WebCore/Modules/mediastream/RTCController.cpp (219330 => 219331)


--- trunk/Source/WebCore/Modules/mediastream/RTCController.cpp	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/Modules/mediastream/RTCController.cpp	2017-07-11 15:32:38 UTC (rev 219331)
@@ -38,6 +38,14 @@
         connection.clearController();
 }
 
+void RTCController::reset(bool shouldFilterICECandidates)
+{
+    m_shouldFilterICECandidates = shouldFilterICECandidates;
+    for (RTCPeerConnection& connection : m_peerConnections)
+        connection.clearController();
+    m_peerConnections.clear();
+}
+
 void RTCController::remove(RTCPeerConnection& connection)
 {
     m_peerConnections.removeFirstMatching([&connection](auto item) {

Modified: trunk/Source/WebCore/Modules/mediastream/RTCController.h (219330 => 219331)


--- trunk/Source/WebCore/Modules/mediastream/RTCController.h	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/Modules/mediastream/RTCController.h	2017-07-11 15:32:38 UTC (rev 219331)
@@ -37,6 +37,8 @@
 #if ENABLE(WEB_RTC)
     ~RTCController();
 
+    void reset(bool shouldFilterICECandidates);
+
     void add(RTCPeerConnection&);
     void remove(RTCPeerConnection&);
 

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (219330 => 219331)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-07-11 15:32:38 UTC (rev 219331)
@@ -69,8 +69,12 @@
     if (!peerConnection->isClosed()) {
         peerConnection->setPendingActivity(peerConnection.ptr());
 
-        auto* page = downcast<Document>(context).page();
-        peerConnection->registerToController(page->rtcController());
+        // ICE candidate filtering can only be disabled for connections from documents that have the same origin as the top document,
+        // or if the page was set to disable it.
+        auto& document = downcast<Document>(context);
+        auto* page = document.page();
+        if (page && (!page->shouldEnableICECandidateFilteringByDefault() || document.origin() == document.topDocument().origin()))
+            peerConnection->registerToController(page->rtcController());
     }
     return peerConnection;
 }

Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp (219330 => 219331)


--- trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp	2017-07-11 15:32:38 UTC (rev 219331)
@@ -186,6 +186,15 @@
     m_videoConstraints.deviceIDHashSalt = WTFMove(deviceIdentifierHashSalt);
 
     RealtimeMediaSourceCenter::singleton().createMediaStream(WTFMove(callback), m_allowedAudioDeviceUID, m_allowedVideoDeviceUID, &m_audioConstraints, &m_videoConstraints);
+
+    if (!m_scriptExecutionContext)
+        return;
+
+#if ENABLE(WEB_RTC)
+    auto* page = downcast<Document>(*m_scriptExecutionContext).page();
+    if (page)
+        page->rtcController().disableICECandidateFiltering();
+#endif
 }
 
 void UserMediaRequest::deny(MediaAccessDenialReason reason, const String& invalidConstraint)

Modified: trunk/Source/WebCore/page/Frame.cpp (219330 => 219331)


--- trunk/Source/WebCore/page/Frame.cpp	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/page/Frame.cpp	2017-07-11 15:32:38 UTC (rev 219331)
@@ -278,8 +278,11 @@
 
     m_documentIsBeingReplaced = true;
 
-    if (isMainFrame())
+    if (isMainFrame()) {
+        if (m_page)
+            m_page->didChangeMainDocument();
         m_loader->client().dispatchDidChangeMainDocument();
+    }
 
     if (m_doc && m_doc->pageCacheState() != Document::InPageCache)
         m_doc->prepareForDestruction();

Modified: trunk/Source/WebCore/page/Page.cpp (219330 => 219331)


--- trunk/Source/WebCore/page/Page.cpp	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/page/Page.cpp	2017-07-11 15:32:38 UTC (rev 219331)
@@ -2410,4 +2410,27 @@
 
 #endif
 
+void Page::disableICECandidateFiltering()
+{
+    m_shouldEnableICECandidateFilteringByDefault = false;
+#if ENABLE(WEB_RTC)
+    m_rtcController.disableICECandidateFiltering();
+#endif
+}
+
+void Page::enableICECandidateFiltering()
+{
+    m_shouldEnableICECandidateFilteringByDefault = true;
+#if ENABLE(WEB_RTC)
+    m_rtcController.enableICECandidateFiltering();
+#endif
+}
+
+void Page::didChangeMainDocument()
+{
+#if ENABLE(WEB_RTC)
+    m_rtcController.reset(m_shouldEnableICECandidateFilteringByDefault);
+#endif
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/Page.h (219330 => 219331)


--- trunk/Source/WebCore/page/Page.h	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/page/Page.h	2017-07-11 15:32:38 UTC (rev 219331)
@@ -225,6 +225,12 @@
 #endif
     LibWebRTCProvider& libWebRTCProvider() { return m_libWebRTCProvider.get(); }
     RTCController& rtcController() { return m_rtcController; }
+    WEBCORE_EXPORT void disableICECandidateFiltering();
+    WEBCORE_EXPORT void enableICECandidateFiltering();
+    bool shouldEnableICECandidateFilteringByDefault() const { return m_shouldEnableICECandidateFilteringByDefault; }
+
+    void didChangeMainDocument();
+
     PerformanceMonitor* performanceMonitor() { return m_performanceMonitor.get(); }
 
     ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient.get(); }
@@ -816,6 +822,7 @@
     std::optional<Navigation> m_navigationToLogWhenVisible;
 
     bool m_isRunningUserScripts { false };
+    bool m_shouldEnableICECandidateFilteringByDefault { true };
 };
 
 inline PageGroup& Page::group()

Modified: trunk/Source/WebCore/testing/Internals.cpp (219330 => 219331)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-07-11 15:32:38 UTC (rev 219331)
@@ -493,11 +493,7 @@
 #if USE(OPENWEBRTC)
     enableMockMediaEndpoint();
 #endif
-#if USE(LIBWEBRTC)
-    if (document.page())
-        document.page()->rtcController().disableICECandidateFiltering();
 #endif
-#endif
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     if (document.page())
@@ -1330,10 +1326,10 @@
 
 void Internals::setICECandidateFiltering(bool enabled)
 {
-    Document* document = contextDocument();
-    auto* page = document->page();
+    auto* page = contextDocument()->page();
     if (!page)
         return;
+
     auto& rtcController = page->rtcController();
     if (enabled)
         rtcController.enableICECandidateFiltering();

Modified: trunk/Source/WebKit2/ChangeLog (219330 => 219331)


--- trunk/Source/WebKit2/ChangeLog	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebKit2/ChangeLog	2017-07-11 15:32:38 UTC (rev 219331)
@@ -1,5 +1,25 @@
 2017-07-11  Youenn Fablet  <[email protected]>
 
+        We should do ICE candidate filtering at the Document level
+        https://bugs.webkit.org/show_bug.cgi?id=173861
+        <rdar://problem/33122058>
+
+        Reviewed by Eric Carlson.
+
+        Removing ICE candidate filtering handling at UIProcess level.
+        ICE candidate filtering is now disabled at UserMediaRequest level.
+        WebPage forwards the ICE candidate filtering option to the page so as to set
+        the default option correctly for every document of the page.
+
+        * UIProcess/UserMediaProcessManager.cpp:
+        (WebKit::UserMediaProcessManager::willCreateMediaStream):
+        (WebKit::UserMediaProcessManager::endedCaptureSession):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::disableICECandidateFiltering):
+        (WebKit::WebPage::enableICECandidateFiltering):
+
+2017-07-11  Youenn Fablet  <[email protected]>
+
         Changing the web page muted state for playing audio should not disable other tabs capture
         https://bugs.webkit.org/show_bug.cgi?id=174349
         rdar://problem/33223988

Modified: trunk/Source/WebKit2/UIProcess/UserMediaProcessManager.cpp (219330 => 219331)


--- trunk/Source/WebKit2/UIProcess/UserMediaProcessManager.cpp	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebKit2/UIProcess/UserMediaProcessManager.cpp	2017-07-11 15:32:38 UTC (rev 219331)
@@ -148,11 +148,6 @@
 
     unsigned currentExtensions = state.sandboxExtensionsGranted();
 
-#if ENABLE(WEB_RTC) && USE(LIBWEBRTC)
-    if (currentExtensions == ProcessState::SandboxExtensionsGranted::None && (withAudio || withVideo))
-        processStartingCapture.send(Messages::WebPage::DisableICECandidateFiltering(), proxy.page().pageID());
-#endif
-
     if (!(requiredExtensions & currentExtensions)) {
         SandboxExtension::HandleArray handles;
         handles.allocate(extensionCount);
@@ -217,12 +212,6 @@
     if (params.isEmpty())
         return;
 
-#if ENABLE(WEB_RTC) && USE(LIBWEBRTC)
-    // FIXME: We should only do EnableICECandidateFiltering when the page is being reloaded.
-    if (currentExtensions == ProcessState::SandboxExtensionsGranted::None)
-        proxy.page().process().send(Messages::WebPage::EnableICECandidateFiltering(), proxy.page().pageID());
-#endif
-
     state.setSandboxExtensionsGranted(currentExtensions);
     proxy.page().process().send(Messages::WebPage::RevokeUserMediaDeviceSandboxExtensions(params), proxy.page().pageID());
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (219330 => 219331)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-07-11 15:14:36 UTC (rev 219330)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-07-11 15:32:38 UTC (rev 219331)
@@ -576,12 +576,12 @@
 #if ENABLE(WEB_RTC)
 void WebPage::disableICECandidateFiltering()
 {
-    m_page->rtcController().disableICECandidateFiltering();
+    m_page->disableICECandidateFiltering();
 }
 
 void WebPage::enableICECandidateFiltering()
 {
-    m_page->rtcController().disableICECandidateFiltering();
+    m_page->enableICECandidateFiltering();
 }
 
 #if USE(LIBWEBRTC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to