tor-browser

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

web-usb.https.html (1083B)


      1 <!DOCTYPE html>
      2 <title>Test WebUSB navigator.usb.requestDevice()</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/utils.js"></script>
      6 <script src="/common/dispatcher/dispatcher.js"></script>
      7 <script src="resources/utils.js"></script>
      8 
      9 <body>
     10 <script>
     11 promise_test(async () => {
     12  const frame = attachFencedFrameContext();
     13  await frame.execute(async () => {
     14    // Request USB access inside the fenced frame. It should fail.
     15    // https://github.com/shivanigithub/fenced-frame#security-considerations.
     16    try {
     17      await navigator.usb.requestDevice({ filters: [{ vendorId: 0}] });
     18      throw 'The USB request should not succeed.';
     19    } catch (e) {
     20      assert_equals(e.name, 'SecurityError');
     21      assert_equals(e.message,
     22        "Failed to execute 'requestDevice' on 'USB': " +
     23        'Access to the feature "usb" is disallowed by permissions policy.',
     24        'Fenced frame has the right error for usb.requestDevice.');
     25    }
     26  });
     27 }, 'navigator.usb.requestDevice');
     28 </script>
     29 </body>