Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/editing/selection/mouse/click-left-of-rtl-wrapping-text.html |
| diff --git a/third_party/WebKit/LayoutTests/editing/selection/mouse/click-left-of-rtl-wrapping-text.html b/third_party/WebKit/LayoutTests/editing/selection/mouse/click-left-of-rtl-wrapping-text.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3be940799be4bdd2fc36cf1e74e239fe616a8e45 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/editing/selection/mouse/click-left-of-rtl-wrapping-text.html |
| @@ -0,0 +1,151 @@ |
| +<!doctype html> |
| +<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<script src="../../assert_selection.js"></script> |
| +<script> |
| +test(() => { |
| + assert_not_equals(window.eventSender, undefined, 'This test requires eventSender.'); |
|
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.
|
| + |
| + function testClickLeft(selection, lines, rowIndexToClick) { |
| + const doc = selection.document; |
| + const container = doc.querySelector('div'); |
| + // Adjust width to have |lines| of lines. |
| + // Since the Ahem font doesn't cover characters used in test, |
| + // we need to calc width depending on each platform. |
| + const heightOfLine = container.offsetHeight; |
| + let width = 5; |
| + do { |
| + 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.
|
| + width++; |
| + } while (container.offsetHeight > heightOfLine * lines); |
| + 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.
|
| + |
| + // Click left of the |rowIndexToClick|th line. |
| + eventSender.mouseMoveTo( |
| + doc.offsetLeft + container.offsetLeft + 3, |
| + doc.offsetTop + container.offsetTop + heightOfLine/2 + rowIndexToClick * heightOfLine); |
| + eventSender.mouseDown(); |
| + eventSender.mouseUp(); |
| + |
| + // Remove width from style to clean result DOM. |
| + container.style.removeProperty('width'); |
| + return heightOfLine; |
| + } |
| + |
| + assert_selection( |
| + '<div contenteditable dir="rtl">ך לכ</div>', |
| + selection => testClickLeft(selection, 2, 0), |
| + '<div contenteditable dir="rtl">ך |לכ</div>'); |
| + |
| + assert_selection( |
| + '<div contenteditable dir="rtl">ך לכ</div>', |
| + selection => testClickLeft(selection, 2, 1), |
| + '<div contenteditable dir="rtl">ך לכ|</div>'); |
| + |
| + assert_selection( |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'ככ ככככ כככ', |
| + '</div>' |
| + ].join(''), |
| + selection => testClickLeft(selection, 3, 0), |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'ככ |ככככ כככ', |
| + '</div>' |
| + ].join('')); |
| + |
| + assert_selection( |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'ככ ככככ כככ', |
| + '</div>' |
| + ].join(''), |
| + selection => testClickLeft(selection, 3, 1), |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'ככ ככככ |כככ', |
| + '</div>' |
| + ].join('')); |
| + |
| + assert_selection( |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'ככ ככככ כככ', |
| + '</div>' |
| + ].join(''), |
| + selection => testClickLeft(selection, 3, 2), |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'ככ ככככ כככ|', |
| + '</div>' |
| + ].join('')); |
| + |
| + assert_selection( |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ יגכ יגכ יגכ', |
| + '</div>' |
| + ].join(''), |
| + selection => testClickLeft(selection, 5, 0), |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ |יגכ יגכ יגכ יגכ', |
| + '</div>' |
| + ].join('')); |
| + |
| + assert_selection( |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ יגכ יגכ יגכ', |
| + '</div>' |
| + ].join(''), |
| + selection => testClickLeft(selection, 5, 1), |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ |יגכ יגכ יגכ', |
| + '</div>' |
| + ].join('')); |
| + |
| + assert_selection( |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ יגכ יגכ יגכ', |
| + '</div>' |
| + ].join(''), |
| + selection => testClickLeft(selection, 5, 2), |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ יגכ |יגכ יגכ', |
| + '</div>' |
| + ].join('')); |
| + |
| + assert_selection( |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ יגכ יגכ יגכ', |
| + '</div>' |
| + ].join(''), |
| + selection => testClickLeft(selection, 5, 3), |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ יגכ יגכ |יגכ', |
| + '</div>' |
| + ].join('')); |
| + |
| + assert_selection( |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ יגכ יגכ יגכ', |
| + '</div>' |
| + ].join(''), |
| + selection => testClickLeft(selection, 5, 4), |
| + [ |
| + '<div contenteditable dir="rtl">', |
| + 'גכ יגכ יגכ יגכ יגכ|', |
| + '</div>' |
| + ].join('')); |
| + |
| +}, 'This tests clicking on the left of RTL text puts the caret at the end of the line'); |
| +</script> |