Index: content/test/data/device_orientation/device_motion_test.html |
diff --git a/content/test/data/device_orientation/device_motion_test.html b/content/test/data/device_orientation/device_motion_test.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ebebe887402a153dec57b149092a164bf551783b |
--- /dev/null |
+++ b/content/test/data/device_orientation/device_motion_test.html |
@@ -0,0 +1,44 @@ |
+<html> |
+ <head> |
+ <title>DeviceMotion test</title> |
+ <script type="text/javascript"> |
+ var eventCount = 0; |
+ |
+ function checkMotionEvent(event) { |
+ // Return true iff the motion is close enough to |
+ // (1, 2, 3, 4, 5, 6, 7, 8, 9, 10). |
+ return Math.abs(event.acceleration.x - 1) < 0.01 && |
+ Math.abs(event.acceleration.y - 2) < 0.01 && |
+ Math.abs(event.acceleration.z - 3) < 0.01 && |
+ Math.abs(event.accelerationIncludingGravity.x - 4) < 0.01 && |
+ Math.abs(event.accelerationIncludingGravity.y - 5) < 0.01 && |
+ Math.abs(event.accelerationIncludingGravity.z - 6) < 0.01 && |
+ Math.abs(event.rotationRate.alpha - 7) < 0.01 && |
+ Math.abs(event.rotationRate.beta - 8) < 0.01 && |
+ Math.abs(event.rotationRate.gamma - 9) < 0.01 && |
+ Math.abs(event.interval - 10) < 0.01; |
+ } |
+ |
+ function onMotion(event) { |
+ if (checkMotionEvent(event)) { |
+ window.removeEventListener('devicemotion', onMotion); |
+ pass(); |
+ } else { |
+ fail(); |
+ } |
+ } |
+ |
+ function pass() { |
+ document.getElementById('status').innerHTML = 'PASS'; |
+ document.location = '#pass'; |
+ } |
+ |
+ function fail() { |
+ document.location = '#fail'; |
+ } |
+ </script> |
+ </head> |
+ <body onLoad="window.addEventListener('devicemotion', onMotion)"> |
+ <div id="status">FAIL</div> |
+ </body> |
+</html> |