blob: 9716489a228ab3ebd830af5c8726b7f0c0f4bd67 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body id="body">
<script src="../../resources/js-test-pre.js"></script>
<div id="content">
<div contenteditable="true" id="contenteditable" oninput="updateContenteditable();">current</div>
<input type="text" id="inputElement" value="somevalue" oninput="updateInput();">
<textarea id="textarea" oninput="updateTextarea();">sometext</textarea>
</div>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that setting value to a text control would dispatch input events.");
if (window.accessibilityController) {
jsTestIsAsync = true;
var inputValue;
var contenteditableValue;
var textareaValue;
function updateContenteditable(){
contenteditableValue = accessibilityController.accessibleElementById("contenteditable").stringValue;
if (contenteditableValue.includes("contenteditable")) {
debug("input event dispatched for contenteditable");
debug(contenteditableValue);
testElement("inputElement");
}
}
function updateInput(){
inputValue = accessibilityController.accessibleElementById("inputElement").stringValue;
if (inputValue.includes("inputElement")) {
debug("input event dispatched for inputElement");
debug(inputValue);
testElement("textarea");
}
}
function updateTextarea(){
textareaValue = accessibilityController.accessibleElementById("textarea").stringValue;
if (textareaValue.includes("textarea")) {
debug("input event dispatched for textarea");
debug(textareaValue);
finishJSTest();
}
}
function testElement(idValue) {
debug("\nTest: " + idValue);
var axElement = accessibilityController.accessibleElementById(idValue);
debug("Role: " + axElement.role);
debug("Value: " + axElement.stringValue);
var writable = axElement.isAttributeSettable("AXValue");
debug("Writable: " + writable);
document.getElementById(idValue).focus();
axElement.setValue("Updated value for " + idValue);
}
testElement("contenteditable");
} else {
testFailed("Could not load accessibility controller");
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>