Home | History | Annotate | Download | only in device_sensors
      1 <html>
      2   <head>
      3     <title>DeviceMotion all-null event test with alert</title>
      4     <script type="text/javascript">
      5       function checkMotionEvent(event) {
      6         return event.acceleration.x == null &&
      7                event.acceleration.y == null &&
      8                event.acceleration.z == null &&
      9                event.accelerationIncludingGravity.x == null &&
     10                event.accelerationIncludingGravity.y == null &&
     11                event.accelerationIncludingGravity.z == null &&
     12                event.rotationRate.alpha == null &&
     13                event.rotationRate.beta == null &&
     14                event.rotationRate.gamma == null;
     15       }
     16 
     17       function onMotion(event) {
     18         window.removeEventListener('devicemotion', onMotion);
     19         checkMotionEvent(event) ? pass() : fail();
     20       }
     21 
     22       function pass() {
     23         document.getElementById('status').innerHTML = 'PASS';
     24         document.location = '#pass';
     25       }
     26 
     27       function fail() {
     28         document.location = '#fail';
     29       }
     30 
     31       window.addEventListener('devicemotion', onMotion);
     32       alert("suspend active DOM objects");
     33     </script>
     34   </head>
     35   <body>
     36     <div id="status">FAIL</div>
     37   </body>
     38 </html>
     39