2 <script src=
"../../../resources/js-test.js"></script>
3 <script src=
"resources/elementsFromPoint.js"></script>
20 background-color: rgba(
0,
255,
0,
0.5);
24 transform: translate3d(-
100px, -
100px,
10px);
29 background-color: rgba(
0,
0,
0,
0.1);
33 <div id=
"beyondTopLeft"></div>
34 <div id=
"simpleDiv"></div>
35 <div id=
"console"></div>
37 window
.jsTestIsAsync
= true;
39 if (window
.testRunner
)
40 testRunner
.dumpAsText();
43 internals
.settings
.setMockScrollbarsEnabled(true);
46 // Verify the document root element is the last element returned for empty queries.
47 shouldBe('document.elementsFromPoint(300, 300)[0]', 'document.body.parentElement');
49 // Verify the document root element is the last element returned for valid queries.
50 var simpleDiv
= document
.getElementById('simpleDiv');
51 var simpleRect
= simpleDiv
.getBoundingClientRect();
52 var simpleCoords
= (simpleRect
.right
- 1) + ', ' + (simpleRect
.bottom
- 1);
53 shouldBe('document.elementsFromPoint(' + simpleCoords
+ ')[0]', 'simpleDiv');
54 shouldBe('document.elementsFromPoint(' + simpleCoords
+ ')[1]', 'document.body');
55 shouldBe('document.elementsFromPoint(' + simpleCoords
+ ')[2]', 'document.body.parentElement');
57 // Verify an empty sequence is returned for queries outside the viewport.
58 var bodyRect
= document
.body
.getBoundingClientRect();
59 var bodyScrollBar
= (bodyRect
.right
+ 1) + ', ' + (bodyRect
.top
+ 1);
60 shouldBeEqualToNumber('document.elementsFromPoint(' + bodyScrollBar
+ ').length', 0);
61 var outsideBodyLeft
= (bodyRect
.left
- 1) + ', ' + (bodyRect
.top
+ 1);
62 shouldBeEqualToNumber('document.elementsFromPoint(' + outsideBodyLeft
+ ').length', 0);
63 var outsideBodyTopLeft
= (bodyRect
.left
- 10) + ', ' + (bodyRect
.top
- 10);
64 shouldBeEqualToNumber('document.elementsFromPoint(' + outsideBodyTopLeft
+ ').length', 0);