chromium/third_party/blink/web_tests/external/wpt/webvtt/parsing/file-parsing/tests/timings-negative.html

<!doctype html>
<!-- DO NOT EDIT! This file and support/timings-negative.vtt are generated. -->
<!-- See /webvtt/parsing/file-parsing/README.md -->
<meta charset=utf-8>
<title>WebVTT parser test: timings, negative</title>
<link rel="help" href="https://w3c.github.io/webvtt/#collect-a-webvtt-timestamp">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var t = async_test('timings, negative');
t.step(function(){
    var video = document.createElement('video');
    var track = document.createElement('track');
    assert_true('src' in track, 'track element not supported');
    track.src = 'support/timings-negative.vtt';
    track['default'] = true;
    track.kind = 'subtitles';
    track.onload = this.step_func(trackLoaded);
    track.onerror = this.step_func(trackError);
    video.appendChild(track);
    document.body.appendChild(video);
});

function trackLoaded(event) {
    var track = event.target;
    var video = track.parentNode;
    var cues = video.textTracks[0].cues;
    {
assert_equals(cues.length, 4);

[
    [0, 0],
    [1, 0.999],
    [60, 59.999],
    [3600, 3599.999],
].forEach(function(pair, index) {
    var startTime = pair[0];
    var endTime = pair[1];

    assert_equals(cues[index].text, 'text' + index, 'Failed with cue ' + index);
    assert_equals(cues[index].startTime, startTime, 'Failed with cue ' + index);
    assert_equals(cues[index].endTime, endTime, 'Failed with cue ' + index);
});

    }
    this.done();
}

function trackError(e) {
    assert_unreached('got unexpected error event');
}
</script>