| OLD | NEW |
| 1 | 1 |
| 2 description('For Bug 40092: Spell checking for pasted text.'); | 2 description('For Bug 40092: Spell checking for pasted text.'); |
| 3 | 3 |
| 4 jsTestIsAsync = true; | 4 jsTestIsAsync = true; |
| 5 | 5 |
| 6 var testRoot = document.createElement("div"); | 6 var testRoot = document.createElement("div"); |
| 7 document.body.insertBefore(testRoot, document.body.firstChild); | 7 document.body.insertBefore(testRoot, document.body.firstChild); |
| 8 | 8 |
| 9 var testTextArea = document.createElement("textarea"); | 9 var testTextArea = document.createElement("textarea"); |
| 10 testRoot.appendChild(testTextArea); | 10 testRoot.appendChild(testTextArea); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 { | 46 { |
| 47 if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement)
{ | 47 if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement)
{ |
| 48 node.focus(); | 48 node.focus(); |
| 49 } else { | 49 } else { |
| 50 sel.selectAllChildren(node); | 50 sel.selectAllChildren(node); |
| 51 } | 51 } |
| 52 | 52 |
| 53 var ok = true; | 53 var ok = true; |
| 54 for (var i = 0; ok && i < expectedMarked.length; ++i) | 54 for (var i = 0; ok && i < expectedMarked.length; ++i) |
| 55 ok = internals.hasSpellingMarker(document, expectedMarked[i][0], expecte
dMarked[i][1]); | 55 ok = internals.hasSpellingMarker(document, expectedMarked[i][0], expecte
dMarked[i][1]); |
| 56 |
| 57 if (ok) { |
| 58 var nodeContent = node instanceof HTMLInputElement || node instanceof HT
MLTextAreaElement ? node.value : node.innerHTML; |
| 59 testPassed(node.tagName + " has a marker on '" + nodeContent + "'"); |
| 60 } |
| 61 |
| 56 return ok; | 62 return ok; |
| 57 } | 63 } |
| 58 | 64 |
| 65 var destination = null; |
| 66 var misspelledLocations = null; |
| 59 function pasteAndVerify(source, dest, expectedMarked) | 67 function pasteAndVerify(source, dest, expectedMarked) |
| 60 { | 68 { |
| 61 sel.selectAllChildren(source); | 69 sel.selectAllChildren(source); |
| 62 document.execCommand("Copy"); | 70 document.execCommand("Copy"); |
| 63 if (dest instanceof HTMLInputElement || dest instanceof HTMLTextAreaElement)
{ | 71 if (dest instanceof HTMLInputElement || dest instanceof HTMLTextAreaElement)
{ |
| 64 dest.value = ""; | 72 dest.value = ""; |
| 65 dest.focus(); | 73 dest.focus(); |
| 66 } else { | 74 } else { |
| 67 dest.innerHTML = ""; | 75 dest.innerHTML = ""; |
| 68 sel.selectAllChildren(dest); | 76 sel.selectAllChildren(dest); |
| 69 } | 77 } |
| 70 document.execCommand("Paste"); | 78 document.execCommand("Paste"); |
| 71 | 79 |
| 72 var nretry = 10; | 80 if (window.internals) { |
| 73 var nsleep = 1; | 81 destination = dest; |
| 74 function trial() { | 82 misspelledLocations = expectedMarked; |
| 75 var verified = verifyMarker(dest, expectedMarked); | 83 shouldBecomeEqual('verifyMarker(destination, misspelledLocations)', 'tru
e', done); |
| 76 if (verified) { | 84 } |
| 77 testPassed(dest.tagName + " has a marker on '" + source.innerHTML +
"'"); | |
| 78 done(); | |
| 79 return; | |
| 80 } | |
| 81 | |
| 82 nretry--; | |
| 83 if (0 == nretry) { | |
| 84 testFailed(dest.tagName + " should have a marker on '" + source.inne
rHTML + "'"); | |
| 85 done(); | |
| 86 return; | |
| 87 } | |
| 88 | |
| 89 nsleep *= 2; | |
| 90 window.setTimeout(trial, nsleep); | |
| 91 }; | |
| 92 trial(); | |
| 93 }; | 85 }; |
| 94 | 86 |
| 95 if (window.internals) | 87 if (window.internals) |
| 96 internals.settings.setAsynchronousSpellCheckingEnabled(true); | 88 internals.settings.setAsynchronousSpellCheckingEnabled(true); |
| 97 | 89 |
| 98 tests.push(function() { pasteAndVerify(testSourcePlain, testInput, [[0, 2]]); })
; | 90 tests.push(function() { pasteAndVerify(testSourcePlain, testInput, [[0, 2]]); })
; |
| 99 tests.push(function() { pasteAndVerify(testSourceDecorated, testInput, [[0, 2]])
; }); | 91 tests.push(function() { pasteAndVerify(testSourceDecorated, testInput, [[0, 2]])
; }); |
| 100 tests.push(function() { pasteAndVerify(testSourceMulti, testInput, [[0, 2], [3,
2]]); }); | 92 tests.push(function() { pasteAndVerify(testSourceMulti, testInput, [[0, 2], [3,
2]]); }); |
| 101 | 93 |
| 102 tests.push(function() { pasteAndVerify(testSourcePlain, testTextArea, [[0, 2]]);
}); | 94 tests.push(function() { pasteAndVerify(testSourcePlain, testTextArea, [[0, 2]]);
}); |
| 103 tests.push(function() { pasteAndVerify(testSourceDecorated, testTextArea, [[0, 2
]]); }); | 95 tests.push(function() { pasteAndVerify(testSourceDecorated, testTextArea, [[0, 2
]]); }); |
| 104 tests.push(function() { pasteAndVerify(testSourceMulti, testTextArea, [[0, 2], [
3, 2]]); }); | 96 tests.push(function() { pasteAndVerify(testSourceMulti, testTextArea, [[0, 2], [
3, 2]]); }); |
| 105 | 97 |
| 106 tests.push(function() { pasteAndVerify(testSourcePlain, testEditable, [[0, 2]]);
}); | 98 tests.push(function() { pasteAndVerify(testSourcePlain, testEditable, [[0, 2]]);
}); |
| 107 tests.push(function() { pasteAndVerify(testSourceDecorated, testEditable, [[0, 1
]]); }); // To check "fo" part of foo. | 99 tests.push(function() { pasteAndVerify(testSourceDecorated, testEditable, [[0, 1
]]); }); // To check "fo" part of foo. |
| 108 tests.push(function() { pasteAndVerify(testSourceMulti, testEditable, [[0, 2], [
3, 2]]); }); | 100 tests.push(function() { pasteAndVerify(testSourceMulti, testEditable, [[0, 2], [
3, 2]]); }); |
| 109 done(); | 101 done(); |
| 110 | 102 |
| 111 var successfullyParsed = true; | 103 var successfullyParsed = true; |
| OLD | NEW |