OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests default DOM layout structure for a VTTRegion.</title> |
3 <head> | 3 <script src="../../media-controls.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../media-file.js"></script> |
| 5 <script src="../../../resources/testharness.js"></script> |
| 6 <script src="../../../resources/testharnessreport.js"></script> |
| 7 <script> |
| 8 var testTrack; |
| 9 var region; |
| 10 var container; |
| 11 var video; |
5 | 12 |
6 <script src=../../media-controls.js></script> | 13 async_test(function(t) { |
7 <script src=../../media-file.js></script> | 14 assert_not_equals(window.VTTRegion, null); |
8 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | |
9 (Please avoid writing new tests using video-test.js) --> | |
10 <script src=../../video-test.js></script> | |
11 <script> | |
12 var testTrack; | |
13 var region; | |
14 var container; | |
15 | 15 |
16 function testRegionsDisplay() | 16 video = document.createElement('video'); |
17 { | 17 video.src = findMediaFile('video', '../../content/test'); |
18 testTrack = video.textTracks[0]; | 18 testTrack = document.createElement('track'); |
| 19 testTrack.onload = t.step_func(function() { |
| 20 video.oncanplaythrough = t.step_func(function() { |
| 21 assert_equals(testTrack.track.regions.length, 1); |
19 | 22 |
20 consoleWrite("** The text track has only one region **"); | 23 region = textTrackDisplayElement(video, 'region'); |
21 testExpected("testTrack.regions.length", 1); | 24 container = textTrackDisplayElement(video, 'region-container'); |
22 | 25 |
23 try { | 26 assert_equals(region.children.length, 1); |
24 region = textTrackDisplayElement(video, 'region'); | 27 assert_equals(region.children[0], container); |
25 container = textTrackDisplayElement(video, 'region-container'); | 28 assert_equals(internals.shadowPseudoId(region), '-webkit-media-text-
track-region'); |
26 } catch(e) { | 29 assert_equals(internals.shadowPseudoId(container), '-webkit-media-te
xt-track-region-container'); |
27 consoleWrite(e); | 30 t.done(); |
28 } | 31 }); |
29 | 32 }); |
30 consoleWrite("<br>** Inspecting the default DOM layout used for regi
ons display **"); | 33 testTrack.src= '../captions-webvtt/captions-regions.vtt'; |
31 | 34 testTrack.kind = 'captions'; |
32 consoleWrite("<br>** Only one region should be displayed **"); | 35 testTrack.default = true; |
33 testExpected("region.children.length", 1); | 36 video.appendChild(testTrack); |
34 | 37 }); |
35 consoleWrite("<br>** The child of the region should be the container
**"); | 38 </script> |
36 testExpected("region.children[0] == container", true); | |
37 | |
38 consoleWrite("<br>** Default pseudo IDs should be set properly"); | |
39 testExpected("internals.shadowPseudoId(region)", "-webkit-media-text
-track-region"); | |
40 testExpected("internals.shadowPseudoId(container)", "-webkit-media-t
ext-track-region-container"); | |
41 | |
42 endTest(); | |
43 } | |
44 | |
45 function startTest() | |
46 { | |
47 if (!window.VTTRegion) { | |
48 failTest(); | |
49 return; | |
50 } | |
51 | |
52 findMediaElement(); | |
53 | |
54 video.src = findMediaFile('video', '../../content/test'); | |
55 waitForEvent('canplaythrough', testRegionsDisplay); | |
56 } | |
57 | |
58 </script> | |
59 </head> | |
60 <body> | |
61 <p>Tests default DOM layout structure for a VTTRegion.</p> | |
62 <video controls> | |
63 <track src="../captions-webvtt/captions-regions.vtt" kind="captions"
default onload="startTest()"> | |
64 </video> | |
65 </body> | |
66 </html> | |
OLD | NEW |