screen-upright-manual.https.html (1455B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>DeviceMotionEvent: A device with the screen upright</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <link rel="author' title='Mosquito FP7"> 8 <link rel="reviewer author" title="Zhiqiang Zhang" href="mailto:zhiqiang.zhang@intel.com"> <!-- 2013-10-14 --> 9 </head> 10 <body> 11 <p>Put the device with the screen upright.</p> 12 <div id="log"></div> 13 <script> 14 var t = async_test(); 15 var run = false; 16 17 /* 18 * A device with the screen upright has an acceleration of zero 19 * and the following value for accelerationIncludingGravity: 20 * { 21 * x: 0, 22 * y: -9.81, 23 * z: 0 24 * }; 25 */ 26 window.addEventListener("devicemotion", function(e) { 27 if (!run) { 28 run = true; 29 t.step(function() { 30 var gvt = e.accelerationIncludingGravity; 31 var acc = e.acceleration; 32 var rot = e.rotationRate; 33 34 assert_approx_equals(gvt.x, 0, 1); 35 assert_approx_equals(gvt.y, -9.81, 1.5); 36 assert_approx_equals(gvt.z, 0, 1); 37 38 assert_approx_equals(acc.x, 0, 1); 39 assert_approx_equals(acc.y, 0, 1); 40 assert_approx_equals(acc.z, 0, 1); 41 42 assert_equals(rot, null); 43 }); 44 t.done(); 45 } 46 }, false); 47 </script> 48 </body> 49 </html>