| <!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.'); |
| |
| const kImageAndSelect = [ |
| '<img src="../resources/abe.png">', |
| '<select>', |
| '<optgroup>', |
| '<option>1</option><option>2</option><option>3</option>', |
| '</optgroup>', |
| '</select>', |
| ].join(''); |
| |
| assert_selection( |
| [ |
| '<div contenteditable id="target"></div>', |
| `^${kImageAndSelect}|`, |
| ].join(''), |
| selection => { |
| selection.document.execCommand('copy'); |
| selection.collapse(selection.document.getElementById('target'), 0); |
| selection.document.execCommand('paste'); |
| // Note: Chnage IMG/@SRC to relative URL, since copyed HTML has absolute |
| // URL which depends on test environment. |
| selection.document.querySelectorAll('img').forEach(img => { |
| img.src = '../resources/abe.png'; |
| }); |
| }, |
| [ |
| `<div contenteditable id="target">${kImageAndSelect}|</div>`, |
| kImageAndSelect, |
| ].join(''), |
| 'Copy IMG and SELECT'); |
| }); |
| </script> |