| 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>
|
|
|