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: popup 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">
<popup slot="listbox" part="listbox" id="selectMenu0-popup">
<option>bottom left</option>
<option>two</option>
<div part="option">three</div>
</popup>
</selectmenu>
<br>
<selectmenu id="selectMenu1">
<popup slot="listbox" part="listbox" id="selectMenu1-popup">
<option>top left</option>
<option>two</option>
<div part="option">three</div>
</popup>
</selectmenu>
<selectmenu id="selectMenu2">
<popup slot="listbox" part="listbox" id="selectMenu2-popup">
<option>bottom right</option>
<option>two</option>
<div part="option">three</div>
</popup>
</selectmenu>
<selectmenu id="selectMenu3">
<popup slot="listbox" part="listbox" id="selectMenu3-popup">
<option>top right</option>
<option>two</option>
<div part="option">three</div>
</popup>
</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 selectMenu0Popup = document.getElementById("selectMenu0-popup");
await clickOn(selectMenu0);
assert_equals(Math.round(selectMenu0.getBoundingClientRect().bottom), Math.round(selectMenu0Popup.getBoundingClientRect().top));
assert_equals(Math.round(selectMenu0.getBoundingClientRect().left), Math.round(selectMenu0Popup.getBoundingClientRect().left));
}, "The popup should be bottom left positioned");
promise_test(async () => {
const selectMenu1 = document.getElementById("selectMenu1");
const selectMenu1Popup = document.getElementById("selectMenu1-popup");
await clickOn(selectMenu1);
assert_equals(Math.round(selectMenu1.getBoundingClientRect().top), Math.round(selectMenu1Popup.getBoundingClientRect().bottom));
assert_equals(Math.round(selectMenu1.getBoundingClientRect().left), Math.round(selectMenu1Popup.getBoundingClientRect().left));
}, "The popup should be top left positioned");
promise_test(async () => {
const selectMenu2 = document.getElementById("selectMenu2");
const selectMenu2Popup = document.getElementById("selectMenu2-popup");
await clickOn(selectMenu2);
assert_equals(Math.round(selectMenu2.getBoundingClientRect().bottom), Math.round(selectMenu2Popup.getBoundingClientRect().top));
assert_equals(Math.round(selectMenu2.getBoundingClientRect().right), Math.round(selectMenu2Popup.getBoundingClientRect().right));
}, "The popup should be bottom right positioned");
promise_test(async () => {
const selectMenu3 = document.getElementById("selectMenu3");
const selectMenu3Popup = document.getElementById("selectMenu3-popup");
await clickOn(selectMenu3);
assert_equals(Math.round(selectMenu3.getBoundingClientRect().top), Math.round(selectMenu3Popup.getBoundingClientRect().bottom));
assert_equals(Math.round(selectMenu3.getBoundingClientRect().right), Math.round(selectMenu3Popup.getBoundingClientRect().right));
}, "The popup should be top right positioned");
</script>
|