4 <p>Test the effect of pointer-events on overflow scrollbars.
</p>
6 <div id=
"result">FAIL: script didn't run to completion.
</div>
8 <div id=
"div1" style=
"position: absolute; top: 100px; width: 130px; height: 340px; background-color: SeaShell; overflow: none;">
11 <div id=
"div2" style=
"position: absolute; top: 120px; width: 100px; height: 300px; background-color: Salmon; overflow: auto; pointer-events: all; z-index: 1;">
12 <div id=
"div2Content" style=
"width: 200%; height: 500px;">
17 <div id=
"div3" style=
"position: absolute; top: 100px; left: 300px; width: 300px; height: 300px; background-color: PaleTurquoise; overflow: none;">
19 <div id=
"div4" style=
"position: absolute; top: 30px; left: 30px; width: 240px; height: 240px; background-color: MediumTurquoise; overflow: auto; pointer-events: none;">
20 <div id=
"div4Content" style=
"width: 200%; height: 200%;">
22 <div id=
"div5" style=
"position: absolute; top: 30px; left: 30px; width: 180px; height: 180px; background-color: DarkSeaGreen; overflow: auto; pointer-events: all;">
23 <div id=
"div5Content" style=
"width: 200%; height: 200%;">
33 if (window
.testRunner
)
34 testRunner
.dumpAsText();
36 var div1
= document
.getElementById("div1");
37 var div2
= document
.getElementById("div2");
39 // First sanity check points that should be within div2's vertical and horizontal scrollbars
40 // when it has pointer-events:all.
41 // Subtract 5px from the right (bottom) edge to get a point within the vertical (horizontal) scrollbar.
42 var verticalPoint
= [div2
.offsetLeft
+ div2
.offsetWidth
- 5, div2
.offsetTop
+ Math
.floor(div2
.offsetHeight
/ 2)];
43 var horizontalPoint
= [div2
.offsetLeft
+ Math
.floor(div2
.offsetWidth
/ 2), div2
.offsetTop
+ div2
.offsetHeight
- 5];
44 var elem
= document
.elementFromPoint(verticalPoint
[0], verticalPoint
[1]);
45 var elem2
= document
.elementFromPoint(horizontalPoint
[0], horizontalPoint
[1]);
46 if (elem
.id
!= div2
.id
|| elem2
.id
!= div2
.id
) {
47 document
.getElementById("result").firstChild
.data
= "FAILURE: The element at points (" + verticalPoint
+ ") and (" + horizontalPoint
+ ") needs to be div2. You may need to turn on overflow scrollbars temporarily. (On Mac: Change the 'Show scroll bars' setting to 'Always'.)";
51 // Apply pointer-events:visible to div2.
52 div2
.style
.pointerEvents
= "visible";
53 if (window
.getComputedStyle(div2
).visibility
!= "visible") {
54 document
.getElementById("result").firstChild
.data
= "FAILURE: div2 needs to be visible.";
57 elem
= document
.elementFromPoint(verticalPoint
[0], verticalPoint
[1]);
58 elem2
= document
.elementFromPoint(horizontalPoint
[0], horizontalPoint
[1]);
59 if (elem
.id
!= div2
.id
|| elem2
.id
!= div2
.id
) {
60 document
.getElementById("result").firstChild
.data
= "FAILURE: With pointer-events:visible and visibility:visible applied to div2, (" + verticalPoint
+ ") and (" + horizontalPoint
+ ") should be div2.";
64 // Hide div2 by applying visibility:hidden. Now when we hit test div2's scrollbars, we should
66 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0338.html
67 div2
.style
.visibility
= "hidden";
68 elem
= document
.elementFromPoint(verticalPoint
[0], verticalPoint
[1]);
69 elem2
= document
.elementFromPoint(horizontalPoint
[0], horizontalPoint
[1]);
70 if (elem
.id
!= div1
.id
|| elem2
.id
!= div1
.id
) {
71 document
.getElementById("result").firstChild
.data
= "FAILURE: With pointer-events:visible and visibility:hidden applied to div2, (" + verticalPoint
+ ") and (" + horizontalPoint
+ ") should be div1.";
75 var div3
= document
.getElementById("div3");
76 var div4
= document
.getElementById("div4");
77 var div5
= document
.getElementById("div5");
79 // div4 has pointer-events:none and scrollbars. Overflow scrollbars of an element having
80 // pointer-events:none do not participate in hit testing.
81 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0338.html
82 var bcr
= div4
.getBoundingClientRect();
83 verticalPoint
= [Math
.floor(bcr
.right
- 5), Math
.floor(bcr
.top
+ bcr
.height
/ 2)];
84 horizontalPoint
= [Math
.floor(bcr
.left
+ bcr
.width
/ 2), Math
.floor(bcr
.bottom
- 5)];
85 elem
= document
.elementFromPoint(verticalPoint
[0], verticalPoint
[1]);
86 elem2
= document
.elementFromPoint(horizontalPoint
[0], horizontalPoint
[1]);
87 if (elem
.id
!= div3
.id
|| elem2
.id
!= div3
.id
) {
88 document
.getElementById("result").firstChild
.data
= "FAILURE: With pointer-events:none applied to div4, (" + verticalPoint
+ ") and (" + horizontalPoint
+ ") should be div3.";
92 // However, descendants of pointer-events:none elements having pointer-events:all do
93 // participate in hit testing.
94 bcr
= div5
.getBoundingClientRect();
95 verticalPoint
= [Math
.floor(bcr
.right
- 5), Math
.floor(bcr
.top
+ bcr
.height
/ 2)];
96 horizontalPoint
= [Math
.floor(bcr
.left
+ bcr
.width
/ 2), Math
.floor(bcr
.bottom
- 5)];
97 elem
= document
.elementFromPoint(verticalPoint
[0], verticalPoint
[1]);
98 elem2
= document
.elementFromPoint(horizontalPoint
[0], horizontalPoint
[1]);
99 if (elem
.id
!= div5
.id
|| elem2
.id
!= div5
.id
) {
100 document
.getElementById("result").firstChild
.data
= "FAILURE: With pointer-events:all applied to div5, (" + verticalPoint
+ ") and (" + horizontalPoint
+ ") should be div5 even though it is a descendant of a pointer-events:none element.";
104 document
.getElementById("result").firstChild
.data
= "SUCCESS";