Commit 35d167b5 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Utilize selection_test() in editing/pasteboard/5478250.html

This patch changes "5478250.html" to utilize |selection_test()| and renames
to "copy_and_paste_with_block_style.html" for ease of maintenance and enabling
EditingNG.

Bug: 679977, 707656
Change-Id: Ie9bf16900f6b31fde0ab98936f144217b8eea0be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2262111
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781749}
parent 087ab38a
<p>This tests that inherited block properties do not propigate to the editing style span.</p>
<div id="copy" contenteditable="true" style="margin: 0 0 0 50px; text-indent: -50px; font-weight: bold; text-align: center;">Some text that is bold.</div>
<div id="paste" contenteditable="true">Some text that is&nbsp;</div>
<script>
var copy = document.getElementById("copy");
window.getSelection().setBaseAndExtent(copy.firstChild, 18, copy, 1);
document.execCommand("Copy");
var paste = document.getElementById("paste");
window.getSelection().setBaseAndExtent(paste, 1, paste, 1);
document.execCommand("Paste");
document.execCommand("InsertText", false, "\nThis text should bold and left justified with \"Some text...\".");
</script>
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// This tests that inherited block properties do not propigate to the editing
// style span.
const kStyle = [
'font-weight: bold;',
'margin: 0 0 0 50px;',
'text-align: center;',
'text-indent: -50px;',
].join('');
const kStyle2 = [
'font-weight: 700;',
'text-align: center;',
'text-indent: -50px;',
].join(' ');
const kSample = [
`<div contenteditable style="${kStyle}>">ab ^XY|</div>`,
'<div contenteditable id="paste">cd</div>',
];
const kSteps = [
{
title: 'Copy and paste text with block inline style',
action: selection => {
selection.document.execCommand('Copy');
const paste = selection.document.getElementById('paste');
selection.collapse(paste, 1);
selection.document.execCommand('Paste');
},
expcted: [
`<div contenteditable style="${kStyle}>">ab XY</div>`,
'<div contenteditable id="paste">',
`cd<span style="${kStyle2}">XY|</span>`,
'</div>',
],
},
{
title: 'Insert text',
action: selection => {
selection.document.execCommand('insertText', false, 'AB');
},
expcted: [
`<div contenteditable style="${kStyle}>">ab XY</div>`,
'<div contenteditable id="paste">',
`cd<span style="${kStyle2}">XYAB|</span>`,
'</div>',
],
},
];
for (let index = 0; index < kSteps.length; ++index) {
selection_test(
kSample,
selection => {
for (const step of kSteps.slice(0, index + 1))
step.action(selection);
},
kSteps[index].expcted,
kSteps[index].title);
}
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment