| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script src="../editing.js"></script> |
| <style> |
| .editing { |
| border: 2px solid red; |
| padding: 6px; |
| font-size: 18px; |
| } |
| </style> |
| </head> |
| <body> |
| <pre id="description"></pre> |
| <pre id="console"></pre> |
| <div id="container"></div> |
| |
| <script> |
| description("The spellchecker should work correctly if unified spellcheck path is used."); |
| |
| var container = document.getElementById('container'); |
| function removeChildren(node) { |
| while (node.firstChild) |
| node.removeChild(node.firstChild); |
| } |
| |
| if (window.internals) |
| internals.settings.setUnifiedTextCheckerEnabled(true); |
| |
| var testData = [ |
| { text: 'zz', marked: ['zz'] }, |
| { text: 'apple,zz,orange', marked: ['zz'] }, |
| { text: 'zz,zz', marked: ['zz','zz'] }, |
| { text: 'zz zz zz', marked: ['zz', 'zz', 'zz'] }, |
| { text: ' zz zz zz ', marked: ['zz', 'zz', 'zz'] }, |
| { text: 'zz apple orange', marked: ['zz'] }, |
| { text: 'apple zz orange', marked: ['zz'] }, |
| { text: 'apple orange zz', marked: ['zz'] }, |
| { text: 'buzz', marked: [] }, |
| { text: 'I would like to sleep, buzz', marked: [] } |
| ]; |
| |
| var numMarked; |
| var len; |
| var str; |
| var markedStr; |
| function performTest(id, data) { |
| removeChildren(container); |
| var e = document.createElement('div'); |
| e.setAttribute("contentEditable", "true"); |
| e.className = 'editing'; |
| e.id = id; |
| container.appendChild(e); |
| |
| e.focus(); |
| for (var i = 0; i < data.text.length; ++i) { |
| typeCharacterCommand(data.text[i]); |
| } |
| typeCharacterCommand('.'); |
| |
| if (!window.internals) |
| return; |
| |
| var e = document.getElementById(id); |
| numMarked = internals.markerCountForNode(e.firstChild, "spelling"); |
| length = data.marked.length; |
| shouldBe('numMarked', 'length'); |
| |
| for (var i = 0; i < numMarked; ++i) { |
| var range = internals.markerRangeForNode(e.firstChild, "spelling", i); |
| str = range.toString(); |
| markedStr = data.marked[i]; |
| shouldBe('str', 'markedStr'); |
| } |
| } |
| |
| for (var i = 0; i < testData.length; ++i) { |
| performTest('test', testData[i]); |
| } |
| |
| if (window.internals) |
| internals.settings.setUnifiedTextCheckerEnabled(false); |
| |
| var successfullyParsed = true; |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |