| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 description('Tests if the spellchecker behaves correctly when the spellcheck att
    ribute ' |  | 
| 2     + 'is being changed by the script.'); |  | 
| 3 |  | 
| 4 jsTestIsAsync = true; |  | 
| 5 if (window.testRunner) |  | 
| 6     testRunner.setMockSpellCheckerEnabled(true); |  | 
| 7 |  | 
| 8 var parent = document.createElement("div"); |  | 
| 9 document.body.appendChild(parent); |  | 
| 10 var sel = document.getSelection(); |  | 
| 11 |  | 
| 12 function testSpellCheckingEnabled(target, enabled) |  | 
| 13 { |  | 
| 14     target.spellcheck = enabled; |  | 
| 15 |  | 
| 16     if (target.tagName == "SPAN") { |  | 
| 17         target.appendChild(document.createTextNode("Hello,")); |  | 
| 18         sel.setBaseAndExtent(target, 6, target, 6); |  | 
| 19     } else if (target.tagName == "INPUT" || target.tagName == "TEXTAREA") { |  | 
| 20         target.focus(); |  | 
| 21         document.execCommand("InsertText", false, "Hello,"); |  | 
| 22     } |  | 
| 23 |  | 
| 24     document.execCommand("InsertText", false, 'z'); |  | 
| 25     document.execCommand("InsertText", false, 'z'); |  | 
| 26     document.execCommand("InsertText", false, ' '); |  | 
| 27 |  | 
| 28     window.target = target; |  | 
| 29     shouldBe("target.spellcheck", enabled ? "true" : "false"); |  | 
| 30     if (window.internals) |  | 
| 31         shouldBecomeEqual("internals.hasSpellingMarker(document, 6, 2)", enabled
     ? "true" : "false", done); |  | 
| 32     else |  | 
| 33         done(); |  | 
| 34 } |  | 
| 35 |  | 
| 36 function createElement(tagName, spellcheck) |  | 
| 37 { |  | 
| 38     var target = document.createElement(tagName); |  | 
| 39     if (tagName == "SPAN") |  | 
| 40         target.setAttribute("contentEditable", "true"); |  | 
| 41     if (spellcheck) |  | 
| 42         target.setAttribute("spellcheck", spellcheck); |  | 
| 43     return target; |  | 
| 44 } |  | 
| 45 |  | 
| 46 function testFor(tagName, spellCheckAttribueValues) |  | 
| 47 { |  | 
| 48     var target = createElement(tagName, spellCheckAttribueValues.initialValue); |  | 
| 49     parent.appendChild(target); |  | 
| 50 |  | 
| 51     testSpellCheckingEnabled(target, spellCheckAttribueValues.destinationValue); |  | 
| 52 } |  | 
| 53 |  | 
| 54 var testElements = [ |  | 
| 55     "SPAN", |  | 
| 56     "INPUT", |  | 
| 57     "TEXTAREA" |  | 
| 58 ]; |  | 
| 59 |  | 
| 60 const spellcheckAttributeVariances = [ |  | 
| 61    { initialValue: undefined, destinationValue: true }, |  | 
| 62    { initialValue: undefined, destinationValue: false }, |  | 
| 63    { initialValue: true, destinationValue: true }, |  | 
| 64    { initialValue: true, destinationValue: false }, |  | 
| 65    { initialValue: false, destinationValue: true }, |  | 
| 66    { initialValue: false, destinationValue: false } |  | 
| 67 ]; |  | 
| 68 |  | 
| 69 var iterator = 0; |  | 
| 70 var currentElement = null; |  | 
| 71 |  | 
| 72 function done() |  | 
| 73 { |  | 
| 74     if (!currentElement) { |  | 
| 75         currentElement = testElements.shift(); |  | 
| 76         // All elements have been already taken. |  | 
| 77         if (!currentElement) |  | 
| 78             return finishJSTest(); |  | 
| 79     } |  | 
| 80 |  | 
| 81     if (iterator != spellcheckAttributeVariances.length) |  | 
| 82         setTimeout(testFor(currentElement, spellcheckAttributeVariances[iterator
    ++]), 0); |  | 
| 83     else { |  | 
| 84         iterator = 0; |  | 
| 85         currentElement = null; |  | 
| 86         done(); |  | 
| 87     } |  | 
| 88 } |  | 
| 89 done(); |  | 
| 90 |  | 
| 91 var successfullyParsed = true; |  | 
| OLD | NEW | 
|---|