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

const TEST_PAGE =
  "https://example.com/browser/browser/base/content/test/permissions/empty.html";

add_task(async function testNoPermissionPrompt() {
  info("Creating tab");
  await BrowserTestUtils.withNewTab(TEST_PAGE, async function (browser) {
    await new Promise(r => {
      SpecialPowers.pushPrefEnv(
        {
          set: [
            ["dom.vibrator.enabled", true],
            ["dom.security.featurePolicy.header.enabled", true],
            ["dom.security.featurePolicy.webidl.enabled", true],
          ],
        },
        r
      );
    });

    await ContentTask.spawn(browser, null, async function () {
      let frame = content.document.createElement("iframe");
      // Cross origin src
      frame.src =
        "https://example.org/browser/browser/base/content/test/permissions/empty.html";
      await new Promise(resolve => {
        frame.addEventListener("load", () => {
          resolve();
        });
        content.document.body.appendChild(frame);
      });

      await content.SpecialPowers.spawn(frame, [], async function () {
        // Request a permission.
        let result = this.content.navigator.vibrate([100, 100]);
        Assert.equal(result, false, "navigator.vibrate has been denied");
      });
      content.document.body.removeChild(frame);
    });
  });
});