OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <title>TextTrackList.onaddtrack</title> | 2 <title>TextTrackList.onaddtrack</title> |
3 <script src=../../../../../resources/testharness.js></script> | 3 <script src=../../../../../resources/testharness.js></script> |
4 <script src=../../../../../resources/testharnessreport.js></script> | 4 <script src=../../../../../resources/testharnessreport.js></script> |
5 <div id=log></div> | 5 <div id=log></div> |
6 <script> | 6 <script> |
7 setup(function(){ | 7 setup(function(){ |
8 window.tracks = document.createElement('video').textTracks; | 8 // TODO(philipj): Remove this test in favor of those in web-platform-tests |
| 9 // once Oilpan has shipped. https://crbug.com/503852 |
| 10 window.video = document.createElement('video'); |
| 11 window.tracks = video.textTracks; |
9 window.ev = new Event('addtrack'); | 12 window.ev = new Event('addtrack'); |
10 window.ran = false; | 13 window.ran = false; |
11 window.cb = function() { ran = true; }; | 14 window.cb = function() { ran = true; }; |
12 }); | 15 }); |
13 test(function(){ | 16 test(function(){ |
14 assert_equals(tracks.onaddtrack, null); | 17 assert_equals(tracks.onaddtrack, null); |
15 tracks.onaddtrack = cb; | 18 tracks.onaddtrack = cb; |
16 assert_equals(tracks.onaddtrack, cb); | 19 assert_equals(tracks.onaddtrack, cb); |
17 tracks.dispatchEvent(ev); | 20 tracks.dispatchEvent(ev); |
18 assert_true(ran); | 21 assert_true(ran); |
19 tracks.onaddtrack = null; | 22 tracks.onaddtrack = null; |
20 ran = false; | 23 ran = false; |
21 tracks.dispatchEvent(ev); | 24 tracks.dispatchEvent(ev); |
22 assert_false(ran); | 25 assert_false(ran); |
23 }); | 26 }); |
24 test(function(){ | 27 test(function(){ |
25 tracks.addEventListener('addtrack', cb, false); | 28 tracks.addEventListener('addtrack', cb, false); |
26 tracks.dispatchEvent(ev); | 29 tracks.dispatchEvent(ev); |
27 assert_true(ran); | 30 assert_true(ran); |
28 tracks.removeEventListener('addtrack', cb, false); | 31 tracks.removeEventListener('addtrack', cb, false); |
29 ran = false; | 32 ran = false; |
30 tracks.dispatchEvent(ev); | 33 tracks.dispatchEvent(ev); |
31 assert_false(ran); | 34 assert_false(ran); |
32 }, 'TextTrackList.addEventListener/removeEventListener'); | 35 }, 'TextTrackList.addEventListener/removeEventListener'); |
33 </script> | 36 </script> |
OLD | NEW |