Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/editing/selection/drag_with_unfocused_selection.html |
| diff --git a/third_party/WebKit/LayoutTests/editing/selection/drag_with_unfocused_selection.html b/third_party/WebKit/LayoutTests/editing/selection/drag_with_unfocused_selection.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fca54a16b51271795efb979319b9dc5534d40e47 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/editing/selection/drag_with_unfocused_selection.html |
| @@ -0,0 +1,98 @@ |
| +<!doctype html> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="../assert_selection.js"></script> |
| +<script> |
| +// Regression tests for crbug.com/717453. |
| + |
| +function mouseMoveTo(element) { |
| + const document = element.ownerDocument; |
| + const mouseX = document.offsetLeft + element.offsetLeft + element.offsetWidth / 2; |
| + const mouseY = document.offsetTop + element.offsetTop + element.offsetHeight / 2; |
| + eventSender.mouseMoveTo(mouseX, mouseY); |
| +} |
| + |
| +test(() => { |
| + assert_not_equals(window.eventSender, 'This test requires eventSender'); |
|
yosin_UTC9
2017/05/12 04:05:44
Let's use |assert_exists(window, 'eventSender');|
|
| + |
| + assert_selection( |
| + [ |
| + '<textarea id="source">^text|</textarea>', |
| + '<a href="http://www.example.com/" id="link">link</a>', |
| + '<textarea id="target"></textarea>' |
| + ].join(''), |
| + selection => { |
| + const document = selection.document; |
| + const source = document.getElementById('source'); |
| + const link = document.getElementById('link'); |
| + const target = document.getElementById('target'); |
| + source.focus(); |
| + mouseMoveTo(link); |
| + eventSender.mouseDown(); |
| + eventSender.leapForward(500); |
| + mouseMoveTo(target); |
| + eventSender.mouseUp(); |
| + }, |
| + [ |
| + '<textarea id="source">text</textarea>', |
| + '<a href="http://www.example.com/" id="link">link</a>', |
| + '<textarea id="target">^http://www.example.com/|</textarea>' |
| + ].join('')); |
| +}, 'Drag link with unfocused selection in text control'); |
| + |
| +test(() => { |
| + assert_not_equals(window.eventSender, 'This test requires eventSender'); |
| + |
| + assert_selection( |
| + [ |
|
yosin_UTC9
2017/05/12 04:05:45
nit: Please have two spaces indentation.
|
| + '<div contenteditable id="source">^text|</div>', |
| + '<a href="http://www.example.com/" id="link">link</a>', |
| + '<textarea id="target"></textarea>' |
| + ].join(''), |
| + selection => { |
| + const document = selection.document; |
| + const source = document.getElementById('source'); |
| + const link = document.getElementById('link'); |
| + const target = document.getElementById('target'); |
| + source.focus(); |
| + mouseMoveTo(link); |
| + eventSender.mouseDown(); |
| + eventSender.leapForward(500); |
| + mouseMoveTo(target); |
| + eventSender.mouseUp(); |
| + }, |
| + [ |
| + '<div contenteditable id="source">text</div>', |
| + '<a href="http://www.example.com/" id="link">link</a>', |
| + '<textarea id="target">^http://www.example.com/|</textarea>' |
| + ].join('')); |
| +}, 'Drag link with unfocused selection in contenteditable div'); |
| + |
| +test(() => { |
| + assert_not_equals(window.eventSender, 'This test requires eventSender'); |
|
yosin_UTC9
2017/05/12 04:05:44
Let's use |assert_exists(window, 'eventSender');|
|
| + |
| + assert_selection( |
| + [ |
|
yosin_UTC9
2017/05/12 04:05:45
nit: Please have two spaces indentation.
|
| + '<div id="source">^text|</div>', |
| + '<a href="http://www.example.com/" id="link">link</a>', |
| + '<textarea id="target"></textarea>' |
| + ].join(''), |
| + selection => { |
| + const document = selection.document; |
| + const source = document.getElementById('source'); |
| + const link = document.getElementById('link'); |
| + const target = document.getElementById('target'); |
| + document.body.focus(); |
| + mouseMoveTo(link); |
| + eventSender.mouseDown(); |
| + eventSender.leapForward(500); |
| + mouseMoveTo(target); |
| + eventSender.mouseUp(); |
| + }, |
| + [ |
| + '<div id="source">text</div>', |
| + '<a href="http://www.example.com/" id="link">link</a>', |
| + '<textarea id="target">^http://www.example.com/|</textarea>' |
| + ].join('')); |
| +}, 'Drag link with unfocused selection in uneditable text'); |
| +</script> |