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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<!DOCTYPE html>
<html>
<title>HTMLSelectMenuElement Test: popover position</title>
<link rel="author" title="Ionel Popescu" href="mailto:iopopesc@microsoft.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
#selectMenu0 {
position: absolute;
top: 0px;
left: 0px;
}
#selectMenu1 {
position: absolute;
bottom: 0px;
left: 0px;
}
#selectMenu2 {
position: absolute;
top: 0px;
right: 0px;
}
#selectMenu3 {
position: absolute;
bottom: 0px;
right: 0px;
}
</style>
<selectmenu id="selectMenu0">
<div popover slot="listbox" behavior="listbox" id="selectMenu0-popover">
<option>bottom left</option>
<option>two</option>
<option>three</option>
</div>
</selectmenu>
<br>
<selectmenu id="selectMenu1">
<div popover slot="listbox" behavior="listbox" id="selectMenu1-popover">
<option>top left</option>
<option>two</option>
<option>three</option>
</div>
</selectmenu>
<selectmenu id="selectMenu2">
<div popover slot="listbox" behavior="listbox" id="selectMenu2-popover">
<option>bottom right</option>
<option>two</option>
<option>three</option>
</div>
</selectmenu>
<selectmenu id="selectMenu3">
<div popover slot="listbox" behavior="listbox" id="selectMenu3-popover">
<option>top right</option>
<option>two</option>
<option>three</option>
</div>
</selectmenu>
<script>
function clickOn(element) {
const actions = new test_driver.Actions();
return actions.pointerMove(0, 0, {origin: element})
.pointerDown({button: actions.ButtonType.LEFT})
.pointerUp({button: actions.ButtonType.LEFT})
.send();
}
promise_test(async () => {
const selectMenu0 = document.getElementById("selectMenu0");
const selectMenu0Popover = document.getElementById("selectMenu0-popover");
await clickOn(selectMenu0);
assert_equals(Math.abs(Math.trunc(selectMenu0.getBoundingClientRect().bottom - selectMenu0Popover.getBoundingClientRect().top)), 0);
assert_equals(Math.abs(Math.trunc(selectMenu0.getBoundingClientRect().left - selectMenu0Popover.getBoundingClientRect().left)), 0);
}, "The popover should be bottom left positioned");
promise_test(async () => {
const selectMenu1 = document.getElementById("selectMenu1");
const selectMenu1Popover = document.getElementById("selectMenu1-popover");
await clickOn(selectMenu1);
assert_equals(Math.abs(Math.trunc(selectMenu1.getBoundingClientRect().top - selectMenu1Popover.getBoundingClientRect().bottom)), 0);
assert_equals(Math.abs(Math.trunc(selectMenu1.getBoundingClientRect().left - selectMenu1Popover.getBoundingClientRect().left)), 0);
}, "The popover should be top left positioned");
promise_test(async () => {
const selectMenu2 = document.getElementById("selectMenu2");
const selectMenu2Popover = document.getElementById("selectMenu2-popover");
await clickOn(selectMenu2);
assert_equals(Math.abs(Math.trunc(selectMenu2.getBoundingClientRect().bottom - selectMenu2Popover.getBoundingClientRect().top)), 0);
assert_equals(Math.abs(Math.trunc(selectMenu2.getBoundingClientRect().right - selectMenu2Popover.getBoundingClientRect().right)), 0);
}, "The popover should be bottom right positioned");
promise_test(async () => {
const selectMenu3 = document.getElementById("selectMenu3");
const selectMenu3Popover = document.getElementById("selectMenu3-popover");
await clickOn(selectMenu3);
assert_equals(Math.abs(Math.trunc(selectMenu3.getBoundingClientRect().top - selectMenu3Popover.getBoundingClientRect().bottom)), 0);
assert_equals(Math.abs(Math.trunc(selectMenu3.getBoundingClientRect().right - selectMenu3Popover.getBoundingClientRect().right)), 0);
}, "The popover should be top right positioned");
</script>
|