summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onexit.html
blob: 815377e4d1aeac1274b7c005fc35425e454c2d18 (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
34
35
36
<!doctype html>
<title>TextTrackCue.onexit</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
    window.c1 = new VTTCue(0, 1, 'text1');
    window.ev = new Event('exit');
    window.ran = false;
    window.cb = function() { ran = true; };
});
test(function(){
    assert_equals(c1.onexit, null, 'initial value');
    c1.onexit = undefined;
    assert_equals(c1.onexit, null, 'assigning undefined');
    c1.onexit = cb;
    assert_equals(c1.onexit, cb, 'assigning onexit');
    c1.dispatchEvent(ev);
    assert_true(ran, 'dispatching event');
    c1.onexit = null;
    assert_equals(c1.onexit, null, 'assigning null');
    ran = false;
    c1.dispatchEvent(ev);
    assert_false(ran, 'dispatching event after nulling onexit');
});
test(function(){
    c1.addEventListener('exit', cb, false);
    c1.dispatchEvent(ev);
    assert_true(ran);
    c1.removeEventListener('exit', cb, false);
    ran = false;
    c1.dispatchEvent(ev);
    assert_false(ran);
}, 'TextTrackCue.addEventListener/removeEventListener');
</script>