-
Notifications
You must be signed in to change notification settings - Fork 54
/
onchange-event.html
41 lines (39 loc) · 1.5 KB
/
onchange-event.html
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
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
promise_test(async t => {
await test_driver.bless("request full screen", () => {
return document.documentElement.requestFullscreen();
});
const type = screen.orientation.type;
screen.orientation.onchange = t.unreached_func("change event should not be fired");
await screen.orientation.lock(type);
assert_equals(screen.orientation.type, type);
return document.exitFullscreen();
}, "Test that orientationchange event is not fired when the orientation does not change.");
promise_test(async t => {
await test_driver.bless("request full screen", () => {
return document.documentElement.requestFullscreen();
});
let orientations = [
'portrait-primary',
'portrait-secondary',
'landscape-primary',
'landscape-secondary'
];
if (screen.orientation.type.includes('portrait')) {
orientations = orientations.reverse();
}
const orientationWatcher = new EventWatcher(t, screen.orientation, 'change');
for (const orientation of orientations) {
await screen.orientation.lock(orientation);
await orientationWatcher.wait_for('change');
assert_equals(screen.orientation.type, orientation);
}
screen.orientation.unlock();
return document.exitFullscreen();
}, "Test that orientationchange event is fired when the orientation changes.");
</script>