DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (b6d82b1a6b02)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<!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.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));

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(SpecialPowers.wrapCallback(d => d.QueryInterface(Ci.nsIMediaDevice)));
};

runTest(async () => {
  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.");
});

</script>
</pre>
</body>
</html>