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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/input/drag_in_unselectable.html

Issue 2891693002: Make mouse drag to ignore unfocused selection (Closed)
Patch Set: 2017-05-17T18:53:32 Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/selection/mouse/drag_user_select_none.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <head>
3 <style>
4 * { font-family: monospace; }
5 div {
6 border: solid 2px green;
7 margin: 2px;
8 }
9 </style>
10 <script src="../../resources/testharness.js"></script>
11 <script src="../../resources/testharnessreport.js"></script>
12 </style>
13 </head>
14 <body>
15 <input id="sample1" value="0123456789">
16 <div id="sample2" contenteditable>0123456789</div>
17 <div id="unselectable" style="user-select: none">0123456789</div>
18 <span id="metricSample">0123456789</span>
19 </body>
20 <script>
21 const sample1 = document.getElementById('sample1');
22 const sample2 = document.getElementById('sample2');
23 const unselectable = document.getElementById('unselectable');
24 const metricSample = document.getElementById('metricSample');
25 const selection = window.getSelection();
26
27 const borderWidth = 2;
28 const charWidth = metricSample.offsetWidth / metricSample.firstChild.length;
29
30 function doAction() {
31 return new Promise((resolve, reject) => {
32 if (window.chrome === undefined)
33 return reject('required chrome.gpuBenchmarking');
34 if (window.chrome.gpuBenchmarking === undefined)
35 return reject('required chrome.gpuBenchmarking');
36
37 // Drag from "3" after "5" in "unselectable".
38 const startX = unselectable.offsetLeft + borderWidth;
39 const dragY = unselectable.offsetTop + unselectable.offsetHeight / 2;
40 chrome.gpuBenchmarking.pointerActionSequence(
Xiaocheng 2017/05/17 18:32:24 lanwei@: This test requires drag-and-drop. Last t
yosin_UTC9 2017/05/18 01:25:12 It seems mouse dragging works for this test. When
yoichio 2017/05/18 01:47:02 Could you confirm dragging by listening mousemove
yosin_UTC9 2017/05/19 06:10:37 Done. Good point! To avoid regression of this tes
41 [{
42 source: 'mouse',
43 actions: [
44 {
45 name: 'pointerDown',
46 button: 'left',
47 x: startX + charWidth * 3,
48 y: dragY,
49 },
50 {
51 name: 'pointerMove',
52 x: startX + charWidth * 6,
53 y: dragY,
54 },
55 {name: 'pointerUp'},
56 ],
57 }], resolve);
58 });
59 }
60
61 promise_test(() => {
62 // Set caret before "7" in "sample1".
63 sample1.focus();
64 sample1.setSelectionRange(7, 7);
yoichio 2017/05/18 01:47:02 Could you define |beforeSelectionStart = sample1.s
yosin_UTC9 2017/05/19 06:10:37 We don't check precondition. We assume all API exc
65 return doAction().then(() => {
66 assert_equals(document.activeElement, document.body, 'activeElement');
67 assert_equals(sample1.selectionStart, 7, 'selectionStart');
68 assert_equals(sample1.selectionEnd, 7, 'selectionEnd');
69 });
70 }, 'A drag at unselectable should not modify selection in INPUT.');
71
72 promise_test(() => {
73 // Set caret before "7" in "sample2".
74 sample2.focus();
75 selection.collapse(sample2.firstChild, 7);
76 return doAction().then(() => {
77 assert_equals(document.activeElement, document.body, 'activeElement');
78 assert_equals(selection.anchorNode, sample2.firstChild, 'anchorNode');
79 assert_equals(selection.anchorOffset, 7, 'anchorOffset');
80 assert_equals(selection.focusNode, sample2.firstChild, 'focusNode');
81 assert_equals(selection.focusOffset, 7, 'focusOffset');
82 });
83 }, 'A drag at unselectable should not modify selection in contenteditable.');
84 </script>
85 </body>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/editing/selection/mouse/drag_user_select_none.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698