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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <script src="../../resources/testharness.js"></script>
3 <head> 3 <script src="../../resources/testharnessreport.js"></script>
4 <style type="text/css"> 4 <script src="../assert_selection.js"></script>
5 5
6 #test:first-letter { 6 <script>
7 color: red; 7 const isMac = navigator.platform.indexOf('Mac') !== -1;
8 }
9 8
10 </style> 9 // The current behavior is wrong. The correct expectation should be
11 </head> 10 // 'hello |world' on Windows and 'hello| world' on other platforms.
12 <body> 11 test(() => assert_selection(
13 <p>This tests moving caret around a word with a first-letter rule. WebKit should not crash. 12 [
14 This test also demonstrates a bug that word position is incorrectly reported.</p > 13 '<style>:first-letter{color:red;}</style>',
15 <div id="test" contenteditable> hello world'</div> 14 '<div contenteditable> hel|lo world\'</div>'
16 <pre id="console"></pre> 15 ].join(''),
17 <script> 16 selection => selection.modify('move', 'forward', 'word'),
17 [
18 '<style>:first-letter{color:red;}</style>',
19 isMac ? '<div contenteditable> hello wor|ld\'</div>'
20 : '<div contenteditable> hello world\'|</div>'
21 ].join('')), 'Move forward by word');
18 22
19 if (window.testRunner) 23 test(() => assert_selection(
20 testRunner.dumpAsText(); 24 [
21 if (window.internals) 25 '<style>:first-letter{color:red;}</style>',
22 internals.settings.setEditingBehavior("mac"); 26 '<div contenteditable> hel|lo world\'</div>'
27 ].join(''),
28 selection => selection.modify('move', 'backward', 'word'),
29 [
30 '<style>:first-letter{color:red;}</style>',
31 '<div contenteditable> |hello world\'</div>'
32 ].join('')), 'Move backward by word');
23 33
24 function runTest(actor, expectedOffset) { 34 // The current behavior is wrong. The correct expectation should be
25 window.getSelection().collapse(test.firstChild, 4); 35 // 'hello |world' on Windows and 'hello| world' on other platforms.
26 var action = actor() + ' from offset ' + 4 + ' put caret at offset '; 36 test(() => assert_selection(
27 var startOffset = window.getSelection().getRangeAt(0).startOffset; 37 [
28 action += startOffset; 38 '<style>:first-letter{color:red;}</style>',
29 if (startOffset == expectedOffset) 39 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>'
30 console.innerHTML += 'PASS: ' + action + '\n'; 40 ].join(''),
31 else 41 selection => selection.modify('move', 'forward', 'word'),
32 console.innerHTML += 'FAIL: ' + action + ' but expected ' + expectedOffs et + '\n'; 42 [
33 } 43 '<style>:first-letter{color:red;}</style>',
44 isMac ? '<div contenteditable style="white-space:pre"> hello wor|ld\'</div >'
45 : '<div contenteditable style="white-space:pre"> hello world\'|</div >'
46 ].join('')), 'Move forward by word with white-space:pre');
34 47
35 var test = document.getElementById('test'); 48 test(() => assert_selection(
36 var console = document.getElementById('console'); 49 [
37 50 '<style>:first-letter{color:red;}</style>',
38 console.innerHTML += 'white-space: normal;\n'; 51 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>'
39 runTest(function () {window.getSelection().modify('move', 'forward', 'word'); re turn 'moving forward by word';}, 6); 52 ].join(''),
40 runTest(function () {window.getSelection().modify('move', 'backward', 'word'); r eturn 'moving backward by word';}, 1); 53 selection => selection.modify('move', 'backward', 'word'),
41 54 [
42 console.innerHTML += 'white-space: pre;\n'; 55 '<style>:first-letter{color:red;}</style>',
43 test.style.whiteSpace = 'pre'; 56 '<div contenteditable style="white-space:pre"> |hello world\'</div>'
44 runTest(function () {window.getSelection().modify('move', 'forward', 'word'); re turn 'moving forward by word';}, 6); 57 ].join('')), 'Move backward by word with white-space:pre');
45 runTest(function () {window.getSelection().modify('move', 'backward', 'word'); r eturn 'moving backward by word';}, 1);
46
47 </script> 58 </script>
48 </body>
49 </html>
OLDNEW
« 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