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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/inserting/insert-composition-whitespace.html

Issue 2934883004: Rewrite editing/inserting/insert-composition-whitespace.html to utilize assert_selection() (Closed)
Patch Set: 2017-06-14T13:56:20 Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!doctype html>
2 <html> 2 <script src="../../resources/testharness.js"></script>
3 <head> 3 <script src="../../resources/testharnessreport.js"></script>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../assert_selection.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script> 5 <script>
10 6 function assertMarkedText(tagName, compositionText, expected) {
11 var sel = document.getSelection(); 7 assert_selection(
12 var root = document.createElement("root"); 8 `<${tagName} contenteditable id="sample">^X|</${tagName}>`,
13 document.body.appendChild(root); 9 selection => {
14 10 selection.document.execCommand('delete');
15 11 textInputController.setMarkedText(compositionText, 0,
16 function createEditable(tagName, text) { 12 compositionText.length);
17 var node = document.createElement(tagName); 13 const sample = selection.document.getElementById('sample');
18 node.contentEditable = true; 14 assert_equals(sample.firstChild.textContent, expected);
19 node.innerHTML = text; 15 textInputController.unmarkText();
20 return node; 16 },
17 `<${tagName} contenteditable id="sample">^${expected}|</${tagName}>`);
21 } 18 }
22 19
23 function test(tagName, compositionText, expected) { 20 test(() => {
24 var node = createEditable(tagName, "X"); 21 assert_exists(window, 'textInputController',
25 root.appendChild(node); 22 'this test requires window.textInputController.');
26 23
27 var textNode = node.firstChild; 24 assertMarkedText('div', 'AB', 'AB');
28 sel.setBaseAndExtent(textNode, 0, textNode, textNode.data.length); 25 assertMarkedText('div', 'A B', 'A B');
29 document.execCommand("Delete", false); 26 assertMarkedText('div', 'A B', 'A \xA0B');
27 assertMarkedText('div', 'A B', 'A \xA0 B');
28 assertMarkedText('div', 'A B', 'A \xA0 \xA0B');
30 29
31 textInputController.setMarkedText(compositionText, 0, compositionText.length ); 30 assertMarkedText('div', ' AB', '\xA0AB');
32 compositingText = node.innerText; 31 assertMarkedText('div', ' AB', '\xA0 AB');
33 textInputController.unmarkText(); 32 assertMarkedText('div', ' AB', '\xA0 \xA0AB');
34 confirmedText = node.innerText; 33 assertMarkedText('div', ' AB', '\xA0 \xA0 AB');
34 assertMarkedText('div', ' AB', '\xA0 \xA0 \xA0AB');
35 assertMarkedText('div', ' AB', '\xA0 \xA0 \xA0 AB');
36 assertMarkedText('div', ' AB', '\xA0 \xA0 \xA0 \xA0AB');
37 assertMarkedText('div', 'AB ', 'AB \xA0');
38 assertMarkedText('div', 'AB ', 'AB \xA0\xA0');
39 assertMarkedText('div', 'AB ', 'AB \xA0 \xA0');
40 assertMarkedText('div', 'AB ', 'AB \xA0 \xA0\xA0');
41 assertMarkedText('div', 'AB ', 'AB \xA0 \xA0 \xA0');
42 assertMarkedText('div', 'AB ', 'AB \xA0 \xA0 \xA0\xA0');
35 43
36 shouldBe("compositingText", "'" + expected + "'"); 44 assertMarkedText('div', ' A B ', '\xA0 A \xA0B \xA0');
37 shouldBe("confirmedText", "'" + expected + "'"); 45 assertMarkedText('div', '\t\tA\t\tB\t\t', '\xA0 A \xA0B \xA0');
38 }
39 46
40 test("div", "AB", "AB"); 47 assertMarkedText('div', ' ', '\xA0');
41 test("div", "A B", "A B"); 48 assertMarkedText('div', ' ', '\xA0\xA0');
42 test("div", "A B", "A \xA0B"); 49 assertMarkedText('div', ' ', '\xA0 \xA0');
43 test("div", "A B", "A \xA0 B");
44 test("div", "A B", "A \xA0 \xA0B");
45 50
46 test("div", " AB", "\xA0AB"); 51 assertMarkedText('pre', 'AB', 'AB');
47 test("div", " AB", "\xA0 AB"); 52 assertMarkedText('pre', 'A B', 'A B');
48 test("div", " AB", "\xA0 \xA0AB"); 53 assertMarkedText('pre', 'A B', 'A B');
49 test("div", " AB", "\xA0 \xA0 AB"); 54 assertMarkedText('pre', 'A B', 'A B');
50 test("div", " AB", "\xA0 \xA0 \xA0AB"); 55 assertMarkedText('pre', 'A B', 'A B');
51 test("div", " AB", "\xA0 \xA0 \xA0 AB"); 56 assertMarkedText('pre', 'AB ', 'AB ');
52 test("div", " AB", "\xA0 \xA0 \xA0 \xA0AB"); 57 assertMarkedText('pre', 'AB ', 'AB ');
53 test("div", "AB ", "AB \xA0"); 58 assertMarkedText('pre', 'AB ', 'AB ');
54 test("div", "AB ", "AB \xA0\xA0"); 59 assertMarkedText('pre', 'AB ', 'AB ');
55 test("div", "AB ", "AB \xA0 \xA0"); 60 assertMarkedText('pre', 'AB ', 'AB ');
56 test("div", "AB ", "AB \xA0 \xA0\xA0"); 61 assertMarkedText('pre', 'AB ', 'AB ');
57 test("div", "AB ", "AB \xA0 \xA0 \xA0"); 62 assertMarkedText('pre', ' AB', ' AB');
58 test("div", "AB ", "AB \xA0 \xA0 \xA0\xA0"); 63 assertMarkedText('pre', ' AB', ' AB');
64 assertMarkedText('pre', ' AB', ' AB');
65 assertMarkedText('pre', ' AB', ' AB');
66 assertMarkedText('pre', ' AB', ' AB');
67 assertMarkedText('pre', ' AB', ' AB');
59 68
60 test("div", " A B ", "\xA0 A \xA0B \xA0"); 69 assertMarkedText('pre', ' A B ', ' A B ');
61 test("div", "\t\tA\t\tB\t\t", "\xA0 A \xA0B \xA0"); 70 assertMarkedText('pre', '\t\tA\t\tB\t\t', '\t\tA\t\tB\t\t');
62 71 assertMarkedText('pre', ' ', ' ');
63 test("div", " ", "\xA0"); 72 assertMarkedText('pre', ' ', ' ');
64 test("div", " ", "\xA0\xA0"); 73 assertMarkedText('pre', ' ', ' ');
65 test("div", " ", "\xA0 \xA0"); 74 }, 'Insert space and TAB via TextInputController');
66
67 test("pre", "AB", "AB");
68 test("pre", "A B", "A B");
69 test("pre", "A B", "A B");
70 test("pre", "A B", "A B");
71 test("pre", "A B", "A B");
72 test("pre", "AB ", "AB ");
73 test("pre", "AB ", "AB ");
74 test("pre", "AB ", "AB ");
75 test("pre", "AB ", "AB ");
76 test("pre", "AB ", "AB ");
77 test("pre", "AB ", "AB ");
78 test("pre", " AB", " AB");
79 test("pre", " AB", " AB");
80 test("pre", " AB", " AB");
81 test("pre", " AB", " AB");
82 test("pre", " AB", " AB");
83 test("pre", " AB", " AB");
84
85 test("pre", " A B ", " A B ");
86 test("pre", "\t\tA\t\tB\t\t", "\t\tA\t\tB\t\t");
87 test("pre", " ", " ");
88 test("pre", " ", " ");
89 test("pre", " ", " ");
90
91 root.style.display = "none";
92
93 </script> 75 </script>
94 </body> 76 </body>
95 </html> 77 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698