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

Unified Diff: third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary.html

Issue 2534423003: Convert edtitng/text-iterator/first-letter-word-boundary.html with assert_selection (Closed)
Patch Set: Add platform-dependent test results Created 4 years 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 | third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary.html
diff --git a/third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary.html b/third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary.html
index 9386c9024d7688e3a1df235d01dbbed0ad024184..9a1bc8794398ebd92b33eedddf750b7726306e7d 100644
--- a/third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary.html
+++ b/third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary.html
@@ -1,49 +1,58 @@
<!DOCTYPE html>
-<html>
-<head>
-<style type="text/css">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../assert_selection.js"></script>
-#test:first-letter {
- color: red;
-}
-
-</style>
-</head>
-<body>
-<p>This tests moving caret around a word with a first-letter rule. WebKit should not crash.
-This test also demonstrates a bug that word position is incorrectly reported.</p>
-<div id="test" contenteditable> hello world'</div>
-<pre id="console"></pre>
<script>
-
-if (window.testRunner)
- testRunner.dumpAsText();
-if (window.internals)
- internals.settings.setEditingBehavior("mac");
-
-function runTest(actor, expectedOffset) {
- window.getSelection().collapse(test.firstChild, 4);
- var action = actor() + ' from offset ' + 4 + ' put caret at offset ';
- var startOffset = window.getSelection().getRangeAt(0).startOffset;
- action += startOffset;
- if (startOffset == expectedOffset)
- console.innerHTML += 'PASS: ' + action + '\n';
- else
- console.innerHTML += 'FAIL: ' + action + ' but expected ' + expectedOffset + '\n';
-}
-
-var test = document.getElementById('test');
-var console = document.getElementById('console');
-
-console.innerHTML += 'white-space: normal;\n';
-runTest(function () {window.getSelection().modify('move', 'forward', 'word'); return 'moving forward by word';}, 6);
-runTest(function () {window.getSelection().modify('move', 'backward', 'word'); return 'moving backward by word';}, 1);
-
-console.innerHTML += 'white-space: pre;\n';
-test.style.whiteSpace = 'pre';
-runTest(function () {window.getSelection().modify('move', 'forward', 'word'); return 'moving forward by word';}, 6);
-runTest(function () {window.getSelection().modify('move', 'backward', 'word'); return 'moving backward by word';}, 1);
-
+const isMac = navigator.platform.indexOf('Mac') !== -1;
+
+// The current behavior is wrong. The correct expectation should be
+// 'hello |world' on Windows and 'hello| world' on other platforms.
+test(() => assert_selection(
+ [
+ '<style>:first-letter{color:red;}</style>',
+ '<div contenteditable> hel|lo world\'</div>'
+ ].join(''),
+ selection => selection.modify('move', 'forward', 'word'),
+ [
+ '<style>:first-letter{color:red;}</style>',
+ isMac ? '<div contenteditable> hello wor|ld\'</div>'
+ : '<div contenteditable> hello world\'|</div>'
+ ].join('')), 'Move forward by word');
+
+test(() => assert_selection(
+ [
+ '<style>:first-letter{color:red;}</style>',
+ '<div contenteditable> hel|lo world\'</div>'
+ ].join(''),
+ selection => selection.modify('move', 'backward', 'word'),
+ [
+ '<style>:first-letter{color:red;}</style>',
+ '<div contenteditable> |hello world\'</div>'
+ ].join('')), 'Move backward by word');
+
+// The current behavior is wrong. The correct expectation should be
+// 'hello |world' on Windows and 'hello| world' on other platforms.
+test(() => assert_selection(
+ [
+ '<style>:first-letter{color:red;}</style>',
+ '<div contenteditable style="white-space:pre"> hel|lo world\'</div>'
+ ].join(''),
+ selection => selection.modify('move', 'forward', 'word'),
+ [
+ '<style>:first-letter{color:red;}</style>',
+ isMac ? '<div contenteditable style="white-space:pre"> hello wor|ld\'</div>'
+ : '<div contenteditable style="white-space:pre"> hello world\'|</div>'
+ ].join('')), 'Move forward by word with white-space:pre');
+
+test(() => assert_selection(
+ [
+ '<style>:first-letter{color:red;}</style>',
+ '<div contenteditable style="white-space:pre"> hel|lo world\'</div>'
+ ].join(''),
+ selection => selection.modify('move', 'backward', 'word'),
+ [
+ '<style>:first-letter{color:red;}</style>',
+ '<div contenteditable style="white-space:pre"> |hello world\'</div>'
+ ].join('')), 'Move backward by word with white-space:pre');
</script>
-</body>
-</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698