Index: LayoutTests/fast/dom/elementsFromPoint/elementsFromPoint-invalid-cases.html |
diff --git a/LayoutTests/fast/dom/elementsFromPoint/elementsFromPoint-invalid-cases.html b/LayoutTests/fast/dom/elementsFromPoint/elementsFromPoint-invalid-cases.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..925104ed3319d34be787cd390de6c718fcedb820 |
--- /dev/null |
+++ b/LayoutTests/fast/dom/elementsFromPoint/elementsFromPoint-invalid-cases.html |
@@ -0,0 +1,69 @@ |
+<!DOCTYPE HTML> |
+<script src="../../../resources/js-test.js"></script> |
+<script src="resources/elementsFromPoint.js"></script> |
+<style> |
+html { |
+ overflow-y: scroll; |
+ overflow-x: scroll; |
+} |
+html, body { |
+ margin: 0; |
+ padding: 0; |
+} |
+body { |
+ width: 100%; |
+ height: 100%; |
+} |
+#simpleDiv { |
+ width: 200px; |
+ height: 200px; |
+ background-color: rgba(0,255,0,0.5); |
+} |
+#beyondTopLeft { |
+ position: absolute; |
+ transform: translate3d(-100px, -100px, 10px); |
+ left: 0; |
+ top: 0; |
+ width: 100px; |
+ height: 100px; |
+ background-color: rgba(0,0,0,0.1); |
+} |
+</style> |
+<body> |
+<div id="beyondTopLeft"></div> |
+<div id="simpleDiv"></div> |
+<div id="console"></div> |
+<script> |
+window.jsTestIsAsync = true; |
+ |
+if (window.testRunner) |
+ testRunner.dumpAsText(); |
+ |
+if (window.internals) |
+ internals.settings.setMockScrollbarsEnabled(true); |
+ |
+onload = function() { |
+ // Verify the document root element is the last element returned for empty queries. |
+ shouldBe('document.elementsFromPoint(300, 300)[0]', 'document.body.parentElement'); |
+ |
+ // Verify the document root element is the last element returned for valid queries. |
+ var simpleDiv = document.getElementById('simpleDiv'); |
+ var simpleRect = simpleDiv.getBoundingClientRect(); |
+ var simpleCoords = (simpleRect.right - 1) + ', ' + (simpleRect.bottom - 1); |
+ shouldBe('document.elementsFromPoint(' + simpleCoords + ')[0]', 'simpleDiv'); |
+ shouldBe('document.elementsFromPoint(' + simpleCoords + ')[1]', 'document.body'); |
+ shouldBe('document.elementsFromPoint(' + simpleCoords + ')[2]', 'document.body.parentElement'); |
+ |
+ // Verify an empty sequence is returned for queries outside the viewport. |
+ var bodyRect = document.body.getBoundingClientRect(); |
+ var bodyScrollBar = (bodyRect.right + 1) + ', ' + (bodyRect.top + 1); |
+ shouldBeEqualToNumber('document.elementsFromPoint(' + bodyScrollBar + ').length', 0); |
+ var outsideBodyLeft = (bodyRect.left - 1) + ', ' + (bodyRect.top + 1); |
+ shouldBeEqualToNumber('document.elementsFromPoint(' + outsideBodyLeft + ').length', 0); |
+ var outsideBodyTopLeft = (bodyRect.left - 10) + ', ' + (bodyRect.top - 10); |
+ shouldBeEqualToNumber('document.elementsFromPoint(' + outsideBodyTopLeft + ').length', 0); |
+ |
+ finishJSTest(); |
+} |
+</script> |
+</body> |