Index: LayoutTests/editing/undo/undo-delete.html |
diff --git a/LayoutTests/editing/undo/undo-delete.html b/LayoutTests/editing/undo/undo-delete.html |
index 1e78d2e28f052bfe5515124070fc28a8aaf376e5..bf1f12a1d6cacc7041c7532fd028affe9973e6c0 100644 |
--- a/LayoutTests/editing/undo/undo-delete.html |
+++ b/LayoutTests/editing/undo/undo-delete.html |
@@ -1,40 +1,44 @@ |
-<html> |
-<head> |
- |
-<style> |
-.editing { |
- border: 2px solid red; |
- padding: 12px; |
- font-size: 24px; |
-} |
-</style> |
-<script src="../editing.js" language="JavaScript" type="text/JavaScript" ></script> |
- |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<p id="description"></p> |
+<div id="test" style="border: 2px solid red;" contenteditable >Test</div> |
+<div id="console"></div> |
+<script src="../../fast/js/resources/js-test-pre.js"></script> |
<script> |
+description('Verifies the selection behavior on undoing a word deletion.'); |
+var startNode = document.getElementById('test').firstChild; |
+var startOffset = startNode.length; |
+var selection = window.getSelection(); |
-function editingTest() { |
- moveSelectionForwardByWordCommand(); |
- moveSelectionForwardByWordCommand(); |
- deleteCommand(); |
- deleteCommand(); |
- deleteCommand(); |
- deleteCommand(); |
- undoCommand(); |
-} |
+function undoTest(platform, selectionType, expectedStartOffset, expectedEndOffset) { |
yosin_UTC9
2013/10/25 08:03:05
nit: If we have |debug(platform)|, it helps debugg
|
+ internals.settings.setEditingBehavior(platform); |
-</script> |
+ var range = document.createRange(); |
yosin_UTC9
2013/10/25 08:03:05
nit: seletion.collapse(startNode, startOffset) is
|
+ range.setStart(startNode, startOffset); |
+ selection.removeAllRanges(); |
+ selection.addRange(range); |
-</head> |
-<body> |
-<div contenteditable id="root" class="editing"> |
-<span id="test">This word should be selected, since the test deleted it a character at a time and then did an undo.</span> |
-</div> |
+ for (var i = 0; i < startOffset; i++) |
+ document.execCommand('delete'); |
+ document.execCommand('undo'); |
-<script> |
-if (window.internals) |
- internals.settings.setEditingBehavior("mac"); |
-runEditingTest(); |
-</script> |
+ shouldBeEqualToString('selection.type', selectionType); |
yosin_UTC9
2013/10/25 08:03:05
Since, selection.type isn't standard. So, we shoul
|
+ shouldBe('selection.baseNode', 'startNode'); |
yosin_UTC9
2013/10/25 08:03:05
Could you use {anchor,focus}{Node,Offste}? They ar
|
+ shouldBe('selection.baseOffset', expectedStartOffset + ''); |
+ shouldBe('selection.extentNode', 'startNode'); |
+ shouldBe('selection.extentOffset', expectedEndOffset + ''); |
+} |
+if (window.internals) { |
+ undoTest('mac', 'Range', 4, 0); |
+ undoTest('win', 'Range', 4, 0); |
+ undoTest('unix', 'Range', 4, 0); |
+ undoTest('android', 'Range', 4, 0); |
+} else { |
+ debug("To test manually, place the cursor at the end of the word 'Test' and delete it completely character by character. Do ctrl+z. On Mac, the word 'Test' should be selected. On other platforms the word 'Test' should not be selected and the cursor should be placed at the end of the word."); |
yosin_UTC9
2013/10/25 08:03:05
nit: Could you put this message in HTML? We can se
|
+} |
+</script> |
+<script src="../../fast/js/resources/js-test-post.js"></script> |
</body> |
</html> |