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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<!DOCTYPE html>
<title>Device Sensor Events not exposed to insecure origins</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/orientation-event-helpers.js"></script>
<script>
if (window.location.origin != get_host_info().HTTP_ORIGIN) {
window.location = get_host_info().HTTP_ORIGIN + window.location.pathname;
promise_test(_ => new Promise(_ => {}), "Stall tests on the wrong host.");
} else {
test(() => {
assert_false('DeviceMotionEvent' in window);
assert_false('DeviceOrientationEvent' in window);
assert_false('DeviceOrientationAbsoluteEvent' in window);
assert_false('DeviceMotionEventAcceleration' in window);
assert_false('DeviceMotionEventRotationRate' in window);
assert_false('ondevicemotion' in window);
assert_false('ondeviceorientation' in window);
assert_false('ondeviceorientationabsolute' in window);
}, 'Event interfaces and event handlers are not exposed on `window`.');
promise_test(async (t) => {
const helper = new SensorTestHelper(t, 'devicemotion');
await helper.initializeSensors();
const motionData = generateMotionData(1, 2, 3,
4, 5, 6,
7, 8, 9);
await helper.setData(motionData);
window.ondevicemotion = t.unreached_func("devicemotion event should not be fired.");
await new Promise(r => t.step_timeout(r, 1000));
}, 'addEventListener() for `devicemotion` does not crash but the handler never fires.');
promise_test(async (t) => {
const helper = new SensorTestHelper(t, 'deviceorientation');
await helper.initializeSensors();
const orientationData = generateOrientationData(1.1, 2.2, 3.3, false);
await helper.setData(orientationData);
window.ondeviceorientation = t.unreached_func("deviceorientation event should not be fired.");
await new Promise(r => t.step_timeout(r, 1000));
}, 'addEventListener() for `deviceorientation` does not crash but the handler never fires.');
promise_test(async (t) => {
const helper = new SensorTestHelper(t, 'deviceorientationabsolute');
await helper.initializeSensors();
const orientationData = generateOrientationData(1.1, 2.2, 3.3, true);
await helper.setData(orientationData);
window.ondeviceorientationabsolute = t.unreached_func("deviceorientationabsolute event should not be fired.");
await new Promise(r => t.step_timeout(r, 1000));
}, 'addEventListener() for `deviceorientationabsolute` does not crash but the handler never fires.');
}
</script>
|