summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_queue_request.js
blob: ed270967d58e06d17017f8769c4367f99b5f6803 (plain)
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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

var gTests = [
  {
    desc: "test queueing allow video behind allow video",
    run: async function testQueuingAllowVideoBehindAllowVideo() {
      let observerPromise = expectObserverCalled("getUserMedia:request");
      let promise = promisePopupNotificationShown("webRTC-shareDevices");
      await promiseRequestDevice(false, true);
      await promiseRequestDevice(false, true);
      await promise;
      checkDeviceSelectors(["camera"]);
      await observerPromise;

      let promises = [
        expectObserverCalled("getUserMedia:request"),
        expectObserverCalled("getUserMedia:response:allow", 2),
        expectObserverCalled("recording-device-events", 2),
      ];

      await promiseMessage(
        "ok",
        () => {
          PopupNotifications.panel.firstElementChild.button.click();
        },
        2
      );
      await Promise.all(promises);

      await promiseNoPopupNotification("webRTC-shareDevices");
      Assert.deepEqual(
        await getMediaCaptureState(),
        { video: true },
        "expected camera to be shared"
      );

      // close all streams
      await closeStream();
    },
  },
];

add_task(async function test() {
  SimpleTest.requestCompleteLog();
  await runTests(gTests);
});