summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackList/onaddtrack.html
blob: 114ca890467b8a23b8aee252aa4e560b5c462333 (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
31
32
33
<!doctype html>
<title>TextTrackList.onaddtrack</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
    window.tracks = document.createElement('video').textTracks;
    window.ev = new Event('addtrack');
    window.ran = false;
    window.cb = function() { ran = true; };
});
test(function(){
    assert_equals(tracks.onaddtrack, null);
    tracks.onaddtrack = cb;
    assert_equals(tracks.onaddtrack, cb);
    tracks.dispatchEvent(ev);
    assert_true(ran);
    tracks.onaddtrack = null;
    ran = false;
    tracks.dispatchEvent(ev);
    assert_false(ran);
});
test(function(){
    tracks.addEventListener('addtrack', cb, false);
    tracks.dispatchEvent(ev);
    assert_true(ran);
    tracks.removeEventListener('addtrack', cb, false);
    ran = false;
    tracks.dispatchEvent(ev);
    assert_false(ran);
}, 'TextTrackList.addEventListener/removeEventListener');
</script>