summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webvtt/api/VTTCue/constructor-exceptions.html
blob: 06ad7f041c29c6580438c8920e53069b3054c3a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!doctype html>
<title>VTTCue constructor exceptions</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
test(function() {
    assert_throws_js(TypeError, function() { new VTTCue(NaN, 0, 'foo'); });
    assert_throws_js(TypeError, function() { new VTTCue(Infinity, 0, 'foo'); });
    assert_throws_js(TypeError, function() { new VTTCue('tomorrow', 0, 'foo'); });
}, document.title+', invalid start time');
test(function() {
    assert_throws_js(TypeError, function() { new VTTCue(0, NaN, 'foo'); });
    assert_throws_js(TypeError, function() { new VTTCue(0, -Infinity, 'foo'); });
    assert_throws_js(TypeError, function() { new VTTCue(0, 'tomorrow', 'foo'); });
}, document.title+', invalid end time');
test(function() {
    var start = { valueOf: function() { return 42; } };
    var end = { valueOf: function() { return 84; } };
    var cue = new VTTCue(start, end, 'bar');
    assert_equals(cue.startTime, 42);
    assert_equals(cue.endTime, 84);
    assert_equals(cue.text, 'bar');
}, document.title+', valueOf');
</script>