OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script src="../assert_selection.js"></script> |
| 5 <div contenteditable> |
| 6 <span id="sample" style="color: red;">abfg</span> |
| 7 <div id="sample">cde</div> |
| 8 </div> |
| 9 <script> |
| 10 test(() => { |
| 11 assert_not_equals(window.internals, undefined, |
| 12 'This test requires clipboard access from JavaScript.'); |
| 13 |
| 14 assert_selection( |
| 15 [ |
| 16 '<div contenteditable>', |
| 17 '<span style="color: red;">ab|fg</span>', |
| 18 '</div>', |
| 19 ].join(''), |
| 20 selection => { |
| 21 selection.setClipboardData('CDE'); |
| 22 selection.document.execCommand('paste'); |
| 23 }, |
| 24 [ |
| 25 '<div contenteditable>', |
| 26 '<span style="color: red;">ab</span>', |
| 27 'CDE|', |
| 28 '<span style="color: red;">fg</span>', |
| 29 '</div>', |
| 30 ].join(''), |
| 31 'Paste into middle of colored SPAN'); |
| 32 |
| 33 assert_selection( |
| 34 [ |
| 35 '<div contenteditable>', |
| 36 // TDOO(yosin): Once we stop normalize selection, we should get |
| 37 // rid of "x". Until then, we need to have "x" to place caret. |
| 38 '<div style="margin-left: 40px; text-indent: -40px;">x|</div>', |
| 39 '</div>', |
| 40 ].join(''), |
| 41 selection => { |
| 42 selection.setClipboardData('<span style="margin-left: 40px; text-ind
ent: -40px;">foo</span>'); |
| 43 selection.document.execCommand('paste'); |
| 44 }, |
| 45 [ |
| 46 '<div contenteditable>', |
| 47 '<div style="margin-left: 40px; text-indent: -40px;">xfoo|</div>
', |
| 48 '</div>', |
| 49 ].join(''), |
| 50 'Keep text-indent at pasting'); |
| 51 }); |
| 52 </script> |
OLD | NEW |