blob: 396ea1d1e5987c0aa2e87135d9a011128bb77168 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<!-- Layout tests use a mock spell checker with only a few words in its dictionary. -->
<div id="editable" contentEditable="true" spellcheck="true"></div>
<p id="paragraph" tabIndex="0" spellcheck="true">Hi, how adaasj sdklj?</p>
<input id="input" spellcheck="true">
<textarea id="textarea" spellcheck="true"></textarea>
<script>
if (window.internals) {
internals.settings.setUnifiedTextCheckerEnabled(true);
internals.setContinuousSpellCheckingEnabled(true);
}
async_test(function(t)
{
document.getElementById('editable').focus();
document.execCommand('InsertText', false, 'Foo baz chello there.');
assert_equals(document.getElementById('editable').childNodes.length, 1);
step_timeout(function()
{
var axEditable = accessibilityController.accessibleElementById('editable');
var axStaticText = axEditable.childAtIndex(0);
assert_equals(axStaticText.misspellingsCount, 3);
assert_equals(axStaticText.misspellingAtIndex(0), 'Foo');
assert_equals(axStaticText.misspellingAtIndex(1), 'baz');
assert_equals(axStaticText.misspellingAtIndex(2), 'chello');
document.getElementById('editable').style.display = "none";;
t.done();
}, 100);
}, 'Misspellings should be reported in content editables.');
async_test(function(t)
{
document.designMode = 'on';
step_timeout(function()
{
var axParagraph = accessibilityController.accessibleElementById('paragraph');
var axStaticText = axParagraph.childAtIndex(0);
assert_equals(axStaticText.misspellingsCount, 2);
assert_equals(axStaticText.misspellingAtIndex(0), 'adaasj');
assert_equals(axStaticText.misspellingAtIndex(1), 'sdklj');
document.designMode = 'off';
document.getElementById('paragraph').style.display = "none";;
t.done();
}, 100);
}, 'Misspellings should be reported in static text when design mode is on.');
async_test(function(t)
{
document.getElementById('input').focus();
document.execCommand('InsertText', false, 'contentEditable ');
step_timeout(function()
{
var axInput = accessibilityController.accessibleElementById('input');
// If input's shadow DOM changes, this logic might need to be modified.
assert_equals(axInput.childrenCount, 1);
var axDiv = axInput.childAtIndex(0);
assert_equals(axDiv.childrenCount, 1);
var axStaticText = axDiv.childAtIndex(0);
assert_equals(axStaticText.misspellingsCount, 1);
assert_equals(axStaticText.misspellingAtIndex(0), 'contentEditable');
document.getElementById('input').style.display = "none";;
t.done();
}, 100);
}, 'Misspellings should be reported in single-line text fields.');
async_test(function(t)
{
document.getElementById('textarea').focus();
document.execCommand('InsertText', false, 'contentEditable ');
step_timeout(function()
{
var axTextarea = accessibilityController.accessibleElementById('textarea');
// If textarea's shadow DOM changes, this logic might need to be modified.
assert_equals(axTextarea.childrenCount, 1);
var axDiv = axTextarea.childAtIndex(0);
assert_equals(axDiv.childrenCount, 1);
var axStaticText = axDiv.childAtIndex(0);
assert_equals(axStaticText.misspellingsCount, 1);
assert_equals(axStaticText.misspellingAtIndex(0), 'contentEditable');
document.getElementById('textarea').style.display = "none";;
t.done();
}, 100);
}, 'Misspellings should be reported in textareas.');
</script>