Index: third_party/WebKit/LayoutTests/editing/undo/undo-smart-delete-word.html |
diff --git a/third_party/WebKit/LayoutTests/editing/undo/undo-smart-delete-word.html b/third_party/WebKit/LayoutTests/editing/undo/undo-smart-delete-word.html |
index 4f576dc76973b75c1cec2774609919d63843744b..dcaef06c5152ff000eedf20ec75b275527686981 100644 |
--- a/third_party/WebKit/LayoutTests/editing/undo/undo-smart-delete-word.html |
+++ b/third_party/WebKit/LayoutTests/editing/undo/undo-smart-delete-word.html |
@@ -1,13 +1,30 @@ |
-<html> |
-<head> |
-<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script> |
+<!DOCTYPE html> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script><html> |
+<div class="scenario"> |
+Tests: |
+<br> |
+Select a word via double-click. Delete. Then undo the delete. The space that got |
+smart deleted should now be selected. |
+</div> |
+</div> |
+<div contenteditable id="root"> |
+foo <span id="word">bar</span> baz |
+</div> |
+<div id="log"></div> |
<script> |
-if (window.testRunner) |
- testRunner.dumpAsText(); |
- |
-function editingTest() { |
- var word = document.getElementById("word"); |
+test(function() { |
+ if (!window.eventSender || !window.internals) { |
+ assert_unreached('This test requires eventSender and internals.'); |
+ return; |
+ } |
+ // Make double-click to select trailing whitespace too. |
+ internals.settings.setEditingBehavior('win'); |
+ internals.settings.setSelectTrailingWhitespaceEnabled(true); |
+ |
+ // Select "bar " |
+ var word = document.getElementById('word'); |
var x = word.offsetLeft; |
var y = word.offsetTop; |
eventSender.mouseMoveTo(x, y); |
@@ -16,43 +33,13 @@ function editingTest() { |
eventSender.mouseDown(); |
eventSender.mouseUp(); |
- document.execCommand("Delete"); |
- document.execCommand("Undo"); |
- |
- var selection = window.getSelection(); |
- if (selection.anchorNode != document.getElementById("root").firstChild || |
- selection.anchorOffset != 4 || |
- selection.focusNode != word.firstChild || |
- selection.focusOffset != 3) { |
- document.getElementById("result").innerHTML = "FAILED"; |
- console.log(selection.anchorNode); |
- console.log(selection.anchorOffset); |
- console.log(selection.focusNode); |
- console.log(selection.focusOffset); |
- } else |
- document.getElementById("result").innerHTML = "PASSED"; |
-} |
- |
-</script> |
-</head> |
-<body> |
+ document.execCommand('Delete'); |
+ document.execCommand('Undo'); |
-<div class="explanation"> |
-<div class="scenario"> |
-Tests: |
-<br> |
-Select a word via double-click. Delete. Then undo the delete. The space that got smart deleted should now be selected. |
-</div> |
-</div> |
- |
-<div contenteditable id="root"> |
-foo <span id="word">bar</span> baz |
-</div> |
- |
-<div id="result"></div> |
-<script> |
-editingTest(); |
+ var selection = window.getSelection(); |
+ assert_equals(selection.anchorNode, word.firstChild, 'anchorNode'); |
+ assert_equals(selection.anchorOffset, 0, 'anchorOffset'); |
+ assert_equals(selection.focusNode, word.nextSibling, 'focusNode'); |
+ assert_equals(selection.focusOffset, 1, 'focusOffset'); |
+}); |
</script> |
- |
-</body> |
-</html> |