requestPermission.https.window.js (2066B)
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 permission 9 // tokens corresponding to the sensors used to implement support for motion 10 // events. They also match the feature policy tokens required by both Blink and 11 // WebKit. 12 const permissionDescriptorNames = ['accelerometer', 'gyroscope']; 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 DeviceMotionEvent.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 DeviceMotionEvent.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 DeviceMotionEvent.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 DeviceMotionEvent.requestPermission(); 46 assert_equals(permission, 'denied'); 47 }); 48 }, 'requestPermission() returns "denied" for denied permissions with user activation');