| <html> |
| <head> |
| <title>AmbientLight Generic Sensor test</title> |
| <script type="text/javascript"> |
| var timeOrigin; |
| var sensor; |
| function onAmbientLightReadingChange() { |
| if (sensor.illuminance == 50 && |
| sensor.timestamp > timeOrigin && |
| sensor.timestamp < window.performance.now()) { |
| pass(); |
| } else { |
| fail(); |
| } |
| } |
| |
| function start() { |
| sensor = new AmbientLightSensor(); |
| timeOrigin = window.performance.now(); |
| sensor.onchange = |
| onAmbientLightReadingChange; |
| sensor.start(); |
| } |
| |
| function pass() { |
| document.getElementById('status').innerHTML = 'PASS'; |
| document.location = '#pass'; |
| } |
| |
| function fail() { |
| document.location = '#fail'; |
| } |
| </script> |
| </head> |
| <body onLoad="start()"> |
| <div id="status">FAIL</div> |
| </body> |
| </html> |