4 <p id=
"description">This tests copying and pasting a p element into another p element doesn't end up in a nested p elements.
</p>
5 <div id=
"editor" style=
"border: 1px solid black;" contenteditable
>
6 <p style=
"font-size: 12px; color: blue;"><span id=
"source">Copy this line
</span></p>
7 <p style=
"font-size: 12px;"><strong>Paste it below in the empty line below. The font size should be
12px and the text should be in blue.
</strong></p>
8 <p style=
"font-size: 12px; color: blue;"><br></p>
10 <script src=
"../../resources/dump-as-markup.js"></script>
13 var source
= document
.getElementById('source');
14 getSelection().collapse(source
, 0);
15 getSelection().modify('extend', 'forward', 'lineboundary');
16 getSelection().modify('extend', 'forward', 'character');
18 function serializeAndParseInnerHTML() {
19 var editor
= document
.getElementById('editor');
20 editor
.innerHTML
= editor
.innerHTML
;
23 if (document
.queryCommandEnabled('copy')) {
24 Markup
.description(document
.getElementById('description').textContent
);
26 document
.execCommand('Copy', false, null);
27 getSelection().collapse(document
.querySelector('br').parentNode
, 0);
28 document
.execCommand('Paste', false, null);
30 Markup
.dump('editor', 'After paste');
32 serializeAndParseInnerHTML();
34 Markup
.dump('editor', 'After innerHTML = innerHTML');
36 document
.onpaste = function () { setTimeout(serializeAndParseInnerHTML
); }