| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!doctype html> |
| 2 <html> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <body> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script src="../../resources/dump-as-markup.js"></script> | 4 <script src="../assert_selection.js"></script> |
| 5 <div id="test" contenteditable="true"> | |
| 6 <b>foo</b><a href="http://www.google.com/">bar</a><i>baz</i><br> | |
| 7 <table border="1"><tr><td>foo</td><td>bar</td><td>baz</td></tr></table> | |
| 8 <u>foo</u>bar<span style="text-decoration:line-through">baz</span><br> | |
| 9 </div> | |
| 10 <pre id="console"></pre> | |
| 11 <script> | 5 <script> |
| 6 test(() => assert_selection( |
| 7 '<div contenteditable><a href="http://foo">bar</a></div>', |
| 8 selection => { |
| 9 assert_false(selection.document.execCommand('removeFormat'), |
| 10 'RemoveFormat enabled with no selection'); |
| 11 }, |
| 12 '<div contenteditable><a href="http://foo">bar</a></div>'), |
| 13 'RemoveFormat command with no selection'); |
| 12 | 14 |
| 13 if (window.testRunner) | 15 test(() => assert_selection( |
| 14 testRunner.dumpEditingCallbacks(); | 16 '<div contenteditable><b>|abc</b></div>', |
| 17 selection => { |
| 18 assert_false(selection.document.execCommand('removeFormat'), |
| 19 'RemoveFormat enabled with no selection'); |
| 20 }, |
| 21 '<div contenteditable><b>|abc</b></div>'), |
| 22 'RemoveFormat command with caret'); |
| 15 | 23 |
| 16 function log(message) { | 24 test(() => assert_selection( |
| 17 var console = document.getElementById("console"); | 25 [ |
| 18 console.innerHTML += message + '\n'; | 26 '<div contenteditable>', |
| 19 } | 27 '<b>^abc</b>', |
| 20 | 28 '<a href="#foo">def</a>', |
| 21 var e = document.getElementById("test"); | 29 '<i>ghi</i><br>', |
| 22 var s = window.getSelection(); | 30 '<table><tbody><tr><td>one</td><td>two</td></tr></tbody></table>', |
| 23 | 31 '<u>jkl</u>', |
| 24 if (document.queryCommandEnabled("RemoveFormat")) | 32 'mno', |
| 25 log("Failure: RemoveFormat enabled with no selection."); | 33 '<span style="text-decoration:line-through">baz|</span><br>', |
| 26 s.collapse(e, 0); | 34 '</div>', |
| 27 if (document.queryCommandEnabled("RemoveFormat")) | 35 ].join(''), |
| 28 log("Failure: RemoveFormat enabled with a caret selection."); | 36 'removeFormat', |
| 29 document.execCommand("SelectAll"); | 37 [ |
| 30 if (!document.queryCommandEnabled("RemoveFormat")) | 38 '<div contenteditable>', |
| 31 log("Failure: RemoveFormat disabled with an editable selection."); | 39 '^abc', |
| 32 if (!document.execCommand("RemoveFormat")) | 40 '<a href="#foo">def</a>', |
| 33 log("Failure: execCommand('RemoveFormat') returned false."); | 41 'ghi<br>', |
| 34 | 42 '<table><tbody><tr><td>one</td><td>two</td></tr></tbody></table>', |
| 35 Markup.description('This is a test for execCommand("RemoveFormat"). It demonstra
tes a bug: everything in the editable region below should be selected, as everyt
hing was selected before Remove Format was performed.'); | 43 'jkl', |
| 36 Markup.dump(e, 'markup'); | 44 'mno', |
| 37 Markup.dump('console', 'console'); | 45 'baz|<br>', |
| 38 | 46 '</div>', |
| 47 ].join('')), |
| 48 'RemoveFormat command with range selection'); |
| 39 </script> | 49 </script> |
| 40 </body> | |
| 41 </html> | |
| OLD | NEW |