blob: c870bb970deb528a5b87835bc16ada4b7628ebd4 [file] [log] [blame]
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
</head>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
<body>
<p id="description"></p>
<div id="console"></div>
<input type="radio" name="r1" id="r1" title="TITLE">Test<br>
<label for="r1">LABEL</label>
<input type="radio" id="r2" aria-labeledby="label3">Test<br>
<label for="r2">LABEL2</label>
<div id="label3">LABEL2a</div>
<input type="radio" name="r3" id="r3" aria-label="radio3">Test<br>
<label for="r3">LABEL3</label>
<script>
description("This test checks that radio buttons expose title ui elements correctly under a variety of cirmcumstances. In general, the <label> should disappear and act as the title for the radio button.");
if (window.accessibilityController) {
// radio button 1
document.getElementById("r1").focus();
// 1) Even though a checkbox has a title attribute, the title ui element should still be exposed.
var focusedElement = accessibilityController.focusedElement;
var titleUIElement = focusedElement.titleUIElement();
shouldBe("focusedElement.title", "'AXTitle: LABEL'");
shouldBeTrue("!titleUIElement || titleUIElement.title == 'AXTitle: '");
// 2) aria-labeledby should override the native label semantics and return a title for the radio button, instead of a title ui element.
document.getElementById("r2").focus();
focusedElement = accessibilityController.focusedElement;
titleUIElement = focusedElement.titleUIElement();
shouldBe("focusedElement.description", "'AXDescription: LABEL2a'");
shouldBe("focusedElement.title", "'AXTitle: '");
shouldBeTrue("!titleUIElement || titleUIElement.title == 'AXTitle: '");
// 3) If a radio button has an aria-label and a <label>, the aria-label should be the title.
document.getElementById("r3").focus();
focusedElement = accessibilityController.focusedElement;
titleUIElement = focusedElement.titleUIElement();
shouldBe("focusedElement.description", "'AXDescription: radio3'");
shouldBe("focusedElement.title", "'AXTitle: '");
shouldBe("titleUIElement.title", "'AXTitle: '");
}
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>