blob: f17724410a6b7037d07759b88791a742f10e6065 [file] [edit]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/accessibility-helper.js"></script>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<div id="test-content">
<p contenteditable="true" id="text">THE QUICK <span id="target1">BROWN FO</span>X JUMPS OV<span id="target2">ER THE LA</span>ZY DOG.</p>
<p contenteditable="true" id="text2">TEXT2: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.</p>
<p contenteditable="true" id="text3">TEXT3: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.</p>
</div>
<script>
var output = "Tests that a Lowercase text operation transforms text to lowercase as expected.\n\n";
if (window.accessibilityController) {
window.jsTestIsAsync = true;
var text, operationResult;
setTimeout(async function() {
// Validate that text is transformed to lowercase as expected (without smart replacement).
text = accessibilityController.accessibleElementById("text");
var markers = [await selectElementTextById("target1")];
await waitForNotification(text, "AXValueChanged", () => {
operationResult = text.performTextOperation("Lowercase", markers, null, /* smart replace */ false);
});
output += expect("operationResult.length", "1");
output += expect("operationResult[0]", "'brown fo'");
output += expect("text.stringValue.replace(/\\s/g, ' ')", "'AXValue: THE QUICK brown foX JUMPS OVER THE LAZY DOG.'");
// Validate that text is transformed to lowercase as expected (with smart replacement).
markers = [await selectElementTextById("target2")];
await waitForNotification(text, "AXValueChanged", () => {
operationResult = text.performTextOperation("Lowercase", markers, null, /* smart replace */ true);
});
output += expect("operationResult.length", "1");
output += expect("operationResult[0]", "'er the la'");
output += expect("text.stringValue.replace(/\\s/g, ' ')", "'AXValue: THE QUICK brown foX JUMPS OV er the la ZY DOG.'");
// Validate that multiple ranges of text are transformed to lowercase as expected (without smart replacement).
text = accessibilityController.accessibleElementById("text2");
markers = [await selectPartialElementTextById("text2", 42, 46), await selectPartialElementTextById("text2", 30, 37), await selectPartialElementTextById("text2", 9, 20)];
await waitForNotification(text, "AXValueChanged", () => {
operationResult = text.performTextOperation("Lowercase", markers, null, /* smart replace */ false);
});
output += expect("operationResult.length", "3");
output += expect("operationResult[0]", "'lazy'");
output += expect("operationResult[1]", "'ps over'");
output += expect("operationResult[2]", "'e quick bro'");
output += expect("text.stringValue.replace(/\\s/g, ' ')", "'AXValue: TEXT2: THe quick broWN FOX JUMps over THE lazy DOG.'");
// Validate that multiple ranges of text are transformed to lowercase as expected (with smart replacement).
// The following test is EXPECTED TO FAIL. See https://bugs.webkit.org/show_bug.cgi?id=278928
text = accessibilityController.accessibleElementById("text3");
markers = [await selectPartialElementTextById("text3", 42, 46), await selectPartialElementTextById("text3", 30, 37), await selectPartialElementTextById("text3", 9, 20)];
await waitForNotification(text, "AXValueChanged", () => {
operationResult = text.performTextOperation("Lowercase", markers, null, /* smart replace */ true);
});
output += expect("operationResult.length", "3");
output += expect("operationResult[0]", "'lazy'");
output += expect("operationResult[1]", "'ps over'");
output += expect("operationResult[2]", "'e quick bro'");
output += expect("text.stringValue.replace(/\\s/g, ' ')", "'AXValue: TEXT3: TH e quick bro WN FOX JUM ps over THE lazy DOG.'");
document.getElementById("test-content").remove();
debug(output);
finishJSTest();
}, 0);
}
</script>
</body>
</html>