blob: 7eff0ac979f4d0de14ac27e5663df32e860c3438 [file] [edit]
<!-- webkit-test-runner [ useFlexibleViewport=true textExtractionEnabled=true AsyncOverflowScrollingEnabled=true ] -->
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/ui-helper.js"></script>
<style>
.tall {
height: 4000px;
}
.scroller {
overflow: scroll;
width: 200px;
height: 200px;
border: 1px solid tomato;
}
</style>
</head>
<body>
<button id="test-button" aria-label="Click Me">Test</button>
<input type="email" placeholder="Enter some text" value="foo" />
<select role="menu">
<option>One</option>
<option selected>Two</option>
<option>Three</option>
</select>
<div contenteditable="plaintext-only">
<h3 aria-label="Heading">Subject</h3>
<p>Hello world.</p>
</div>
<h1 class="click-count">0</h1>
<div class="scroller" aria-label="Child scroller">
<div class="tall">Foo bar</div>
</div>
<div class="tall"></div>
<script>
jsTestIsAsync = true;
addEventListener("load", async () => {
textField = document.querySelector("input");
select = document.querySelector("select");
clickCount = document.querySelector(".click-count");
childScroller = document.querySelector(".scroller");
document.getElementById("test-button").addEventListener("click", () => {
clickCount.textContent = parseInt(clickCount.textContent) + 1;
});
if (!window.testRunner)
return;
const debugText = await UIHelper.requestDebugText({
nodeIdentifierInclusion: "interactive",
includeEventListeners: true,
includeAccessibilityAttributes: true,
});
clickError = await UIHelper.performTextExtractionInteraction("click", {
nodeIdentifier: UIHelper.nodeIdentifierFromDebugText(debugText, "Click Me")
});
textInputError = await UIHelper.performTextExtractionInteraction("textinput", {
nodeIdentifier: UIHelper.nodeIdentifierFromDebugText(debugText, "Enter some text"),
replaceAll: true,
text: "bar"
});
selectMenuItemError = await UIHelper.performTextExtractionInteraction("selectmenuitem", {
nodeIdentifier: UIHelper.nodeIdentifierFromDebugText(debugText, "menu"),
text: "Three"
});
selectTextError = await UIHelper.performTextExtractionInteraction("selecttext", {
nodeIdentifier: UIHelper.nodeIdentifierFromDebugText(debugText, "contentEditable"),
text: "Subject"
});
scrollChildContainerError = await UIHelper.performTextExtractionInteraction("scrollby", {
nodeIdentifier: UIHelper.nodeIdentifierFromDebugText(debugText, "Child scroller"),
scrollDelta: {
x: 0,
y: 100
}
});
scrollPageError = await UIHelper.performTextExtractionInteraction("scrollby", {
scrollDelta: {
x: 0,
y: 100
}
});
invalidActionError = await UIHelper.performTextExtractionInteraction("click", {
nodeIdentifier: "4294967293",
});
shouldBeEqualToString("clickError", "");
shouldBeEqualToString("clickCount.textContent", "1");
shouldBeEqualToString("textInputError", "");
shouldBeEqualToString("textField.value", "bar");
shouldBeEqualToString("selectMenuItemError", "");
shouldBeEqualToString("select.value", "Three");
shouldBeEqualToString("selectTextError", "");
shouldBeEqualToString("getSelection().toString()", "Subject");
shouldBeEqualToString("scrollChildContainerError", "");
shouldBe("childScroller.scrollTop", "100");
shouldBeEqualToString("scrollPageError", "");
shouldBe("document.scrollingElement.scrollTop", "100");
shouldBeEqualToString("invalidActionError", "Failed to resolve nodeIdentifier 4294967293");
finishJSTest();
});
</script>
</body>
</html>