Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <title>DeviceOrientation test</title> | 3 <title>DeviceOrientation all-null event test</title> |
| 4 <script type="text/javascript"> | 4 <script type="text/javascript"> |
| 5 var eventCount = 0; | |
| 6 | |
| 7 function checkOrientationEvent(event) { | 5 function checkOrientationEvent(event) { |
| 8 // Return true iff the orientation is close enough to (1, 2, 3). | 6 return event.alpha == null && |
| 9 return Math.abs(event.alpha - 1) < 0.01 && | 7 event.beta == null && |
| 10 Math.abs(event.beta - 2) < 0.01 && | 8 event.gamma == null; |
| 11 Math.abs(event.gamma - 3) < 0.01; | |
| 12 } | 9 } |
| 13 | 10 |
| 14 function onOrientation(event) { | 11 function onOrientation(event) { |
| 15 if (checkOrientationEvent(event)) { | 12 if (checkOrientationEvent(event)) { |
| 16 window.removeEventListener('deviceorientation', onOrientation); | 13 window.removeEventListener('deviceorientation', onOrientation); |
|
mlamouri (slow - plz ping)
2014/04/04 13:47:07
ditto
| |
| 17 pass(); | 14 pass(); |
| 18 } else { | 15 } else { |
| 19 fail(); | 16 fail(); |
| 20 } | 17 } |
| 21 } | 18 } |
| 22 | 19 |
| 23 function pass() { | 20 function pass() { |
| 24 document.getElementById('status').innerHTML = 'PASS'; | 21 document.getElementById('status').innerHTML = 'PASS'; |
| 25 document.location = '#pass'; | 22 document.location = '#pass'; |
| 26 } | 23 } |
| 27 | 24 |
| 28 function fail() { | 25 function fail() { |
| 29 document.location = '#fail'; | 26 document.location = '#fail'; |
| 30 } | 27 } |
| 28 | |
| 29 window.addEventListener('deviceorientation', onOrientation); | |
| 30 alert("suspend active DOM objects"); | |
| 31 </script> | 31 </script> |
| 32 </head> | 32 </head> |
| 33 <body onLoad="window.addEventListener('deviceorientation', onOrientation)"> | 33 <body> |
| 34 <div id="status">FAIL</div> | 34 <div id="status">FAIL</div> |
| 35 </body> | 35 </body> |
| 36 </html> | 36 </html> |
| OLD | NEW |