OLD | NEW |
---|---|
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <title>Test to ensure that no text track cues are active after the video is unlo aded.</title> |
3 <head> | 3 <script src="../media-file.js"></script> |
4 <script src=../media-file.js></script> | 4 <script src="../../resources/testharness.js"></script> |
5 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 5 <script src="../../resources/testharnessreport.js"></script> |
6 (Please avoid writing new tests using video-test.js) --> | 6 <script> |
7 <script src=../video-test.js></script> | 7 var eventCount = 0; |
philipj_slow
2016/04/11 11:50:03
Can you put this the helper inside the async_test
Srirama
2016/04/11 12:06:56
Done.
| |
8 var video; | |
9 var trackElement; | |
8 | 10 |
9 <script> | 11 function clearSrc() { |
philipj_slow
2016/04/11 11:50:02
clearSrc doesn't quite work as a name when you've
Srirama
2016/04/11 12:06:56
Done.
| |
10 function clearSrc() | 12 eventCount++; |
11 { | 13 if (eventCount == 3) { |
12 consoleWrite("<br>** Video and track loaded, one cue should be a ctive **"); | 14 assert_equals(trackElement.track.activeCues.length, 1); |
13 testExpected("trackElement.track.activeCues.length", 1); | 15 video.src = ''; |
16 } | |
17 } | |
14 | 18 |
15 consoleWrite("<br>** Clear video 'src' and force reload **"); | 19 async_test(function(t) { |
16 run("video.src = ''"); | 20 video = document.createElement('video'); |
17 consoleWrite(""); | 21 video.src = findMediaFile('video', '../content/test'); |
18 } | 22 trackElement = document.createElement('track'); |
19 | 23 |
20 function videoError() | 24 trackElement.onload = t.step_func(function() { |
philipj_slow
2016/04/11 11:50:02
Just t.step_func(clearSrc) should work.
Srirama
2016/04/11 12:06:56
Done.
| |
21 { | 25 clearSrc(); |
22 consoleWrite("** 'error' event, no cues should be active **)"); | 26 }); |
23 testExpected("event.target", video); | |
24 testExpected("video.error", null, "!="); | |
25 testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SU PPORTED); | |
26 testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_S OURCE); | |
27 testExpected("trackElement.track.activeCues.length", 0); | |
28 | 27 |
29 consoleWrite(""); | 28 trackElement.oncuechange = t.step_func(function() { |
30 endTest(); | 29 clearSrc(); |
31 } | 30 }); |
32 | 31 |
33 function setup() | 32 video.oncanplaythrough = t.step_func(function() { |
34 { | 33 clearSrc(); |
35 consoleWrite(""); | 34 }); |
36 | 35 |
37 findMediaElement(); | 36 video.onerror = t.step_func_done(function() { |
38 trackElement = document.querySelector('track'); | 37 assert_equals(event.target, video); |
38 assert_not_equals(video.error, null); | |
39 assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); | |
40 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); | |
41 assert_equals(trackElement.track.activeCues.length, 0); | |
42 }); | |
39 | 43 |
40 waitForEventsAndCall([[video, 'canplaythrough'], [trackElement, 'load'], [trackElement, 'cuechange']], clearSrc); | 44 trackElement.src = 'captions-webvtt/captions-fast.vtt'; |
41 | 45 trackElement.kind = 'captions'; |
42 video.src = findMediaFile("video", "../content/test"); | 46 trackElement.default = true; |
43 } | 47 video.appendChild(trackElement); |
44 | 48 }); |
45 </script> | 49 </script> |
46 </head> | |
47 <body onload="setup()"> | |
48 <video controls onerror="videoError()"> | |
49 <track src="captions-webvtt/captions-fast.vtt" kind="captions" defau lt> | |
50 </video> | |
51 | |
52 <p>Test to ensure that a no text track cues are active after the video i s unloaded.</p> | |
53 | |
54 </body> | |
55 </html> | |
OLD | NEW |