tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_storage_access_notification.html (1319B)


      1 <!--
      2  Any copyright is dedicated to the Public Domain.
      3  http://creativecommons.org/publicdomain/zero/1.0/
      4 -->
      5 <!DOCTYPE HTML>
      6 <html>
      7 
      8 <head>
      9  <meta charset="utf-8">
     10  <title>Test for Permissions API</title>
     11  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     12  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
     13  <script type="application/javascript">
     14    'use strict';
     15 
     16    SimpleTest.waitForExplicitFinish();
     17 
     18    async function setPermission(type, allow) {
     19      await SpecialPowers.popPermissions();
     20      await SpecialPowers.pushPermissions(
     21            [{ type, allow, context: document }]
     22          );
     23    }
     24 
     25    const {
     26      UNKNOWN_ACTION,
     27      PROMPT_ACTION,
     28      ALLOW_ACTION,
     29      DENY_ACTION
     30    } = SpecialPowers.Ci.nsIPermissionManager;
     31 
     32    window.addEventListener(
     33      "message",
     34      (event) => {
     35        if (event.data == "ready") {
     36          setPermission("3rdPartyFrameStorage^https://example.org", ALLOW_ACTION);
     37        } else {
     38          is(event.data, "granted", "storage-access permission should change to granted after the permission is set");
     39          SimpleTest.finish();
     40        }
     41      }
     42    );
     43    </script>
     44 </head>
     45 
     46 <body>
     47  <iframe id="frame" src="https://example.org/tests/dom/permission/tests/file_storage_access_notification_helper.html"/>
     48 </body>
     49 
     50 </html>