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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/pasteboard/smart-paste-008.html

Issue 2695193002: Selection API: setBaseAndExtent() and selectAllChildren() should create new Range based on the spec… (Closed)
Patch Set: rebase Created 3 years, 10 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script> 2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script> 3 <script src="../../resources/testharnessreport.js"></script>
4 <p>There was a bug in paste's smart replace whitespace handling. In some cases, 4 <p>There was a bug in paste's smart replace whitespace handling. In some cases,
5 it used information gathered at the start of the selection being pasted into to 5 it used information gathered at the start of the selection being pasted into to
6 decide whether or not a space needed to be added to the end of the incoming 6 decide whether or not a space needed to be added to the end of the incoming
7 content.</p> 7 content.</p>
8 <p>A smart paste is performed into a selection starting in one block and ending 8 <p>A smart paste is performed into a selection starting in one block and ending
9 in another. Spaces should surround the pasted word.</p> 9 in another. Spaces should surround the pasted word.</p>
10 <div id="sample" contenteditable="true"><div id="foo">foo</div><div id="bar">x b ar</div></div> 10 <div id="sample" contenteditable="true"><div id="foo">foo</div><div id="bar">x b ar</div></div>
11 <div id="log"></div> 11 <div id="log"></div>
12 <script> 12 <script>
13 test(function() { 13 test(function() {
14 var selection = window.getSelection(); 14 var selection = window.getSelection();
15 var sample = document.getElementById('sample'); 15 var sample = document.getElementById('sample');
16 16
17 if (!window.internals && !window.eventSender) 17 if (!window.internals && !window.eventSender)
18 return; 18 return;
19 19
20 internals.settings.setEditingBehavior('win'); 20 internals.settings.setEditingBehavior('win');
21 21
22 selection.setBaseAndExtent(sample, 0, sample, 0); 22 var foo = document.getElementById('foo');
23 selection.selectAllChildren(foo);
23 var rects = window.getSelection().getRangeAt(0).getClientRects(); 24 var rects = window.getSelection().getRangeAt(0).getClientRects();
24 var x = rects[0].left; 25 var x = rects[0].left;
25 var y = rects[0].top; 26 var y = rects[0].top;
26 eventSender.mouseMoveTo(x, y); 27 eventSender.mouseMoveTo(x, y);
27 eventSender.mouseDown(); 28 eventSender.mouseDown();
28 eventSender.mouseUp(); 29 eventSender.mouseUp();
29 eventSender.mouseDown(); 30 eventSender.mouseDown();
30 eventSender.mouseUp(); 31 eventSender.mouseUp();
31 document.execCommand('copy'); 32 document.execCommand('copy');
32 33
33 selection.collapse(document.getElementById('foo').firstChild, 1); 34 selection.collapse(foo.firstChild, 1);
34 selection.extend(document.getElementById('bar').firstChild, 1); 35 selection.extend(document.getElementById('bar').firstChild, 1);
35 document.execCommand('paste'); 36 document.execCommand('paste');
36 37
37 assert_equals(sample.innerHTML, '<div id="foo">f foo bar</div>', 'innerHTML' ); 38 assert_equals(sample.innerHTML, '<div id="foo">f foo bar</div>', 'innerHTML' );
38 assert_true(selection.isCollapsed, 'isCollapsed'); 39 assert_true(selection.isCollapsed, 'isCollapsed');
39 assert_equals(selection.anchorNode, document.getElementById('foo').firstChil d, 'anchorNode'); 40 assert_equals(selection.anchorNode, foo.firstChild, 'anchorNode');
40 assert_equals(selection.anchorOffset, 5, 'anchorOffset'); 41 assert_equals(selection.anchorOffset, 5, 'anchorOffset');
41 }); 42 });
42 </script> 43 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698