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 54 55 56 57 58 59 60 61 62 63 64
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
</head>
<body>
<script type="application/javascript">
"use strict";

createHTML({
  title: "ondevicechange tests",
  bug: "1152383"
});

const RESPONSE_WAIT_TIME_MS = 10000;

function OnDeviceChangeEvent() {
  return new Promise(resolve => navigator.mediaDevices.ondevicechange = resolve);
}

function OnDeviceChangeEventReceived() {
  return Promise.race([
    OnDeviceChangeEvent(),
    wait(RESPONSE_WAIT_TIME_MS).then(() => Promise.reject("Timed out while waiting for devicechange event"))
  ]);
}

function OnDeviceChangeEventNotReceived() {
  return Promise.race([
    OnDeviceChangeEvent().then(() => Promise.reject("ondevicechange event is fired unexpectedly.")),
    wait(RESPONSE_WAIT_TIME_MS)
  ]);
}

runTest(async () => {
  SimpleTest.requestCompleteLog();

  await pushPrefs(["media.ondevicechange.fakeDeviceChangeEvent.enabled", true]);
  await pushPrefs(["media.navigator.permission.disabled", false]);
  await pushPrefs(["media.ondevicechange.enabled", true]);

  info("assure devicechange event is NOT fired when gUM is NOT in use and permanent permission is NOT granted");
  await OnDeviceChangeEventNotReceived();
  ok(true, "devicechange event is NOT fired when gUM is NOT in use and permanent permission is NOT granted");

  await pushPrefs(['media.navigator.permission.disabled', true]);

  info("assure devicechange event is fired when gUM is NOT in use and permanent permission is granted");
  await OnDeviceChangeEventReceived();
  ok(true, "devicechange event is fired when gUM is NOT in use and permanent permission is granted");
  let st = await getUserMedia({video: true, fake: true});
  let videoTracks = st.getVideoTracks();

  info("assure devicechange event is fired when gUM is in use");
  await OnDeviceChangeEventReceived();
  ok(true, "devicechange event is fired when gUM is in use");
  videoTracks.forEach(track => track.stop());
});

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