blob: dd712cfa25f24515a222aff53b832df5363583e4 [file] [log] [blame]
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description('Tests that updates to the proximity causes new events to fire.');
var firedEvent;
function setProximity(value, min, max) {
firedEvent = {value: value, min: min, max: max};
internals.setDeviceProximity('webkitdeviceproximity', firedEvent.value, firedEvent.min, firedEvent.max);
}
var deviceProximityEvent;
function checkProximity(event) {
deviceProximityEvent = event;
shouldBe('deviceProximityEvent.value', 'firedEvent.value');
shouldBe('deviceProximityEvent.min', 'firedEvent.min');
shouldBe('deviceProximityEvent.max', 'firedEvent.max');
}
function firstListener(event) {
checkProximity(event);
window.removeEventListener('webkitdeviceproximity', firstListener);
window.addEventListener('webkitdeviceproximity', updateListener);
setProximity(22.2, 11.1, 33.3);
}
function updateListener(event) {
checkProximity(event);
finishJSTest();
}
window.addEventListener('webkitdeviceproximity', firstListener);
setProximity(2.2, 1.1, 3.3);
window.jsTestIsAsync = true;
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>