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

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

Powered by Google App Engine
This is Rietveld 408576698