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

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-17T16:41:10 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>
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.
15 <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.
16 <div id="sample2" style="user-select: none">0123456789</div>
17 <span id="sample3">0123456789</span>
18 </body>
19 <script>
20 const sample1 = document.getElementById('sample1');
21 const sample2 = document.getElementById('sample2');
22 const sample3 = document.getElementById('sample3');
23 const selection = window.getSelection();
24
25 const borderWidth = 2;
26 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
27
28 function doAction() {
29 // Set caret before "7" in "sample1".
30 sample1.focus();
31 selection.collapse(sample1.firstChild, 7);
32
33 return new Promise((resolve, reject) => {
34 if (window.chrome === undefined)
35 return reject('required chrome.gpuBenchmarking');
36 if (window.chrome.gpuBenchmarking === undefined)
37 return reject('required chrome.gpuBenchmarking');
38
39 // Drag from "3" after "5" in "sample2".
40 const startX = sample2.offsetLeft + borderWidth;
41 const dragY = sample2.offsetTop + sample2.offsetHeight / 2;
42 chrome.gpuBenchmarking.pointerActionSequence(
43 [{
44 source: 'mouse',
45 actions: [
46 {
47 name: 'pointerDown',
48 button: 'left',
49 x: startX + charWidth * 3,
50 y: dragY,
51 },
52 {
53 name: 'pointerMove',
54 x: startX + charWidth * 6,
55 y: dragY,
56 },
57 {name: 'pointerUp'},
58 ],
59 }], resolve);
60 });
61 }
62
63 promise_test(() => doAction().then(() => {
64 assert_equals(document.activeElement, document.body, 'activeElement');
65 assert_equals(selection.anchorNode, sample1.firstChild, 'anchorNode');
66 assert_equals(selection.anchorOffset, 7, 'anchorOffset');
67 assert_equals(selection.focusNode, sample1.firstChild, 'focusNode');
68 assert_equals(selection.focusOffset, 7, 'focusOffset');
69 }), '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.
70 </script>
71 </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