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

Unified Diff: LayoutTests/editing/undo/undo-combined-delete.html

Issue 43523002: Make tests related to undo word deletion platform independent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: All tests modified 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/editing/undo/undo-combined-delete-boundary.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/editing/undo/undo-combined-delete.html
diff --git a/LayoutTests/editing/undo/undo-combined-delete.html b/LayoutTests/editing/undo/undo-combined-delete.html
index 6123625e10bb92d2c1dac54888439cc05769d9b0..589b2480a3ad61357ab70c433fc20fa5ec49874b 100644
--- a/LayoutTests/editing/undo/undo-combined-delete.html
+++ b/LayoutTests/editing/undo/undo-combined-delete.html
@@ -1,42 +1,48 @@
-<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 completely 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 word 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 selectionNode = document.getElementById('test').firstChild;
+var selectionOffset = selectionNode.data.indexOf('o') + 1;
+var startOffset = selectionNode.data.indexOf(' ') + 1;
+var endOffset = selectionNode.data.indexOf('d') + 1;
+var selection = window.getSelection();
-function editingTest() {
- moveSelectionForwardByWordCommand();
- moveSelectionForwardByCharacterCommand();
- moveSelectionForwardByCharacterCommand();
- moveSelectionForwardByCharacterCommand();
- deleteCommand();
- deleteCommand();
- forwardDeleteCommand();
- forwardDeleteCommand();
- undoCommand();
-}
+function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndNode, expectedEndOffset, selectedText) {
+ debug(platform);
+ internals.settings.setEditingBehavior(platform);
-</script>
+ 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');
-</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>
+ shouldBeEqualToString('selection.anchorNode.data', expectedStartNode.data);
+ shouldBe('selection.anchorOffset', expectedStartOffset + '');
+ shouldBeEqualToString('selection.focusNode.data', expectedEndNode.data);
+ shouldBe('selection.focusOffset', expectedEndOffset + '');
+ shouldBeEqualToString('selection.toString()', selectedText);
+}
-<script>
-if (window.internals)
- internals.settings.setEditingBehavior("mac");
-runEditingTest();
+if (window.internals) {
+ undoTest('mac', selectionNode, startOffset, selectionNode, endOffset, 'word');
+ undoTest('win', selectionNode, startOffset, selectionNode, endOffset, 'word');
+ undoTest('unix', selectionNode, startOffset, selectionNode, endOffset, 'word');
+ undoTest('android', selectionNode, startOffset, selectionNode, endOffset, 'word');
+}
+if (window.testRunner)
+ document.getElementById('container').outerHTML = '';
</script>
-
+<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
« no previous file with comments | « no previous file | LayoutTests/editing/undo/undo-combined-delete-boundary.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698