203 lines
8.2 KiB
HTML
203 lines
8.2 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8" />
|
|
<title>
|
|
This test is for testing plain text copy paste of paragraph ending with non
|
|
layed out content.
|
|
</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/resources/testdriver.js"></script>
|
|
<script src="/resources/testdriver-vendor.js"></script>
|
|
<script src="/resources/testdriver-actions.js"></script>
|
|
<script src="../include/editor-test-utils.js"></script>
|
|
<div id="copy" contenteditable="true">
|
|
<p>line 1</p>
|
|
<p id="line2">line 2<!-- A comment !--></p>
|
|
<p>line 3</p>
|
|
</div>
|
|
<div id="button-in-inline">
|
|
<span id="contains-button">test<div id="contains-button" style="display: inline-flex"><button> </button></div>;
|
|
</span>
|
|
</div>
|
|
<textarea id="paste"></textarea>
|
|
<script>
|
|
promise_test(async () => {
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("copy");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3");
|
|
}, "The extra line break is missing after the paragraph that ends with a comment.");
|
|
|
|
promise_test(async () => {
|
|
const line2 = document.getElementById("line2");
|
|
line2.innerHTML =
|
|
'line 2<span style="display: none;">hidden content</span>';
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("copy");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.value = "";
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3");
|
|
}, "The extra line break is missing after the paragraph that ends with a display:none span.");
|
|
|
|
promise_test(async () => {
|
|
const line2 = document.getElementById("line2");
|
|
line2.innerHTML = "line 2<span hidden>hidden content</span>";
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("copy");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.value = "";
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3");
|
|
}, "The extra line break is missing after the paragraph that ends with a hidden span.");
|
|
|
|
promise_test(async () => {
|
|
const line2 = document.getElementById("line2");
|
|
line2.innerHTML = 'line 2<meta charset="UTF-8">';
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("copy");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.value = "";
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3");
|
|
}, "The extra line break is missing after the paragraph that ends with a meta tag.");
|
|
|
|
promise_test(async () => {
|
|
const line2 = document.getElementById("line2");
|
|
line2.innerHTML =
|
|
'line 2<style>body{ font-family: Arial, sans-serif; ""}</style>';
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("copy");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.value = "";
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3");
|
|
}, "The extra line break is missing after the paragraph that ends with a style tag.");
|
|
|
|
promise_test(async () => {
|
|
const line2 = document.getElementById("line2");
|
|
line2.innerHTML = 'line 2<base href="http://crbug.com/41350470">';
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("copy");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.value = "";
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "line 1\n\nline 2\n\nline 3");
|
|
}, "The extra line break is missing after the paragraph that ends with a base tag.");
|
|
|
|
promise_test(async () => {
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("button-in-inline");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.value = "";
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "test;");
|
|
}, "Line break should not be present before semicolon after block elements styled as inline-flex.");
|
|
|
|
promise_test(async () => {
|
|
const contains_button = document.getElementById("contains-button");
|
|
contains_button.innerHTML =
|
|
'test<div id="contains-button" style="display: inline-block"><button> </button></div>;';
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("button-in-inline");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.value = "";
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "test;");
|
|
}, "Line break should not be present before semicolon after block elements styled as inline-block.");
|
|
|
|
promise_test(async () => {
|
|
const contains_button = document.getElementById("contains-button");
|
|
contains_button.innerHTML =
|
|
'test<div id="contains-button" style="display: inline-grid"><button> </button></div>;';
|
|
const range = document.createRange();
|
|
const contentToCopy = document.getElementById("button-in-inline");
|
|
range.selectNodeContents(contentToCopy);
|
|
const selection = window.getSelection();
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
// Send copy command
|
|
const utils = new EditorTestUtils(contentToCopy);
|
|
await utils.sendCopyShortcutKey();
|
|
selection.removeAllRanges();
|
|
const textarea = document.getElementById("paste");
|
|
textarea.value = "";
|
|
textarea.focus();
|
|
await utils.sendPasteShortcutKey();
|
|
assert_equals(textarea.value, "test;");
|
|
}, "Line break should not be present before semicolon after block elements styled as inline-grid.");
|
|
</script>
|