Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
RTCController should disable ICE candidate filtering in case of getUs…
…erMedia based on the RTCPerrConnection origin https://bugs.webkit.org/show_bug.cgi?id=180851 Patch by Youenn Fablet <youenn@apple.com> on 2018-01-11 Reviewed by Eric Carlson. Source/WebCore: Test: http/wpt/webrtc/third-party-frame-ice-candidate-filtering.html RTCController now stores all the client origins (top+frame origins) of frames that got access to camera/microphone access. For any such client origin, PeerConnection objects ICE candidate filtering is disabled. ICE candidate filtering is reset whenever navigating/reloading the page. * Modules/mediastream/RTCController.cpp: (WebCore::RTCController::reset): (WebCore::matchDocumentOrigin): (WebCore::RTCController::shouldDisableICECandidateFiltering): (WebCore::RTCController::add): (WebCore::RTCController::disableICECandidateFilteringForAllOrigins): (WebCore::RTCController::disableICECandidateFiltering): (WebCore::RTCController::enableICECandidateFiltering): * Modules/mediastream/RTCController.h: * Modules/mediastream/RTCPeerConnection.cpp: (WebCore::RTCPeerConnection::create): * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::allow): * page/Page.cpp: (WebCore::Page::disableICECandidateFiltering): * testing/Internals.cpp: (WebCore::Internals::setICECandidateFiltering): LayoutTests: * http/wpt/webrtc/resources/third-party-frame-ice-candidate-filtering-iframe.html: Added. * http/wpt/webrtc/third-party-frame-ice-candidate-filtering-expected.txt: Added. * http/wpt/webrtc/third-party-frame-ice-candidate-filtering.html: Added. Canonical link: https://commits.webkit.org/197417@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226804 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
207 additions
and 14 deletions.
- +11 −0 LayoutTests/ChangeLog
- +40 −0 LayoutTests/http/wpt/webrtc/resources/third-party-frame-ice-candidate-filtering-iframe.html
- +8 −0 LayoutTests/http/wpt/webrtc/third-party-frame-ice-candidate-filtering-expected.txt
- +64 −0 LayoutTests/http/wpt/webrtc/third-party-frame-ice-candidate-filtering.html
- +1 −0 LayoutTests/platform/mac-wk1/TestExpectations
- +31 −0 Source/WebCore/ChangeLog
- +34 −2 Source/WebCore/Modules/mediastream/RTCController.cpp
- +12 −1 Source/WebCore/Modules/mediastream/RTCController.h
- +1 −6 Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
- +3 −3 Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
- +1 −1 Source/WebCore/page/Page.cpp
- +1 −1 Source/WebCore/testing/Internals.cpp
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,40 @@ | ||
<body> | ||
<script> | ||
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); | ||
}); | ||
}); | ||
} | ||
|
||
async function doGetUserMedia() { | ||
var result = await navigator.mediaDevices.getUserMedia({video:true}); | ||
return true; | ||
} | ||
|
||
window.onmessage = async (event) => { | ||
if (event.data === "checkFiltering") { | ||
event.source.postMessage(await isFilteringEnabled(), event.origin); | ||
return; | ||
} | ||
if (event.data === "capture") { | ||
event.source.postMessage(await doGetUserMedia(), event.origin); | ||
return; | ||
} | ||
event.source.postMessage("unknown message", event.origin); | ||
} | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
|
||
|
||
PASS Setup test | ||
PASS getUserMedia on third party iframe and check same frame filtering | ||
PASS Check same origin filtering as top frame | ||
PASS Check same origin filtering as capturing frame | ||
PASS Check filtering of frame with different origin as top and capturing frame origins | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,64 @@ | ||
<html> | ||
<head> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<title>ICE candidate filtering for third party iframes</title> | ||
</head> | ||
<body> | ||
<script> | ||
if (self.internals && internals.setICECandidateFiltering) | ||
internals.setICECandidateFiltering(true); | ||
|
||
async function withFrame(scopeURL) | ||
{ | ||
return new Promise((resolve) => { | ||
let frame = document.createElement('iframe'); | ||
frame.src = scopeURL; | ||
frame.allow= "camera;microphone"; | ||
frame.onload = function() { resolve(frame); }; | ||
document.body.appendChild(frame); | ||
}); | ||
} | ||
|
||
function doIFrameTest(frame, name) | ||
{ | ||
return new Promise((resolve, reject) => { | ||
frame.contentWindow.postMessage(name, "*"); | ||
window.onmessage = (event) => { | ||
window.onmessage = undefined; | ||
resolve(event.data); | ||
} | ||
setTimeout(() => reject("no message from frame"), 5000); | ||
}); | ||
} | ||
|
||
var host = get_host_info(); | ||
var frame1, frame2, frame2b, frame3; | ||
promise_test(async (test) => { | ||
frame1 = await withFrame("resources/third-party-frame-ice-candidate-filtering-iframe.html"); | ||
frame2 = await withFrame(host.HTTP_REMOTE_ORIGIN + "/WebKit/webrtc/resources/third-party-frame-ice-candidate-filtering-iframe.html"); | ||
frame2b = await withFrame(host.HTTP_REMOTE_ORIGIN + "/WebKit/webrtc/resources/third-party-frame-ice-candidate-filtering-iframe.html"); | ||
frame3 = await withFrame(host.HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT + "/WebKit/webrtc/resources/third-party-frame-ice-candidate-filtering-iframe.html"); | ||
}, "Setup test"); | ||
|
||
promise_test(async (test) => { | ||
assert_true(await doIFrameTest(frame2, "capture"), "iframe is capturing"); | ||
assert_false(await doIFrameTest(frame2, "checkFiltering"), "iframe is not filtering"); | ||
}, "getUserMedia on third party iframe and check same frame filtering"); | ||
|
||
promise_test(async (test) => { | ||
assert_false(await doIFrameTest(frame1, "checkFiltering")); | ||
}, "Check same origin filtering as top frame"); | ||
|
||
promise_test(async (test) => { | ||
assert_false(await doIFrameTest(frame2b, "checkFiltering")); | ||
}, "Check same origin filtering as capturing frame"); | ||
|
||
promise_test(async (test) => { | ||
assert_true(await doIFrameTest(frame3, "checkFiltering")); | ||
}, "Check filtering of frame with different origin as top and capturing frame origins"); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters