summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/test_getUserMedia_scarySources.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_getUserMedia_scarySources.html')
-rw-r--r--dom/media/webrtc/tests/mochitests/test_getUserMedia_scarySources.html51
1 files changed, 51 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_getUserMedia_scarySources.html b/dom/media/webrtc/tests/mochitests/test_getUserMedia_scarySources.html
new file mode 100644
index 0000000000..782110823e
--- /dev/null
+++ b/dom/media/webrtc/tests/mochitests/test_getUserMedia_scarySources.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <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"});
+
+const Services = SpecialPowers.Services;
+
+let observe = topic => new Promise(r => Services.obs.addObserver(function o(...args) {
+ Services.obs.removeObserver(o, topic);
+ r(args.map(x => SpecialPowers.wrap(x)));
+}, topic));
+
+let getDevices = async constraints => {
+ SpecialPowers.wrap(document).notifyUserGestureActivation();
+ let [{ windowID, innerWindowID, callID, devices }] = await Promise.race([
+ getUserMedia(constraints),
+ observe("getUserMedia:request")
+ ]);
+ let window = Services.wm.getOuterWindowWithId(windowID);
+ return devices.map(SpecialPowers.wrapCallback(d => d.QueryInterface(Ci.nsIMediaDevice)));
+};
+
+runTest(async () => {
+ await pushPrefs(["media.navigator.permission.disabled", true],
+ ["media.navigator.permission.force", true]);
+ let devices = await getDevices({video: { mediaSource: "window" }});
+ ok(devices.length, "Found one or more windows.");
+ devices = Array.prototype.filter.call(devices, d => d.scary);
+ ok(devices.length, "Found one or more scary windows (our own counts).");
+ devices = devices.filter(d => d.rawName.includes("MochiTest"));
+ ok(devices.length,
+ "Our own window is among the scary: "
+ + devices.map(d => `"${d.rawName}"`));
+
+ devices = await getDevices({video: { mediaSource: "screen" }});
+ let numScreens = devices.length;
+ ok(numScreens, "Found one or more screens.");
+ devices = Array.prototype.filter.call(devices, d => d.scary);
+ is(devices.length, numScreens, "All screens are scary.");
+});
+
+</script>
+</pre>
+</body>
+</html>