Update WPT tests for embedded content
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / html / semantics / embedded-content / media-elements / interfaces / TextTrack / removeCue.html
1 <!doctype html>
2 <title>TextTrack.removeCue()</title>
3 <script src=/resources/testharness.js></script>
4 <script src=/resources/testharnessreport.js></script>
5 <div id=log></div>
6 <script>
7 setup(function(){
8     window.video = document.createElement('video');
9     document.body.appendChild(video);
10 });
11 test(function() {
12     var t1 = video.addTextTrack('subtitles');
13     var t2 = video.addTextTrack('subtitles');
14     var c1 = new VTTCue(0, 1, 'text1');
15     assert_throws("NOT_FOUND_ERR", function() {
16         t1.removeCue(c1);
17     }, 'standalone');
18     t1.addCue(c1);
19     assert_throws("NOT_FOUND_ERR", function() {
20         t2.removeCue(c1);
21     }, 'listed in t1, remove from t2');
22     t1.removeCue(c1);
23     assert_throws("NOT_FOUND_ERR", function() {
24         t1.removeCue(c1);
25     }, 'standalone, remove from t1');
26     assert_throws("NOT_FOUND_ERR", function() {
27         t2.removeCue(c1);
28     }, 'standalone, remove from t2');
29 }, document.title+', two elementless tracks');
30 var t = async_test(document.title+', cue from track element');
31 t.step(function(){
32     var t1 = video.addTextTrack('subtitles');
33     var track = document.createElement('track');
34     track.onload = t.step_func(function(){
35         var cue = track.track.cues[0];
36         assert_throws('NOT_FOUND_ERR', function() { t1.removeCue(cue); }, 'listed in track.track, remove from t1');
37         track.track.removeCue(cue);
38         assert_throws('NOT_FOUND_ERR', function() { track.track.removeCue(cue); }, 'standalone, remove from track.track');
39         assert_throws('NOT_FOUND_ERR', function() { t1.removeCue(cue); }, 'standalone, remove from t1');
40         t.done();
41     });
42     track.onerror = t.step_func(function() {
43       assert_unreached('got error event');
44     });
45     track.src= 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:01.000\ntest\n');
46     track.kind = 'subtitles';
47     track.track.mode = 'hidden';
48     video.appendChild(track);
49 });
50 </script>