rounding.https.html (1405B)
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 check_properties_for_coarsening(obj, properties) { 11 assert_not_equals(obj, null, 'Expected event object'); 12 for (const prop of properties) { 13 assertValueIsCoarsened(obj[prop]); 14 } 15 } 16 17 promise_test(async (t) => { 18 const helper = new SensorTestHelper(t, 'devicemotion'); 19 await helper.grantSensorsPermissions(); 20 await helper.initializeSensors(); 21 22 const value = 1.23456789; 23 const motionData = generateMotionData(value, value, value, 24 value, value, value, 25 value, value, value); 26 await helper.setData(motionData); 27 28 const event = await new Promise(resolve => { 29 window.addEventListener('devicemotion', t.step_func(ev => { 30 resolve(ev); 31 }, { once: true })); 32 }); 33 34 check_properties_for_coarsening(event.acceleration, ['x', 'y', 'z']); 35 check_properties_for_coarsening(event.accelerationIncludingGravity, ['x', 'y', 'z']); 36 check_properties_for_coarsening(event.rotationRate, ['alpha', 'beta', 'gamma']); 37 }, 'Tests that devicemotion values are correctly rounded.'); 38 </script>