1 // META: script=/resources/testdriver.js
2 // META: script=/resources/testdriver-vendor.js
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'];
14 promise_test(async (t) => {
15 await Promise.all(permissionDescriptorNames.map(
16 name => test_driver.set_permission({name}, 'granted')));
18 const permission = await DeviceOrientationEvent.requestPermission();
19 assert_equals(permission, 'granted');
20 }, 'requestPermission() returns "granted" for granted permissions without user activation');
22 promise_test(async (t) => {
23 await Promise.all(permissionDescriptorNames.map(
24 name => test_driver.set_permission({name}, 'granted')));
26 return test_driver.bless('enable user activation', async () => {
27 const permission = await DeviceOrientationEvent.requestPermission();
28 assert_equals(permission, 'granted');
30 }, 'requestPermission() returns "granted" for granted permissions with user activation');
32 promise_test(async (t) => {
33 await Promise.all(permissionDescriptorNames.map(
34 name => test_driver.set_permission({name}, 'denied')));
36 const permission = await DeviceOrientationEvent.requestPermission();
37 assert_equals(permission, 'denied');
38 }, 'requestPermission() returns "denied" for denied permissions without user activation');
40 promise_test(async (t) => {
41 await Promise.all(permissionDescriptorNames.map(
42 name => test_driver.set_permission({name}, 'denied')));
44 return test_driver.bless('enable user activation', async () => {
45 const permission = await DeviceOrientationEvent.requestPermission();
46 assert_equals(permission, 'denied');
48 }, 'requestPermission() returns "denied" for denied permissions with user activation');