summaryrefslogtreecommitdiffstats
path: root/dom/permission/tests/test_storage_access_notification.html
blob: d8b55885546f355d80012717783ea26b47778f12 (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
48
49
50
<!--
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>

<head>
  <meta charset="utf-8">
  <title>Test for Permissions API</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
  <script type="application/javascript">
    'use strict';

    SimpleTest.waitForExplicitFinish();

    async function setPermission(type, allow) {
      await SpecialPowers.popPermissions();
      await SpecialPowers.pushPermissions(
            [{ type, allow, context: document }]
          );
    }

    const {
      UNKNOWN_ACTION,
      PROMPT_ACTION,
      ALLOW_ACTION,
      DENY_ACTION
    } = SpecialPowers.Ci.nsIPermissionManager;

    window.addEventListener(
      "message",
      (event) => {
        if (event.data == "ready") {
          setPermission("3rdPartyFrameStorage^https://example.org", ALLOW_ACTION);
        } else {
          is(event.data, "granted", "storage-access permission should change to granted after the permission is set");
          SimpleTest.finish();
        }
      }
    );
    </script>
</head>

<body>
  <iframe id="frame" src="https://example.org/tests/dom/permission/tests/file_storage_access_notification_helper.html"/>
</body>

</html>