blob: 8feb994e469288bd79f7ac3b11d80312feb85ae9 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body id="body">
<input id="range1" type="range">
<p id="description"></p>
<div id="console"></div>
<div id="notifications"></div>
<script>
description("This tests that a basic range returns all the correct information for the mac platform.");
var range = 0;
var valueChangeCount = 0;
function notificationCallback(notification) {
if (notification == "AXValueChanged") {
document.getElementById("notifications").innerHTML += "Successfully received " + notification + "<br>";
valueChangeCount++;
}
if (valueChangeCount == 4) {
range.removeNotificationListener();
finishJSTest();
}
}
if (window.accessibilityController) {
jsTestIsAsync = true;
document.getElementById("range1").focus();
range = accessibilityController.focusedElement;
range.addNotificationListener(notificationCallback);
// Check that min/max/value return correct default values.
shouldBe("range.minValue", "0");
shouldBe("range.maxValue", "100");
shouldBe("range.intValue", "50");
// Check the value indicator returns a value.
var valueIndicator = range.childAtIndex(0);
shouldBe("valueIndicator.intValue", "50");
// Check that incrementing/decrementing with keyboard sends AXValueChange.
eventSender.keyDown("leftArrow");
shouldBe("range.intValue", "49");
shouldBe("valueIndicator.intValue", "49");
eventSender.keyDown("rightArrow");
shouldBe("range.intValue", "50");
shouldBe("valueIndicator.intValue", "50");
// Check that incrementing/decrementing with accessibility API sends AXValueChange.
range.increment();
shouldBe("range.intValue", "55");
shouldBe("valueIndicator.intValue", "55");
range.decrement();
shouldBe("range.intValue", "50");
shouldBe("valueIndicator.intValue", "50");
// Check that a hit test on the value indicator succeeds.
var hitTestIndicator = accessibilityController.elementAtPoint(range.x + range.width/2, range.y + range.height/2);
shouldBeTrue("valueIndicator.isEqual(hitTestIndicator)");
// Check that outside the indicator returns the slider.
var hitTestRange = accessibilityController.elementAtPoint(range.x + 1, range.y + range.height/2);
shouldBeTrue("range.isEqual(hitTestRange)");
}
</script>
</body>
</html>