Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: LayoutTests/fast/events/elementsFromPoint-invalid-cases.html

Issue 869813003: Implement elementsFromPoint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix Internals.cpp for touch adjustment Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/events/elementsFromPoint-invalid-cases.html
diff --git a/LayoutTests/fast/events/elementsFromPoint-invalid-cases.html b/LayoutTests/fast/events/elementsFromPoint-invalid-cases.html
new file mode 100644
index 0000000000000000000000000000000000000000..a8b652a3bb458c0bca7fde7eef116cc5ffacc1ae
--- /dev/null
+++ b/LayoutTests/fast/events/elementsFromPoint-invalid-cases.html
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<script src="../../resources/js-test.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>
Rick Byers 2015/02/20 20:02:24 did you intend to use this div somewhere? Seems l
pdr. 2015/02/22 23:28:13 It's used in the last testcase where we try to hit
+<div id="simpleDiv"></div>
+<div id="console"></div>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+// 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);
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698