Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <title>Device Motion/Orientation all-null event test with alert</title> | 3 <title>Device Orientation all-null event test with alert</title> |
| 4 </head> | 4 </head> |
| 5 <body> | 5 <body> |
| 6 <div id="status">FAIL</div> | 6 <div id="status">FAIL</div> |
| 7 </body> | 7 </body> |
| 8 <script type="text/javascript"> | 8 <script type="text/javascript"> |
| 9 passedOrientation = false; | |
| 10 passedMotion = false; | |
| 11 | 9 |
| 12 function checkOrientationEvent(event) { | 10 function checkOrientationEvent(event) { |
| 13 return event.alpha == null && | 11 return event.alpha == null && |
| 14 event.beta == null && | 12 event.beta == null && |
| 15 event.gamma == null; | 13 event.gamma == null; |
| 16 } | 14 } |
| 17 | 15 |
| 18 function checkMotionEvent(event) { | |
| 19 return event.acceleration.x == null && | |
| 20 event.acceleration.y == null && | |
| 21 event.acceleration.z == null && | |
| 22 event.accelerationIncludingGravity.x == null && | |
| 23 event.accelerationIncludingGravity.y == null && | |
| 24 event.accelerationIncludingGravity.z == null && | |
| 25 event.rotationRate.alpha == null && | |
| 26 event.rotationRate.beta == null && | |
| 27 event.rotationRate.gamma == null; | |
| 28 } | |
| 29 | |
| 30 function onOrientation(event) { | 16 function onOrientation(event) { |
| 31 window.removeEventListener('deviceorientation', onOrientation); | 17 window.removeEventListener('deviceorientation', onOrientation); |
| 32 checkOrientationEvent(event) ? passOrientation() : fail(); | 18 checkOrientationEvent(event) ? passOrientation() : fail(); |
| 33 } | 19 } |
| 34 | 20 |
| 35 function onMotion(event) { | |
| 36 window.removeEventListener('devicemotion', onMotion); | |
| 37 checkMotionEvent(event) ? passMotion() : fail(); | |
| 38 } | |
| 39 | |
| 40 function passOrientation() { | 21 function passOrientation() { |
| 41 passedOrientation = true; | 22 pass(); |
| 42 if (passedMotion) pass(); | |
| 43 } | |
| 44 | |
| 45 function passMotion() { | |
| 46 passedMotion = true; | |
| 47 if (passedOrientation) pass(); | |
| 48 } | 23 } |
| 49 | 24 |
| 50 function pass() { | 25 function pass() { |
| 51 document.getElementById('status').innerHTML = 'PASS'; | 26 document.getElementById('status').innerHTML = 'PASS'; |
| 52 document.location = '#pass'; | 27 document.location = '#pass'; |
| 53 } | 28 } |
| 54 | 29 |
| 55 function fail() { | 30 function fail() { |
| 56 document.location = '#fail'; | 31 document.location = '#fail'; |
| 57 } | 32 } |
| 58 | 33 |
| 59 window.addEventListener('deviceorientation', onOrientation); | 34 window.addEventListener('deviceorientation', onOrientation); |
| 60 window.addEventListener('devicemotion', onMotion); | |
|
timvolodine
2017/05/23 12:33:40
why remove the motion test?
juncai
2017/05/23 21:33:55
https://codereview.chromium.org/2896583005/diff/20
timvolodine
2017/05/24 15:30:16
Removing this as such reduces test coverage. Can t
juncai
2017/05/26 02:38:53
Updated the device sensors browsertest, and this f
| |
| 61 | 35 |
| 62 // Raise a modal alert dialog to test that the one-off null-events | 36 // Raise a modal alert dialog to test that the one-off null-events |
| 63 // still propagate to window after the alert is dismissed. | 37 // still propagate to window after the alert is dismissed. |
| 64 alert("suspend active DOM objects"); | 38 alert("suspend active DOM objects"); |
| 65 </script> | 39 </script> |
| 66 </html> | 40 </html> |
| OLD | NEW |