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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/selection/mouse/click-left-of-rtl-wrapping-text.html

Issue 2525273002: [Editing][CodeHealth] Convert editing/selection to utilize w3c test harness part 1. (Closed)
Patch Set: update 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
OLDNEW
(Empty)
1 <!doctype html>
2 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script src="../../assert_selection.js"></script>
6 <script>
7 test(() => {
8 assert_not_equals(window.eventSender, undefined, 'This test requires eventSend er.');
yosin_UTC9 2017/01/11 05:59:54 It seems following pattern is better than this, it
yoichio 2017/01/11 07:18:57 Done.
9
10 function testClickLeft(selection, lines, rowIndexToClick) {
11 const doc = selection.document;
12 const container = doc.querySelector('div');
13 // Adjust width to have |lines| of lines.
14 // Since the Ahem font doesn't cover characters used in test,
15 // we need to calc width depending on each platform.
16 const heightOfLine = container.offsetHeight;
17 let width = 5;
18 do {
19 container.style.width = width + 'px';
yosin_UTC9 2017/01/11 05:59:54 nit: s/width + 'px'/`${width}px`/
yoichio 2017/01/11 07:18:57 Done.
20 width++;
21 } while (container.offsetHeight > heightOfLine * lines);
22 container.style.width = (width + 1) + 'px';
yosin_UTC9 2017/01/11 05:59:54 s/(width + 1) + 'px'/`${width + 1}px`/
yoichio 2017/01/11 07:18:57 Done.
23
24 // Click left of the |rowIndexToClick|th line.
25 eventSender.mouseMoveTo(
26 doc.offsetLeft + container.offsetLeft + 3,
27 doc.offsetTop + container.offsetTop + heightOfLine/2 + rowIndexToClick * h eightOfLine);
28 eventSender.mouseDown();
29 eventSender.mouseUp();
30
31 // Remove width from style to clean result DOM.
32 container.style.removeProperty('width');
33 return heightOfLine;
34 }
35
36 assert_selection(
37 '<div contenteditable dir="rtl">&#1498; &#1500;&#1499;</div>',
38 selection => testClickLeft(selection, 2, 0),
39 '<div contenteditable dir="rtl">ך |לכ</div>');
40
41 assert_selection(
42 '<div contenteditable dir="rtl">&#1498; &#1500;&#1499;</div>',
43 selection => testClickLeft(selection, 2, 1),
44 '<div contenteditable dir="rtl">ך לכ|</div>');
45
46 assert_selection(
47 [
48 '<div contenteditable dir="rtl">',
49 '&#1499;&#1499; &#1499;&#1499;&#1499;&#1499; &#1499;&#1499;&#1499;',
50 '</div>'
51 ].join(''),
52 selection => testClickLeft(selection, 3, 0),
53 [
54 '<div contenteditable dir="rtl">',
55 'ככ |ככככ כככ',
56 '</div>'
57 ].join(''));
58
59 assert_selection(
60 [
61 '<div contenteditable dir="rtl">',
62 '&#1499;&#1499; &#1499;&#1499;&#1499;&#1499; &#1499;&#1499;&#1499;',
63 '</div>'
64 ].join(''),
65 selection => testClickLeft(selection, 3, 1),
66 [
67 '<div contenteditable dir="rtl">',
68 'ככ ככככ |כככ',
69 '</div>'
70 ].join(''));
71
72 assert_selection(
73 [
74 '<div contenteditable dir="rtl">',
75 '&#1499;&#1499; &#1499;&#1499;&#1499;&#1499; &#1499;&#1499;&#1499;',
76 '</div>'
77 ].join(''),
78 selection => testClickLeft(selection, 3, 2),
79 [
80 '<div contenteditable dir="rtl">',
81 'ככ ככככ כככ|',
82 '</div>'
83 ].join(''));
84
85 assert_selection(
86 [
87 '<div contenteditable dir="rtl">',
88 '&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#149 0;&#1499; &#1497;&#1490;&#1499;',
89 '</div>'
90 ].join(''),
91 selection => testClickLeft(selection, 5, 0),
92 [
93 '<div contenteditable dir="rtl">',
94 'גכ |יגכ יגכ יגכ יגכ',
95 '</div>'
96 ].join(''));
97
98 assert_selection(
99 [
100 '<div contenteditable dir="rtl">',
101 '&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#149 0;&#1499; &#1497;&#1490;&#1499;',
102 '</div>'
103 ].join(''),
104 selection => testClickLeft(selection, 5, 1),
105 [
106 '<div contenteditable dir="rtl">',
107 'גכ יגכ |יגכ יגכ יגכ',
108 '</div>'
109 ].join(''));
110
111 assert_selection(
112 [
113 '<div contenteditable dir="rtl">',
114 '&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#149 0;&#1499; &#1497;&#1490;&#1499;',
115 '</div>'
116 ].join(''),
117 selection => testClickLeft(selection, 5, 2),
118 [
119 '<div contenteditable dir="rtl">',
120 'גכ יגכ יגכ |יגכ יגכ',
121 '</div>'
122 ].join(''));
123
124 assert_selection(
125 [
126 '<div contenteditable dir="rtl">',
127 '&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#149 0;&#1499; &#1497;&#1490;&#1499;',
128 '</div>'
129 ].join(''),
130 selection => testClickLeft(selection, 5, 3),
131 [
132 '<div contenteditable dir="rtl">',
133 'גכ יגכ יגכ יגכ |יגכ',
134 '</div>'
135 ].join(''));
136
137 assert_selection(
138 [
139 '<div contenteditable dir="rtl">',
140 '&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#1490;&#1499; &#1497;&#149 0;&#1499; &#1497;&#1490;&#1499;',
141 '</div>'
142 ].join(''),
143 selection => testClickLeft(selection, 5, 4),
144 [
145 '<div contenteditable dir="rtl">',
146 'גכ יגכ יגכ יגכ יגכ|',
147 '</div>'
148 ].join(''));
149
150 }, 'This tests clicking on the left of RTL text puts the caret at the end of the line');
151 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698