1 description('Tests if the spellchecker behaves correctly when the spellcheck attribute '
2 + 'is being changed by the script.');
6 if (window
.internals
) {
7 internals
.settings
.setUnifiedTextCheckerEnabled(true);
8 internals
.settings
.setAsynchronousSpellCheckingEnabled(true);
11 var parent
= document
.createElement("div");
12 document
.body
.appendChild(parent
);
13 var sel
= document
.getSelection();
15 function testSpellCheckingEnabled(target
, enabled
)
17 target
.spellcheck
= enabled
;
19 if (target
.tagName
== "SPAN") {
20 target
.appendChild(document
.createTextNode("Hello,"));
21 sel
.setBaseAndExtent(target
, 6, target
, 6);
22 } else if (target
.tagName
== "INPUT" || target
.tagName
== "TEXTAREA") {
24 document
.execCommand("InsertText", false, "Hello,");
27 document
.execCommand("InsertText", false, 'z');
28 document
.execCommand("InsertText", false, 'z');
29 document
.execCommand("InsertText", false, ' ');
31 window
.target
= target
;
32 shouldBe("target.spellcheck", enabled
? "true" : "false");
34 shouldBecomeEqual("internals.hasSpellingMarker(document, 6, 2)", enabled
? "true" : "false", done
);
39 function createElement(tagName
, spellcheck
)
41 var target
= document
.createElement(tagName
);
42 if (tagName
== "SPAN")
43 target
.setAttribute("contentEditable", "true");
45 target
.setAttribute("spellcheck", spellcheck
);
49 function testFor(tagName
, spellCheckAttribueValues
)
51 var target
= createElement(tagName
, spellCheckAttribueValues
.initialValue
);
52 parent
.appendChild(target
);
54 testSpellCheckingEnabled(target
, spellCheckAttribueValues
.destinationValue
);
63 const spellcheckAttributeVariances
= [
64 { initialValue
: undefined, destinationValue
: true },
65 { initialValue
: undefined, destinationValue
: false },
66 { initialValue
: true, destinationValue
: true },
67 { initialValue
: true, destinationValue
: false },
68 { initialValue
: false, destinationValue
: true },
69 { initialValue
: false, destinationValue
: false }
73 var currentElement
= null;
77 if (!currentElement
) {
78 currentElement
= testElements
.shift();
79 // All elements have been already taken.
81 return finishJSTest();
84 if (iterator
!= spellcheckAttributeVariances
.length
)
85 setTimeout(testFor(currentElement
, spellcheckAttributeVariances
[iterator
++]), 0);
88 currentElement
= null;
94 var successfullyParsed
= true;