| <!doctype html> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../assert_selection.js"></script> |
| <script> |
| test(() => { |
| assert_not_equals(window.internals, undefined, |
| 'This test requires window.internals to access clipboard'); |
| |
| assert_selection( |
| '<div contenteditable>^b|</div>', |
| selection => { |
| selection.document.execCommand('cut'); |
| selection.document.execCommand('bold'); |
| selection.document.execCommand('insertText', false, 'a'); |
| selection.document.execCommand('pasteAndMatchStyle'); |
| }, |
| '<div contenteditable><b>ab|</b></div>', |
| 'Paste a letter into B'); |
| |
| assert_selection( |
| '<div contenteditable>^abc|</div>', |
| selection => { |
| selection.document.execCommand('cut'); |
| selection.document.execCommand('bold'); |
| selection.document.execCommand('pasteAndMatchStyle'); |
| }, |
| '<div contenteditable><b>abc|</b></div>', |
| 'Paste a word into B'); |
| }, 'Pasting and matching style when there is nothing typed, but the typing style is set to bold.'); |
| </script> |