tor-browser

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

requestPermission.https.window.js (2084B)


      1 // META: script=/resources/testdriver.js
      2 // META: script=/resources/testdriver-vendor.js
      3 
      4 'use strict';
      5 
      6 // The Device Orientation spec does not fully integrate with the Permissions
      7 // spec and does not list the permissions that are expected for
      8 // requestPermission() to work. The list below was based on the permissions
      9 // listed in https://w3c.github.io/orientation-sensor/#model for the low-level
     10 // sensors that power absolute and relative orientation sensors.
     11 const permissionDescriptorNames =
     12    ['accelerometer', 'gyroscope', 'magnetometer'];
     13 
     14 promise_test(async (t) => {
     15  await Promise.all(permissionDescriptorNames.map(
     16      name => test_driver.set_permission({name}, 'granted')));
     17 
     18  const permission = await DeviceOrientationEvent.requestPermission();
     19  assert_equals(permission, 'granted');
     20 }, 'requestPermission() returns "granted" for granted permissions without user activation');
     21 
     22 promise_test(async (t) => {
     23  await Promise.all(permissionDescriptorNames.map(
     24      name => test_driver.set_permission({name}, 'granted')));
     25 
     26  return test_driver.bless('enable user activation', async () => {
     27    const permission = await DeviceOrientationEvent.requestPermission();
     28    assert_equals(permission, 'granted');
     29  });
     30 }, 'requestPermission() returns "granted" for granted permissions with user activation');
     31 
     32 promise_test(async (t) => {
     33  await Promise.all(permissionDescriptorNames.map(
     34      name => test_driver.set_permission({name}, 'denied')));
     35 
     36  const permission = await DeviceOrientationEvent.requestPermission();
     37  assert_equals(permission, 'denied');
     38 }, 'requestPermission() returns "denied" for denied permissions without user activation');
     39 
     40 promise_test(async (t) => {
     41  await Promise.all(permissionDescriptorNames.map(
     42      name => test_driver.set_permission({name}, 'denied')));
     43 
     44  return test_driver.bless('enable user activation', async () => {
     45    const permission = await DeviceOrientationEvent.requestPermission();
     46    assert_equals(permission, 'denied');
     47  });
     48 }, 'requestPermission() returns "denied" for denied permissions with user activation');