basic-operation.https.html (1529B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testdriver.js"></script> 5 <script src="/resources/testdriver-vendor.js"></script> 6 <script src="../resources/orientation-event-helpers.js"></script> 7 <script> 8 'use strict'; 9 10 promise_test(async (t) => { 11 const helper = new SensorTestHelper(t, 'deviceorientation'); 12 await helper.grantSensorsPermissions(); 13 await helper.initializeSensors(); 14 15 const orientationData = generateOrientationData(1.1, 2.2, 3.3, false); 16 await helper.setData(orientationData); 17 await waitForEvent(getExpectedOrientationEvent(orientationData)); 18 }, 'Tests basic operation of deviceorientation event using mock data.'); 19 20 promise_test(async (t) => { 21 const helper = new SensorTestHelper(t, 'deviceorientation'); 22 await helper.grantSensorsPermissions(); 23 await helper.initializeSensors({disabledSensors: ['relative-orientation']}); 24 25 const orientationData = generateOrientationData(null, null, null, false); 26 const watcher = new EventWatcher(t, window, ['deviceorientation']); 27 28 const event = await watcher.wait_for('deviceorientation'); 29 assert_equals(event.type, 'deviceorientation', 'type is set to \"deviceorientation\"'); 30 assert_true(event instanceof DeviceOrientationEvent, 'event is DeviceOrientationEvent'); 31 32 assertEventEquals(event, getExpectedOrientationEvent(orientationData)); 33 }, 'If UA can never provide orientation information, the event should be fired as a null event.'); 34 </script>