1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
content / test / data / generic_sensor / ambient_light_sensor_test.html [blame]
<html>
<head>
<title>AmbientLight Generic Sensor test</title>
<script type="text/javascript">
var timeOrigin;
var sensor;
var activated = false;
function onAmbientLightActivate() {
activated = true;
}
function onAmbientLightReading() {
if (activated &&
sensor.illuminance == 50 &&
sensor.timestamp >= timeOrigin &&
sensor.timestamp <= window.performance.now()) {
pass();
} else {
fail();
}
}
function start() {
sensor = new AmbientLightSensor();
timeOrigin = window.performance.now();
sensor.onactivate = onAmbientLightActivate;
sensor.onreading = onAmbientLightReading;
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>