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 async_test(function(t) { |
| 8 var eventCount = 0; |
8 | 9 |
9 <script> | 10 function eventCallback() { |
10 function clearSrc() | 11 eventCount++; |
11 { | 12 if (eventCount == 3) { |
12 consoleWrite("<br>** Video and track loaded, one cue should be a
ctive **"); | 13 assert_equals(trackElement.track.activeCues.length, 1); |
13 testExpected("trackElement.track.activeCues.length", 1); | 14 video.src = ''; |
| 15 } |
| 16 } |
14 | 17 |
15 consoleWrite("<br>** Clear video 'src' and force reload **"); | 18 var video = document.createElement('video'); |
16 run("video.src = ''"); | 19 video.src = findMediaFile('video', '../content/test'); |
17 consoleWrite(""); | 20 var trackElement = document.createElement('track'); |
18 } | |
19 | 21 |
20 function videoError() | 22 trackElement.onload = t.step_func(eventCallback); |
21 { | 23 trackElement.oncuechange = t.step_func(eventCallback); |
22 consoleWrite("** 'error' event, no cues should be active **)"); | 24 video.oncanplaythrough = t.step_func(eventCallback); |
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 | 25 |
29 consoleWrite(""); | 26 video.onerror = t.step_func_done(function() { |
30 endTest(); | 27 assert_equals(event.target, video); |
31 } | 28 assert_not_equals(video.error, null); |
| 29 assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
| 30 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); |
| 31 assert_equals(trackElement.track.activeCues.length, 0); |
| 32 }); |
32 | 33 |
33 function setup() | 34 trackElement.src = 'captions-webvtt/captions-fast.vtt'; |
34 { | 35 trackElement.kind = 'captions'; |
35 consoleWrite(""); | 36 trackElement.default = true; |
36 | 37 video.appendChild(trackElement); |
37 findMediaElement(); | 38 }); |
38 trackElement = document.querySelector('track'); | 39 </script> |
39 | |
40 waitForEventsAndCall([[video, 'canplaythrough'], [trackElement,
'load'], [trackElement, 'cuechange']], clearSrc); | |
41 | |
42 video.src = findMediaFile("video", "../content/test"); | |
43 } | |
44 | |
45 </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 |