OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <title>DeviceMotion only some sensors are available test</title> | |
4 <script type="text/javascript"> | |
5 let expectedInterval = Math.floor(1000 / 60); | |
6 function checkMotionEvent(event) { | |
7 return event.acceleration.x == 1 && | |
8 event.acceleration.y == 2 && | |
9 event.acceleration.z == 3 && | |
10 event.accelerationIncludingGravity.x == null && | |
11 event.accelerationIncludingGravity.y == null && | |
12 event.accelerationIncludingGravity.z == null && | |
13 event.rotationRate.alpha == 7 && | |
14 event.rotationRate.beta == 8 && | |
15 event.rotationRate.gamma == 9 && | |
16 event.interval == expectedInterval; | |
17 } | |
18 | |
19 function onMotion(event) { | |
20 if (checkMotionEvent(event)) { | |
21 window.removeEventListener('devicemotion', onMotion); | |
22 pass(); | |
23 } else { | |
24 fail(); | |
25 } | |
26 } | |
27 | |
28 function pass() { | |
29 document.getElementById('status').innerHTML = 'PASS'; | |
30 document.location = '#pass'; | |
31 } | |
32 | |
33 function fail() { | |
34 document.location = '#fail'; | |
35 } | |
36 </script> | |
37 </head> | |
38 <body onLoad="window.addEventListener('devicemotion', onMotion)"> | |
39 <div id="status">FAIL</div> | |
40 </body> | |
41 </html> | |
OLD | NEW |