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

Unified Diff: LayoutTests/fast/regions/resources/helper.js

Issue 25761004: [CSS Regions] Helper functions for selection layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | LayoutTests/fast/regions/selection/selecting-text-in-empty-region.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/regions/resources/helper.js
diff --git a/LayoutTests/fast/regions/resources/helper.js b/LayoutTests/fast/regions/resources/helper.js
index 4c290a8536da33ec0d7fd15f7a855934971bfbbc..6cf7d3f6af3ad0268f60138b0723e3deb42d8857 100644
--- a/LayoutTests/fast/regions/resources/helper.js
+++ b/LayoutTests/fast/regions/resources/helper.js
@@ -202,3 +202,41 @@ function compareArrays(current, expected) {
}
testPassed("Array [" + expected.toString() + "] is equal to [" + current.toString() + "]");
}
+
+function selectContentByRange(fromX, fromY, toX, toY) {
+ if (!window.testRunner)
+ return;
+
+ eventSender.mouseMoveTo(fromX, fromY);
+ eventSender.mouseDown();
+
+ eventSender.mouseMoveTo(toX, toY);
+ eventSender.mouseUp();
+}
+
+function selectContentByIds(fromId, toId) {
+ var fromRect = document.getElementById(fromId).getBoundingClientRect();
+ var toRect = document.getElementById(toId).getBoundingClientRect();
+
+ var fromRectVerticalCenter = fromRect.top + fromRect.height / 2;
+ var toRectVerticalCenter = toRect.top + toRect.height / 2;
+
+ selectContentByRange(fromRect.left, fromRectVerticalCenter, toRect.right, toRectVerticalCenter);
+}
+
+function selectBaseAndExtent(fromId, fromOffset, toId, toOffset) {
+ var from = document.getElementById(fromId);
+ var to = document.getElementById(toId);
+
+ var selection = window.getSelection();
+ selection.setBaseAndExtent(from, fromOffset, to, toOffset);
+}
+
+function mouseClick(positionX, positionY) {
+ if (!window.testRunner)
+ return;
+
+ eventSender.mouseMoveTo(positionX, positionY);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+}
« no previous file with comments | « no previous file | LayoutTests/fast/regions/selection/selecting-text-in-empty-region.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698