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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/Editor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/editing/pasteboard/pasteboard_with_unfocused_selection.html
diff --git a/third_party/WebKit/LayoutTests/editing/pasteboard/pasteboard_with_unfocused_selection.html b/third_party/WebKit/LayoutTests/editing/pasteboard/pasteboard_with_unfocused_selection.html
new file mode 100644
index 0000000000000000000000000000000000000000..37e41be93b76f08c7414e4c3c1a37cb7edba0f7b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/editing/pasteboard/pasteboard_with_unfocused_selection.html
@@ -0,0 +1,139 @@
+<!doctype html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../assert_selection.js"></script>
+<script>
+test(() => {
+ assert_exists(window, 'testRunner', 'This test requires testRunner');
+
+ assert_selection(
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>'
+ ].join(''),
+ selection => {
+ let cutFired = false;
+ selection.document.body.addEventListener('cut', () => cutFired = true);
+
+ const link = selection.document.querySelector('a');
+ link.focus();
+ testRunner.execCommand('cut'); // Shouldn't cut 'text'
+ assert_equals(selection.document.activeElement, link);
+ assert_true(cutFired, "'cut' should still be dispatched even when cut command is disabled");
+ },
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>'
+ ].join(''));
+}, 'Cutting with unfocused selection in contenteditable div');
+
+test(() => {
+ assert_exists(window, 'testRunner', 'This test requires testRunner');
+
+ assert_selection(
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>',
+ '<div contenteditable id="target"></div>'
+ ].join(''),
+ selection => {
+ selection.setClipboardData('foo');
+
+ let copyFired = false;
+ selection.document.body.addEventListener('copy', () => copyFired = true);
+
+ const link = selection.document.querySelector('a');
+ link.focus();
+ testRunner.execCommand('copy'); // Shouldn't copy 'text'
+ const target = selection.document.getElementById('target');
+ target.focus();
+ testRunner.execCommand('paste');
+ assert_true(copyFired, "'copy' should still be dispatched even when copy command is disabled");
+ },
+ [
+ '<div contenteditable>text</div>',
+ '<a href="http://www.example.com/">link</a>',
+ '<div contenteditable id="target">foo|</div>'
+ ].join(''));
+}, 'Copying with unfocused selection in contenteditable div');
+
+test(() => {
+ assert_exists(window, 'testRunner', 'This test requires testRunner');
+
+ assert_selection(
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>'
+ ].join(''),
+ selection => {
+ selection.setClipboardData('foo');
+
+ let pasteFired = false;
+ selection.document.body.addEventListener('paste', () => pasteFired = true);
+
+ const link = selection.document.querySelector('a');
+ link.focus();
+ testRunner.execCommand('paste'); // Shouldn't paste
+ assert_equals(selection.document.activeElement, link);
+ assert_true(pasteFired, "'paste' should still be dispatched even when paste command is disabled");
+ },
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>'
+ ].join(''));
+}, 'Pasting with unfocused selection in contenteditable div');
+
+test(() => {
+ assert_exists(window, 'testRunner', 'This test requires testRunner');
+
+ assert_selection(
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>'
+ ].join(''),
+ selection => {
+ selection.setClipboardData('foo');
+
+ let pasteFired = false;
+ selection.document.body.addEventListener('paste', () => pasteFired = true);
+
+ const link = selection.document.querySelector('a');
+ link.focus();
+ testRunner.execCommand('pasteAndMatchStyle'); // Shouldn't paste
+ assert_equals(selection.document.activeElement, link);
+ assert_true(pasteFired, "'paste' should still be dispatched even when paste command is disabled");
+ },
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>'
+ ].join(''));
+}, 'Pasting as plain text with unfocused selection in contenteditable div');
+
+test(() => {
+ assert_exists(window, 'testRunner', 'This test requires testRunner');
+ assert_exists(window, 'internals', 'This test requires internal settings');
+ internals.settings.setEditingBehavior('unix');
+
+ assert_selection(
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>'
+ ].join(''),
+ selection => {
+ selection.setClipboardData('foo');
+
+ let pasteFired = false;
+ selection.document.body.addEventListener('paste', () => pasteFired = true);
+
+ const link = selection.document.querySelector('a');
+ link.focus();
+ testRunner.execCommand('pasteGlobalSelection'); // Shouldn't paste
+ assert_equals(selection.document.activeElement, link);
+ assert_true(pasteFired, "'paste' should still be dispatched even when paste command is disabled");
+ },
+ [
+ '<div contenteditable>^text|</div>',
+ '<a href="http://www.example.com/">link</a>'
+ ].join(''));
+}, 'Pasting global selection with unfocused selection in contenteditable div');
+</script>
« 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