summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-data-url.html
blob: 26ff90d56da74eaec639a7a7618807d0dbc6ab55 (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
26
27
28
29
30
<!doctype html>
<title>track element data: URL</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
[null, "anonymous", "use-credentials"].forEach(function(crossOriginValue) {
  async_test(function() {
    var video = document.createElement('video');
    if (crossOriginValue !== null) {
      video.setAttribute('crossorigin', crossOriginValue);
    }
    document.body.appendChild(video);
    var t = document.createElement('track');
    t.onload = this.step_func_done(function() {
      assert_equals(t.track.cues.length, 1);
      assert_equals(t.track.cues[0].startTime, 1);
      assert_equals(t.track.cues[0].endTime, 2);
      assert_equals(t.track.cues[0].id, 'x');
      assert_equals(t.track.cues[0].text, 'test');
    });
    t.onerror = this.step_func(function() {
      assert_unreached('got error event');
    });
    t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\nx\n00:00:01.000 --> 00:00:02.000\ntest\n\n');
    t.track.mode = 'showing';
    video.appendChild(t);
  }, document.title + ' ' + (crossOriginValue ? crossOriginValue : 'No CORS'));
});
</script>