blob: 6a96a64ccb828c522ee08033c91e2a7f15da049b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../editing/editing.js"></script>
<script src="value-change/value-change-helpers.js"></script>
</head>
<body id="body">
<div id="content">
<div id="content-editable-div" contenteditable="true" role="textbox"></div>
<input id="text" type="text" value="">
<textarea id="textarea"></textarea>
</div>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that when we are calling the replace with range API to insert or replace text, value change notifications are posted as expected with correct user info data.");
var webArea = 0;
var count = 0;
var resultIndex = -1;
var actualChangeTypes = [];
var actualChangeValues = [];
var actualEditTypes = [];
var expectedValues = [];
function notificationCallback(notification, userInfo) {
if (notification == "AXValueChanged") {
actualChangeTypes[count] = userInfo["AXTextStateChangeType"];
var changes = userInfo["AXTextChangeValues"];
if (changes && changes.length == 1) {
var change = changes[0];
actualChangeValues[count] = change["AXTextChangeValue"];
actualEditTypes[count] = stringForEditType(change["AXTextEditType"])
} else if (changes && changes.length == 2) {
var change1 = changes[0];
var change2 = changes[1];
actualChangeValues[count] = [change1["AXTextChangeValue"], change2["AXTextChangeValue"]];
actualEditTypes[count] = [stringForEditType(change1["AXTextEditType"]), stringForEditType(change2["AXTextEditType"])];
}
count++;
var expectedCount = 6;
if (count == expectedCount) {
shouldBeInsert("Apple");
shouldBeInsertReplace("Apple", "Pie");
shouldBeInsert("Banana");
shouldBeInsertReplace("Banana", "Ice-cream");
shouldBeInsert("Cat");
shouldBeInsertReplace("Cat", "Dog");
webArea.removeNotificationListener();
finishJSTest();
}
}
}
if (window.accessibilityController) {
jsTestIsAsync = true;
accessibilityController.enableEnhancedAccessibility(true);
webArea = accessibilityController.rootElement.childAtIndex(0);
var addedNotification = webArea.addNotificationListener(notificationCallback);
shouldBe("addedNotification", "true");
var axContentEditableDiv = accessibilityController.accessibleElementById("content-editable-div");
var contentEditableDiv = document.getElementById("content-editable-div");
contentEditableDiv.focus();
shouldBeTrue("axContentEditableDiv.replaceTextInRange('Apple', 0, 0)");
shouldBe("axContentEditableDiv.stringValue", "'AXValue: Apple'");
shouldBeTrue("axContentEditableDiv.replaceTextInRange('Pie', 0, 5)");
shouldBe("axContentEditableDiv.stringValue", "'AXValue: Pie'");
contentEditableDiv.blur();
var axText = accessibilityController.accessibleElementById("text");
var text = document.getElementById("text");
text.focus();
shouldBeTrue("axText.replaceTextInRange('Banana', 0, 0)");
shouldBe("axText.stringValue", "'AXValue: Banana'");
shouldBeTrue("axText.replaceTextInRange('Ice-cream', 0, 6)");
shouldBe("axText.stringValue", "'AXValue: Ice-cream'");
text.blur();
var axTextarea = accessibilityController.accessibleElementById("textarea");
var textarea = document.getElementById("textarea");
textarea.focus();
shouldBeTrue("axTextarea.replaceTextInRange('Cat', 0, 0)");
shouldBe("axTextarea.stringValue", "'AXValue: Cat'");
shouldBeTrue("axTextarea.replaceTextInRange('Dog', 0, 3)");
shouldBe("axTextarea.stringValue", "'AXValue: Dog'");
textarea.blur();
document.getElementById("content").style.visibility = "hidden";
}
</script>
</body>
</html>