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

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-19T15:07:18 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 // To verify test script regression, we verify this test script moves mouse on
31 // |unselectable| element.
32 let didMoveMouseOnUnselectable = false;
33 unselectable.addEventListener('mousemove',
34 () => didMoveMouseOnUnselectable = true);
35
36 function doAction() {
37 return new Promise((resolve, reject) => {
38 if (window.chrome === undefined)
39 return reject('required chrome.gpuBenchmarking');
40 if (window.chrome.gpuBenchmarking === undefined)
41 return reject('required chrome.gpuBenchmarking');
42
43 didMoveMouseOnUnselectable = false;
44
45 // Drag from "3" after "5" in "unselectable".
46 const startX = unselectable.offsetLeft + borderWidth;
47 const dragY = unselectable.offsetTop + unselectable.offsetHeight / 2;
48 chrome.gpuBenchmarking.pointerActionSequence(
49 [{
50 source: 'mouse',
51 actions: [
52 {
53 name: 'pointerDown',
54 button: 'left',
55 x: startX + charWidth * 3,
56 y: dragY,
57 },
58 {
59 name: 'pointerMove',
60 x: startX + charWidth * 6,
61 y: dragY,
62 },
63 {name: 'pointerUp'},
64 ],
65 }], resolve);
66 });
67 }
68
69 promise_test(() => {
70 // Set caret before "7" in "sample1".
71 sample1.focus();
72 sample1.setSelectionRange(7, 7);
73 return doAction().then(() => {
74 assert_true(didMoveMouseOnUnselectable, 'mouse moved on unselectable');
75 assert_equals(document.activeElement, document.body, 'activeElement');
76 assert_equals(sample1.selectionStart, 7, 'selectionStart');
77 assert_equals(sample1.selectionEnd, 7, 'selectionEnd');
78 });
79 }, 'A drag at unselectable should not modify selection in INPUT.');
80
81 promise_test(() => {
82 // Set caret before "7" in "sample2".
83 sample2.focus();
84 selection.collapse(sample2.firstChild, 7);
85 return doAction().then(() => {
86 assert_true(didMoveMouseOnUnselectable, 'mouse moved on unselectable');
87 assert_equals(document.activeElement, document.body, 'activeElement');
88 assert_equals(selection.anchorNode, sample2.firstChild, 'anchorNode');
89 assert_equals(selection.anchorOffset, 7, 'anchorOffset');
90 assert_equals(selection.focusNode, sample2.firstChild, 'focusNode');
91 assert_equals(selection.focusOffset, 7, 'focusOffset');
92 });
93 }, 'A drag at unselectable should not modify selection in contenteditable.');
94 </script>
95 </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