diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/tests/mochitest/test_getUserMedia_scarySources.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/tests/mochitest/test_getUserMedia_scarySources.html')
-rw-r--r-- | dom/media/tests/mochitest/test_getUserMedia_scarySources.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/dom/media/tests/mochitest/test_getUserMedia_scarySources.html b/dom/media/tests/mochitest/test_getUserMedia_scarySources.html new file mode 100644 index 000000000..2f1b2195b --- /dev/null +++ b/dom/media/tests/mochitest/test_getUserMedia_scarySources.html @@ -0,0 +1,66 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="head.js"></script> + <script type="application/javascript" src="mediaStreamPlayback.js"></script> +</head> +<body> +<pre id="test"> +<script type="application/javascript"> + +createHTML({title: "Detect screensharing sources that are firefox", bug: "1311048"}); + +netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + +const { Services } = SpecialPowers.Cu.import('resource://gre/modules/Services.jsm'); + +let observe = topic => new Promise(r => Services.obs.addObserver(function o(...args) { + Services.obs.removeObserver(o, topic); + r(args); +}, topic, false)); + +let getDevices = async constraints => { + let [{ windowID, innerWindowID, callID }] = await Promise.race([ + getUserMedia(constraints), + observe("getUserMedia:request") + ]); + let window = Services.wm.getOuterWindowWithId(windowID); + let devices = await new Promise((resolve, reject) => + window.navigator.mozGetUserMediaDevices({}, resolve, reject, + innerWindowID, callID)); + return devices.map(d => d.QueryInterface(Ci.nsIMediaDevice)); +}; + +runTest(async () => { + try { + const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1; + if (IsMacOSX10_6orOlder() || isWinXP) { + ok(true, "Screensharing disabled for OSX10.6 and WinXP"); + return; + } + + await pushPrefs(["media.navigator.permission.disabled", true], + ["media.navigator.permission.fake", true], + ["media.navigator.permission.force", true]); + let devices = await getDevices({video: { mediaSource: "window" }}); + ok(devices.length, "Found one or more windows."); + devices = devices.filter(d => d.scary); + ok(devices.length, "Found one or more scary windows (our own counts)."); + devices.filter(d => d.name.includes("MochiTest")); + ok(devices.length, + "Our own window is among the scary: " + devices.map(d => `"${d.name}"`)); + + devices = await getDevices({video: { mediaSource: "screen" }}); + let numScreens = devices.length; + ok(numScreens, "Found one or more screens."); + devices = devices.filter(d => d.scary); + is(devices.length, numScreens, "All screens are scary."); + } catch(e) { + ok(false, e); + } +}); + +</script> +</pre> +</body> +</html> |