Index: LayoutTests/editing/selection/resources/js-test-selection-shared.js |
diff --git a/LayoutTests/editing/selection/resources/js-test-selection-shared.js b/LayoutTests/editing/selection/resources/js-test-selection-shared.js |
index ed7cbb3ada35e3de45c32662579fee586b9c6b4a..33ca54dbde749a672bcb9d478cfde32b3cbce84a 100644 |
--- a/LayoutTests/editing/selection/resources/js-test-selection-shared.js |
+++ b/LayoutTests/editing/selection/resources/js-test-selection-shared.js |
@@ -1,3 +1,34 @@ |
+function $(id) { return document.getElementById(id); } |
+ |
+var selection= window.getSelection(); |
+ |
+function testCaretMotion(direction, granularity, repeatCount, origin, originOffset, target, targetOffset) { |
+ if (direction == 'both') { |
+ testCaretMotion('forward', granularity, repeatCount, origin, originOffset, target, targetOffset); |
ojan
2013/05/22 02:25:20
Here and elsewhere, Blink style is 4-space indents
yosin_UTC9
2013/05/22 07:54:12
Done.
|
+ testCaretMotion('backward', granularity,repeatCount, target, targetOffset, origin, originOffset); |
+ return; |
+ } |
+ |
+ if (typeof origin == 'string') |
+ origin = $(origin); |
+ |
+ if (typeof target == 'string') |
+ target = $(target); |
+ |
+ if (originOffset < 0) |
+ originOffset = origin.firstChild.length + originOffset + 1; |
+ |
+ if (targetOffset < 0) |
+ targetOffset = target.firstChild.length + targetOffset + 1; |
+ |
+ selection.setPosition(origin.firstChild, originOffset); |
+ debug('Move ' + direction + ' ' + granularity + ' x ' + repeatCount); |
+ for (var i = 0; i < repeatCount; ++i) |
+ selection.modify("move", direction, granularity); |
+ shouldEvaluateTo('selection.anchorNode', target.firstChild); |
+ shouldEvaluateTo('selection.anchorOffset', targetOffset); |
+} |
+ |
function objectAsString(object, properties) { |
var result = "["; |
for (var x = 0; x < properties.length; x++) { |