blob: 73b3a2d6193bc6f5a120a583a7a7e6169a34487f (
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
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
|
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title>Popover should *not* light dismiss on scroll</title>
<link rel="author" href="mailto:masonf@chromium.org">
<link rel=help href="https://open-ui.org/components/popup.research.explainer">
<link rel=help href="https://github.com/openui/open-ui/issues/240">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=scroller>
Scroll me<br><br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Enim ut sem viverra aliquet eget sit amet tellus. Massa
sed elementum tempus egestas sed sed risus pretium. Felis bibendum ut tristique et egestas
quis. Tortor dignissim convallis aenean et. Eu mi bibendum neque egestas congue quisque
</div>
<div popover id=popover1>
This is popover 1
<div popover id=popover2 anchor=anchor>
This is popover 2
</div>
</div>
<button onclick='popover1.showPopover();popover2.showPopover();'>Open popovers</button>
<style>
#popover1 { top:50px; left: 50px; }
#popover2 { top:150px; left: 50px; }
#scroller {
height: 150px;
width: 150px;
overflow-y: scroll;
border: 1px solid black;
}
</style>
<script>
const popovers = document.querySelectorAll('[popover]');
function assertAll(showing) {
for(let popover of popovers) {
assert_equals(popover.matches(':open'),showing);
}
}
async_test(t => {
for(let popover of popovers) {
popover.addEventListener('beforetoggle',e => {
if (e.newState !== "closed")
return;
assert_unreached('Scrolling should not light-dismiss a popover');
});
}
assertAll(/*showing*/false);
popovers[0].showPopover();
popovers[1].showPopover();
assertAll(/*showing*/true);
scroller.scrollTo(0, 100);
requestAnimationFrame(() => {
requestAnimationFrame(() => {
assertAll(/*showing*/true);
t.done();
});
});
},'Scrolling should not light-dismiss popovers');
</script>
|