updates.html 1.17 KB
Newer Older
1 2
<html>
<head>
3
<script src="../resources/js-test-pre.js"></script>
4 5 6 7 8 9 10 11
</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};
12
    internals.setDeviceProximity('webkitdeviceproximity', firedEvent.value, firedEvent.min, firedEvent.max);
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
}

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>
39
<script src="../resources/js-test-post.js"></script>
40 41
</body>
</html>