Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/editing/input/drag_in_unselectable.html |
| diff --git a/third_party/WebKit/LayoutTests/editing/input/drag_in_unselectable.html b/third_party/WebKit/LayoutTests/editing/input/drag_in_unselectable.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1c81d226cf3b7e690f2ed8e538350ce221393757 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/editing/input/drag_in_unselectable.html |
| @@ -0,0 +1,71 @@ |
| +<!doctype html> |
| +<head> |
| +<style> |
| +* { font-family: monospace; } |
| +div { |
| + border: solid 2px green; |
| + margin: 2px; |
| +} |
| +</style> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +</style> |
| +</head> |
| +<body> |
|
hugoh_UTC2
2017/05/17 08:15:57
Nit: Maybe add a <input> and test that too since t
yosin_UTC9
2017/05/17 09:55:22
Done.
|
| +<div contenteditable id="sample1">0123456789</div> |
|
hugoh_UTC2
2017/05/17 08:15:57
Nit: 2 spaces, <div c...
yosin_UTC9
2017/05/17 09:55:22
Done.
|
| +<div id="sample2" style="user-select: none">0123456789</div> |
| +<span id="sample3">0123456789</span> |
| +</body> |
| +<script> |
| +const sample1 = document.getElementById('sample1'); |
| +const sample2 = document.getElementById('sample2'); |
| +const sample3 = document.getElementById('sample3'); |
| +const selection = window.getSelection(); |
| + |
| +const borderWidth = 2; |
| +const charWidth = sample3.offsetWidth / sample3.firstChild.length; |
|
hugoh_UTC2
2017/05/17 08:15:57
Can be done on sample2? (Is the <span id="sample3"
yosin_UTC9
2017/05/17 09:55:22
No. sample2.offsetWidth is width of page, instead
|
| + |
| +function doAction() { |
| + // Set caret before "7" in "sample1". |
| + sample1.focus(); |
| + selection.collapse(sample1.firstChild, 7); |
| + |
| + return new Promise((resolve, reject) => { |
| + if (window.chrome === undefined) |
| + return reject('required chrome.gpuBenchmarking'); |
| + if (window.chrome.gpuBenchmarking === undefined) |
| + return reject('required chrome.gpuBenchmarking'); |
| + |
| + // Drag from "3" after "5" in "sample2". |
| + const startX = sample2.offsetLeft + borderWidth; |
| + const dragY = sample2.offsetTop + sample2.offsetHeight / 2; |
| + chrome.gpuBenchmarking.pointerActionSequence( |
| + [{ |
| + source: 'mouse', |
| + actions: [ |
| + { |
| + name: 'pointerDown', |
| + button: 'left', |
| + x: startX + charWidth * 3, |
| + y: dragY, |
| + }, |
| + { |
| + name: 'pointerMove', |
| + x: startX + charWidth * 6, |
| + y: dragY, |
| + }, |
| + {name: 'pointerUp'}, |
| + ], |
| + }], resolve); |
| + }); |
| +} |
| + |
| +promise_test(() => doAction().then(() => { |
| + assert_equals(document.activeElement, document.body, 'activeElement'); |
| + assert_equals(selection.anchorNode, sample1.firstChild, 'anchorNode'); |
| + assert_equals(selection.anchorOffset, 7, 'anchorOffset'); |
| + assert_equals(selection.focusNode, sample1.firstChild, 'focusNode'); |
| + assert_equals(selection.focusOffset, 7, 'focusOffset'); |
| +}), 'Drag unselectable below editable'); |
|
hugoh_UTC2
2017/05/17 08:15:57
Nit: "A drag at unselectable should not modify sel
yosin_UTC9
2017/05/17 09:55:22
Done.
|
| +</script> |
| +</body> |