| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| |
| <div contenteditable="" id="root"> |
| <span id="test">foo bar baz</span> |
| </div> |
| |
| <script> |
| test(() => { |
| assert_not_equals(window.internals, undefined, |
| 'This test requires clipboard access'); |
| |
| const selection = window.getSelection(); |
| const root = document.getElementById('root'); |
| const test = document.getElementById('test'); |
| |
| selection.setBaseAndExtent(test.firstChild, 4, test.firstChild, 7); // foo ^bar| baz |
| document.execCommand('copy'); |
| selection.collapse(test.firstChild, 7); // foo bar| baz |
| document.execCommand('paste'); |
| |
| const expectedText = '\n<span xmlns=\"http://www.w3.org/1999/xhtml\" id=\"test\">foo barbar baz</span>\n'; |
| assert_equals(root.innerHTML, expectedText); |
| assert_equals(selection.anchorNode, test.firstChild); |
| assert_equals(selection.anchorOffset, 10); |
| assert_equals(selection.type, 'Caret'); |
| }, 'Paste in XML'); |
| </script> |
| |
| </html> |