blob: d2b84e1f7c424d908af4c6997c6b109139f46ff4 [file] [log] [blame]
<!DOCTYPE html>
<head>
<title>timeranges-nearest</title>
<script src="video-test.js"></script>
<script>
var timeRanges;
function runTest() {
if (!window.internals) {
failTest('This test requires window.internals.');
return;
}
var startTimes = new Float32Array([1, 4]);
var endTimes = new Float32Array([2, 5]);
timeRanges = internals.createTimeRanges(startTimes, endTimes);
testExpected("internals.closestTimeToTimeRanges( .5, timeRanges)", 1);
testExpected("internals.closestTimeToTimeRanges(1.5, timeRanges)", 1.5);
testExpected("internals.closestTimeToTimeRanges(2.1, timeRanges)", 2);
testExpected("internals.closestTimeToTimeRanges(3.0, timeRanges)", 2);
testExpected("internals.closestTimeToTimeRanges(3.9, timeRanges)", 4);
testExpected("internals.closestTimeToTimeRanges(5.5, timeRanges)", 5);
endTest();
}
</script>
</head>
<body onload="runTest()">
<div>This tests the ability of a TimeRanges object to return the time nearest its constituent ranges given a target time.</div>
</body>