null-values.https.html (1635B)
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 function test_null_orientation_data(eventType) { 11 promise_test(async t => { 12 const helper = new SensorTestHelper(t, eventType); 13 await helper.grantSensorsPermissions(); 14 await helper.initializeSensors( 15 {disabledSensors : [ 'absolute-orientation', 'relative-orientation' ]}); 16 17 const inputData = generateOrientationData(1.1, 2.2, 3.3, false); 18 // Currently it is not possible to set individual values to null because 19 // the parsing algorithms used by 20 // https://w3c.github.io/sensors/#update-virtual-sensor-reading-command 21 // always expect numbers. 22 const expectedData = generateOrientationData( 23 null, null, null, 24 /*absolute=*/ eventType === 'deviceorientationabsolute'); 25 const expectedEvent = eventType === 'deviceorientationabsolute' 26 ? getExpectedAbsoluteOrientationEvent 27 : getExpectedOrientationEvent; 28 29 // An example how setting the orientation sensors as disabled will always 30 // output null values. 31 await helper.setData(inputData); 32 await waitForEvent(expectedEvent(expectedData)); 33 }, `${eventType}: Missing values are set to null or true/false accordingly`); 34 } 35 36 test_null_orientation_data('deviceorientation'); 37 test_null_orientation_data('deviceorientationabsolute'); 38 </script>