Index: LayoutTests/editing/undo/undo-combined-delete-boundary.html |
diff --git a/LayoutTests/editing/undo/undo-combined-delete-boundary.html b/LayoutTests/editing/undo/undo-combined-delete-boundary.html |
index 1f48f1ef11832bdabe0337538125c681be0239cc..d66c3a24f0f03b2f9987c629cd37e4f2bbe969ce 100644 |
--- a/LayoutTests/editing/undo/undo-combined-delete-boundary.html |
+++ b/LayoutTests/editing/undo/undo-combined-delete-boundary.html |
@@ -1,42 +1,53 @@ |
-<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> |
+<div id="container"> |
+<p id="description"></p> |
+<p>To test manually, place the cursor after 'o' in 'word' and delete it character by character. Do ctrl+z. On Mac, 'word' should be selected. On other platforms 'word' should not be selected and the cursor should be placed after 'o' in 'word'.</p> |
+<div id="test" style="border: 2px solid red;" contenteditable>This wo<b>rd </b>should be selected.</div> |
+</div> |
+<div id="console"></div> |
+<script src="../../fast/js/resources/js-test-pre.js"></script> |
<script> |
+description('Verifies the selection behavior on undoing a text deletion.'); |
+var sampleHTML = 'This wo<b>rd </b>should be selected.'; |
+var selectionNode = document.getElementById('test').firstChild; // Text node 'This wo' |
+var selectionOffset = selectionNode.length; |
+var endNode = document.getElementById('test').childNodes[1].firstChild; // Text node 'rd ' |
+var endOffset = endNode.length - 1; |
+var startOffset = selectionNode.data.indexOf(' ')+1; |
+var selection = window.getSelection(); |
-function editingTest() { |
- moveSelectionForwardByWordCommand(); |
- moveSelectionForwardByCharacterCommand(); |
- moveSelectionForwardByCharacterCommand(); |
- moveSelectionForwardByCharacterCommand(); |
- deleteCommand(); |
- deleteCommand(); |
- forwardDeleteCommand(); |
- forwardDeleteCommand(); |
- undoCommand(); |
-} |
+function $(id) { return document.getElementById(id); } |
-</script> |
+function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndNode, expectedEndOffset, selectedText) { |
+ debug(platform); |
+ internals.settings.setEditingBehavior(platform); |
-</head> |
-<body> |
-<div contenteditable id="root" class="editing"> |
-<span id="test">This wo<b>rd </b>should be selected, since the test deleted it a character at a time and then did an undo.</span> |
-</div> |
+ selection.collapse(selectionNode, selectionOffset); |
+ for (var i = 0; i < 2; i++) |
+ document.execCommand('delete'); |
+ for (var i = 0; i < 2; i++) |
+ document.execCommand('forwarddelete'); |
+ document.execCommand('undo'); |
-<script> |
-if (window.internals) |
- internals.settings.setEditingBehavior("mac"); |
-runEditingTest(); |
-</script> |
+ shouldBeEqualToString('selection.anchorNode.data', expectedStartNode.data); |
+ shouldBe('selection.anchorOffset', expectedStartOffset + ''); |
+ shouldBeEqualToString('selection.focusNode.data', expectedEndNode.data); |
+ shouldBe('selection.focusOffset', expectedEndOffset + ''); |
+ shouldBeEqualToString('selection.toString()', selectedText); |
+ shouldBeEqualToString('$("test").innerHTML', sampleHTML); |
+} |
+if (window.internals) { |
+ undoTest('mac', selectionNode, startOffset, endNode, endOffset, 'word'); |
+ undoTest('win', selectionNode, startOffset, endNode, endOffset, 'word'); |
+ undoTest('unix', selectionNode, startOffset, endNode, endOffset, 'word'); |
+ undoTest('android', selectionNode, startOffset, endNode, endOffset, 'word'); |
+} |
+if (window.testRunner) |
+ document.getElementById('container').outerHTML = ''; |
+</script> |
+<script src="../../fast/js/resources/js-test-post.js"></script> |
</body> |
</html> |