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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/pasteboard/pasteboard_with_unfocused_selection.html

Issue 2894473003: Fix behavior of clipboard commands when there is unfocused selection (Closed)
Patch Set: Fix UnsafeSVGAttributeSanitizationTest 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/Source/core/editing/Editor.h » ('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 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script src="../assert_selection.js"></script>
5 <script>
6 test(() => {
7 assert_exists(window, 'testRunner', 'This test requires testRunner');
8
9 assert_selection(
10 [
11 '<div contenteditable>^text|</div>',
12 '<a href="http://www.example.com/">link</a>'
13 ].join(''),
14 selection => {
15 let cutFired = false;
16 selection.document.body.addEventListener('cut', () => cutFired = true);
17
18 const link = selection.document.querySelector('a');
19 link.focus();
20 testRunner.execCommand('cut'); // Shouldn't cut 'text'
21 assert_equals(selection.document.activeElement, link);
22 assert_true(cutFired, "'cut' should still be dispatched even when cut comman d is disabled");
23 },
24 [
25 '<div contenteditable>^text|</div>',
26 '<a href="http://www.example.com/">link</a>'
27 ].join(''));
28 }, 'Cutting with unfocused selection in contenteditable div');
29
30 test(() => {
31 assert_exists(window, 'testRunner', 'This test requires testRunner');
32
33 assert_selection(
34 [
35 '<div contenteditable>^text|</div>',
36 '<a href="http://www.example.com/">link</a>',
37 '<div contenteditable id="target"></div>'
38 ].join(''),
39 selection => {
40 selection.setClipboardData('foo');
41
42 let copyFired = false;
43 selection.document.body.addEventListener('copy', () => copyFired = true);
44
45 const link = selection.document.querySelector('a');
46 link.focus();
47 testRunner.execCommand('copy'); // Shouldn't copy 'text'
48 const target = selection.document.getElementById('target');
49 target.focus();
50 testRunner.execCommand('paste');
51 assert_true(copyFired, "'copy' should still be dispatched even when copy com mand is disabled");
52 },
53 [
54 '<div contenteditable>text</div>',
55 '<a href="http://www.example.com/">link</a>',
56 '<div contenteditable id="target">foo|</div>'
57 ].join(''));
58 }, 'Copying with unfocused selection in contenteditable div');
59
60 test(() => {
61 assert_exists(window, 'testRunner', 'This test requires testRunner');
62
63 assert_selection(
64 [
65 '<div contenteditable>^text|</div>',
66 '<a href="http://www.example.com/">link</a>'
67 ].join(''),
68 selection => {
69 selection.setClipboardData('foo');
70
71 let pasteFired = false;
72 selection.document.body.addEventListener('paste', () => pasteFired = true);
73
74 const link = selection.document.querySelector('a');
75 link.focus();
76 testRunner.execCommand('paste'); // Shouldn't paste
77 assert_equals(selection.document.activeElement, link);
78 assert_true(pasteFired, "'paste' should still be dispatched even when paste command is disabled");
79 },
80 [
81 '<div contenteditable>^text|</div>',
82 '<a href="http://www.example.com/">link</a>'
83 ].join(''));
84 }, 'Pasting with unfocused selection in contenteditable div');
85
86 test(() => {
87 assert_exists(window, 'testRunner', 'This test requires testRunner');
88
89 assert_selection(
90 [
91 '<div contenteditable>^text|</div>',
92 '<a href="http://www.example.com/">link</a>'
93 ].join(''),
94 selection => {
95 selection.setClipboardData('foo');
96
97 let pasteFired = false;
98 selection.document.body.addEventListener('paste', () => pasteFired = true);
99
100 const link = selection.document.querySelector('a');
101 link.focus();
102 testRunner.execCommand('pasteAndMatchStyle'); // Shouldn't paste
103 assert_equals(selection.document.activeElement, link);
104 assert_true(pasteFired, "'paste' should still be dispatched even when paste command is disabled");
105 },
106 [
107 '<div contenteditable>^text|</div>',
108 '<a href="http://www.example.com/">link</a>'
109 ].join(''));
110 }, 'Pasting as plain text with unfocused selection in contenteditable div');
111
112 test(() => {
113 assert_exists(window, 'testRunner', 'This test requires testRunner');
114 assert_exists(window, 'internals', 'This test requires internal settings');
115 internals.settings.setEditingBehavior('unix');
116
117 assert_selection(
118 [
119 '<div contenteditable>^text|</div>',
120 '<a href="http://www.example.com/">link</a>'
121 ].join(''),
122 selection => {
123 selection.setClipboardData('foo');
124
125 let pasteFired = false;
126 selection.document.body.addEventListener('paste', () => pasteFired = true);
127
128 const link = selection.document.querySelector('a');
129 link.focus();
130 testRunner.execCommand('pasteGlobalSelection'); // Shouldn't paste
131 assert_equals(selection.document.activeElement, link);
132 assert_true(pasteFired, "'paste' should still be dispatched even when paste command is disabled");
133 },
134 [
135 '<div contenteditable>^text|</div>',
136 '<a href="http://www.example.com/">link</a>'
137 ].join(''));
138 }, 'Pasting global selection with unfocused selection in contenteditable div');
139 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Editor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698