| OLD | NEW |
| 1 <html> | 1 <!doctype html> |
| 2 <head> | 2 <script src="../../resources/testharness.js"></script> |
| 3 | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <style> | 4 <script src="../assert_selection.js"></script> |
| 5 .editing { | 5 <script src="spellcheck_test.js"></script> |
| 6 border: 2px solid red; | |
| 7 padding: 12px; | |
| 8 font-size: 24px; | |
| 9 } | |
| 10 </style> | |
| 11 <script src="../../resources/js-test.js"></script> | |
| 12 <script src=../editing.js language="JavaScript" type="text/JavaScript" ></script
> | |
| 13 | 6 |
| 14 <script> | 7 <script> |
| 15 | 8 spellcheck_test( |
| 16 jsTestIsAsync = true; | 9 '<div contenteditable>Hello,zz a |a</div>', |
| 17 if (window.testRunner) | 10 '', |
| 18 testRunner.setMockSpellCheckerEnabled(true); | 11 '<div contenteditable>Hello,#zz# a a</div>', |
| 19 | 12 { |
| 20 function editingTest() { | 13 title: 'Has marker on initially misspelled word', |
| 21 | 14 callback: sample => spellcheck_test( |
| 22 var elem = document.getElementById("test"); | 15 sample, |
| 23 var selection = window.getSelection(); | 16 'insertLineBreak', |
| 24 selection.collapse(elem, elem.childNodes.length); | 17 '<div contenteditable>Hello,#zz# a <br>a</div>', |
| 25 | 18 'Markers are preserved after adding line break') |
| 26 typeCharacterCommand('z'); | 19 }); |
| 27 typeCharacterCommand('z'); | |
| 28 typeCharacterCommand(' '); | |
| 29 typeCharacterCommand('a'); | |
| 30 typeCharacterCommand(' '); | |
| 31 typeCharacterCommand('a'); | |
| 32 moveSelectionBackwardByWordCommand(); | |
| 33 insertLineBreakCommand(); | |
| 34 | |
| 35 if (window.testRunner) { | |
| 36 selection.collapse(elem, 0); | |
| 37 shouldBecomeEqual("internals.hasSpellingMarker(document, 6, 2)", "true",
function() { | |
| 38 document.getElementById("root").style.display = "none"; | |
| 39 finishJSTest(); | |
| 40 }); | |
| 41 } | |
| 42 | |
| 43 } | |
| 44 | |
| 45 </script> | 20 </script> |
| 46 | |
| 47 <title>Editing Test</title> | |
| 48 </head> | |
| 49 <body> | |
| 50 <script> | |
| 51 description("Misspellings should be preserved when a line-break command " | |
| 52 + "splits a text node. You should see 'Hello,zz a' on the first line below,
" | |
| 53 + "and 'a' on the second line. " | |
| 54 + "This test succeeds when 'zz' (and only 'zz') is marked as misspelled."); | |
| 55 </script> | |
| 56 <div contenteditable id="root" class="editing"> | |
| 57 <!-- we need to lead "Hello," to preserve the marker even after collapse() --> | |
| 58 <span id="test">Hello,</span> | |
| 59 </div> | |
| 60 <script> | |
| 61 editingTest(); | |
| 62 </script> | |
| 63 </body> | |
| 64 </html> | |
| OLD | NEW |