LinearAccelerationSensor-shake-threshold-manual.https.html (936B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>LinearAccelerationSensor Shake Threshold Test</title> 4 <link rel="author" title="Intel" href="http://www.intel.com"> 5 <link rel="help" href="https://w3c.github.io/accelerometer/#examples"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <p class="instructions"> 9 Shake gesture along x axis of the device. 10 </p> 11 <script> 12 13 setup({explicit_timeout: true}); 14 15 async_test(t => { 16 const shakeThreshold = 25; 17 const sensor = new LinearAccelerationSensor({frequency: 60}); 18 19 sensor.onreading = t.step_func(() => { 20 if (sensor.x > shakeThreshold) { 21 t.done(); 22 } 23 }); 24 25 sensor.onerror = t.step_func_done(event => { 26 assert_unreached(event.error.name + ":" + event.error.message); 27 }); 28 29 sensor.start(); 30 }, "Test that when shaking gesture along x axis of the device, the shake threshold can be greater than 25"); 31 32 </script>