Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/regions-webvtt/vtt-region-list.html

Issue 1854553003: Convert webvtt regions tests from video-test.js to testharness.js based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Tests VTTRegionList functionality: length, operator[], and getRegionById( ).</title>
3 <head> 3 <script src="../../../resources/testharness.js"></script>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../../../resources/testharnessreport.js"></script>
5 <script>
6 test(function() {
7 var testTrack = document.createElement('track');
8
9 assert_equals(testTrack.track.mode, 'disabled');
10 assert_equals(testTrack.track.regions, null);
5 11
6 <script src=../../media-file.js></script> 12 testTrack.track.mode = 'hidden';
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 13 var regions = testTrack.track.regions;
8 (Please avoid writing new tests using video-test.js) -->
9 <script src=../../video-test.js></script>
10 <script>
11 var testTrack;
12 var region;
13 var regions;
14 var updatedRegion;
15 14
16 function startTest() 15 assert_true(regions instanceof VTTRegionList, 'instanceof');
17 {
18 testTrack = document.getElementsByTagName('track')[0];
19 16
20 consoleWrite("<br>** Implicit mode disabled and the regions attribut e is null **"); 17 assert_equals(regions.length, 0);
21 testExpected("testTrack.track.mode", "disabled");
22 testExpected("testTrack.track.regions", null);
23 18
24 testTrack.track.mode = "hidden"; 19 var region = new VTTRegion();
25 regions = testTrack.track.regions; 20 region.id = 'TestId';
26 21
27 consoleWrite("<br>** Test instanceof VTTRegionList **"); 22 assert_equals(region.track, null);
28 testExpected("regions instanceof VTTRegionList", true);
29 23
30 consoleWrite("<br>** The regions attribute should be an empty VTTReg ionList **"); 24 testTrack.track.addRegion(region);
31 testExpected("regions != null", true);
32 testExpected("regions.length", 0);
33 25
34 region = new VTTRegion(); 26 assert_equals(regions.length, 1);
35 region.id = "TestId"; 27 assert_equals(regions[0], region);
28 assert_equals(regions[0].track, testTrack.track);
36 29
37 consoleWrite("<br>** The default value of the track attribute of the region is null**"); 30 assert_equals(region.track, testTrack.track);
38 testExpected("region.track", null);
39 31
40 testTrack.track.addRegion(region); 32 var updatedRegion = new VTTRegion();
33 updatedRegion.id = region.id;
34 updatedRegion.viewportAnchorX = 59;
35 updatedRegion.viewportAnchorY = 68;
36 updatedRegion.regionAnchorX = 20;
37 updatedRegion.regionAnchorY = 30;
38 updatedRegion.height = 5;
39 updatedRegion.width = 87;
40 updatedRegion.scroll = 'up';
41 41
42 consoleWrite("<br>** The addRegion() method properly updates the VTT RegionList object **"); 42 testTrack.track.addRegion(updatedRegion);
43 testExpected("regions.length", 1); 43 assert_equals(regions[0].viewportAnchorX, updatedRegion.viewportAnchorX);
44 testExpected("regions[0] == region", true); 44 assert_equals(regions[0].viewportAnchorY, updatedRegion.viewportAnchorY);
45 testExpected("regions[0].track == testTrack.track", true); 45 assert_equals(regions[0].regionAnchorX, updatedRegion.regionAnchorX);
46 assert_equals(regions[0].regionAnchorY, updatedRegion.regionAnchorY);
47 assert_equals(regions[0].height, updatedRegion.height);
48 assert_equals(regions[0].width, updatedRegion.width);
49 assert_equals(regions[0].scroll, updatedRegion.scroll);
46 50
47 consoleWrite("<br>** The track attribute should correctly reflect th e track to which the region was added to**"); 51 assert_not_equals(regions[0], updatedRegion);
48 testExpected("region.track == testTrack.track", true);
49 52
50 updatedRegion = new VTTRegion(); 53 testTrack.track.addRegion(region);
51 updatedRegion.id = region.id; 54 assert_equals(regions.length, 1);
52 updatedRegion.viewportAnchorX = 59; 55 testTrack.track.removeRegion(region);
53 updatedRegion.viewportAnchorY = 68; 56 assert_equals(regions.length, 0);
54 updatedRegion.regionAnchorX = 20;
55 updatedRegion.regionAnchorY = 30;
56 updatedRegion.height = 5;
57 updatedRegion.width = 87;
58 updatedRegion.scroll = "up";
59 57
60 consoleWrite("<br>** Adding a region with an existing id should upda te the existing region **"); 58 assert_throws('NotFoundError', function() { testTrack.track.removeRegion(reg ion); });
61 testTrack.track.addRegion(updatedRegion);
62 testExpected("regions[0].viewportAnchorX", updatedRegion.viewportAnc horX);
63 testExpected("regions[0].viewportAnchorY", updatedRegion.viewportAnc horY);
64 testExpected("regions[0].regionAnchorX", updatedRegion.regionAnchorX );
65 testExpected("regions[0].regionAnchorY", updatedRegion.regionAnchorY );
66 testExpected("regions[0].height", updatedRegion.height);
67 testExpected("regions[0].width", updatedRegion.width);
68 testExpected("regions[0].scroll", updatedRegion.scroll);
69 59
70 testExpected("regions[0] != updatedRegion", true); 60 // FIXME(109818): Update test for multiple initial regions (after parsing is supported).
71 61 });
72 consoleWrite("<br>** Add the region back and check if removeRegion() removes it properly **"); 62 </script>
73 testTrack.track.addRegion(region);
74 testExpected("regions.length", 1);
75 testTrack.track.removeRegion(region);
76 testExpected("regions.length", 0);
77
78 consoleWrite("<br>** In case the region is not found, NotFoundError should be thrown **");
79 try {
80 testTrack.track.removeRegion(region);
81 } catch(e) {
82 consoleWrite(e);
83 }
84
85 // FIXME(109818): Update test for multiple initial regions (after pa rsing is supported).
86
87 consoleWrite("");
88 endTest();
89 }
90
91 function startTestWithDelay()
92 {
93 setTimeout(startTest, 100);
94 }
95 </script>
96 </head>
97 <body onload="startTestWithDelay()">
98 <p>Tests VTTRegionList functionality: length, operator[], and getRegionB yId()</p>
99 <video>
100 <track id="testTrack" src="captions-webvtt/captions-fast.vtt">
101 </video>
102 </body>
103 </html> 63 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698