blob: 99a706f20c521a55977ee63fdd85da0dda93cb58 (
plain)
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
|
<!DOCTYPE html>
<meta charset="utf-8">
<title>AmbientLightSensor Test: onstatechange</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://www.w3.org/TR/ambient-light/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var sensor;
setup(function() {
sensor = new AmbientLightSensor();
});
test(function() {
assert_equals(sensor.state, "idle");
}, "The default sensor.state is 'idle'.");
async_test(function(t) {
sensor.onstatechange = t.step_func_done(function(event) {
assert_equals(sensor.state, "activating");
});
sensor.onerror = t.step_func_done(function(event) {
assert_unreached(event.error.name + ":" + event.error.message);
});
sensor.start();
}, "The sensor.state changes to 'activating' after sensor.start().");
async_test(function(t) {
sensor.onstatechange = t.step_func_done(function(event) {
assert_equals(sensor.state, "idle");
});
sensor.onerror = t.step_func_done(function(event) {
assert_unreached(event.error.name + ":" + event.error.message);
});
sensor.stop();
}, "The sensor.state changes to 'idle' after sensor.stop().");
</script>
|