Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <video> | |
| 6 <track id="testTrack" src="captions-webvtt/captions-fast.vtt"> | |
|
philipj_slow
2016/04/06 12:40:04
Given that the test is synchronous, does this real
Srirama
2016/04/07 10:40:07
Done.
| |
| 7 </video> | |
| 8 <script> | |
| 9 var testTrack; | |
|
philipj_slow
2016/04/06 12:40:04
Move in to test?
Srirama
2016/04/07 10:40:07
Done.
| |
| 10 var region; | |
| 11 var regions; | |
| 12 var updatedRegion; | |
| 5 | 13 |
| 6 <script src=../../media-file.js></script> | 14 test(function() { |
| 7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 15 testTrack = document.querySelector('track'); |
| 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 | 16 |
| 16 function startTest() | 17 assert_equals(testTrack.track.mode, "disabled"); |
| 17 { | 18 assert_equals(testTrack.track.regions, null); |
| 18 testTrack = document.getElementsByTagName('track')[0]; | |
| 19 | 19 |
| 20 consoleWrite("<br>** Implicit mode disabled and the regions attribut e is null **"); | 20 testTrack.track.mode = "hidden"; |
| 21 testExpected("testTrack.track.mode", "disabled"); | 21 regions = testTrack.track.regions; |
| 22 testExpected("testTrack.track.regions", null); | |
| 23 | 22 |
| 24 testTrack.track.mode = "hidden"; | 23 assert_true(regions instanceof VTTRegionList, 'instanceof'); |
|
Srirama
2016/04/01 12:14:23
should i remove these kind of gaurds also? Or its
philipj_slow
2016/04/06 12:19:40
This one seems OK, but you could remove the follow
Srirama
2016/04/07 10:40:07
Done.
| |
| 25 regions = testTrack.track.regions; | |
| 26 | 24 |
| 27 consoleWrite("<br>** Test instanceof VTTRegionList **"); | 25 assert_not_equals(regions, null); |
| 28 testExpected("regions instanceof VTTRegionList", true); | 26 assert_equals(regions.length, 0); |
| 29 | 27 |
| 30 consoleWrite("<br>** The regions attribute should be an empty VTTReg ionList **"); | 28 region = new VTTRegion(); |
| 31 testExpected("regions != null", true); | 29 region.id = "TestId"; |
| 32 testExpected("regions.length", 0); | |
| 33 | 30 |
| 34 region = new VTTRegion(); | 31 assert_equals(region.track, null); |
| 35 region.id = "TestId"; | |
| 36 | 32 |
| 37 consoleWrite("<br>** The default value of the track attribute of the region is null**"); | 33 testTrack.track.addRegion(region); |
| 38 testExpected("region.track", null); | |
| 39 | 34 |
| 40 testTrack.track.addRegion(region); | 35 assert_equals(regions.length, 1); |
| 36 assert_equals(regions[0], region); | |
| 37 assert_equals(regions[0].track, testTrack.track); | |
| 41 | 38 |
| 42 consoleWrite("<br>** The addRegion() method properly updates the VTT RegionList object **"); | 39 assert_equals(region.track, testTrack.track); |
| 43 testExpected("regions.length", 1); | |
| 44 testExpected("regions[0] == region", true); | |
| 45 testExpected("regions[0].track == testTrack.track", true); | |
| 46 | 40 |
| 47 consoleWrite("<br>** The track attribute should correctly reflect th e track to which the region was added to**"); | 41 updatedRegion = new VTTRegion(); |
| 48 testExpected("region.track == testTrack.track", true); | 42 updatedRegion.id = region.id; |
| 43 updatedRegion.viewportAnchorX = 59; | |
| 44 updatedRegion.viewportAnchorY = 68; | |
| 45 updatedRegion.regionAnchorX = 20; | |
| 46 updatedRegion.regionAnchorY = 30; | |
| 47 updatedRegion.height = 5; | |
| 48 updatedRegion.width = 87; | |
| 49 updatedRegion.scroll = "up"; | |
| 49 | 50 |
| 50 updatedRegion = new VTTRegion(); | 51 testTrack.track.addRegion(updatedRegion); |
| 51 updatedRegion.id = region.id; | 52 assert_equals(regions[0].viewportAnchorX, updatedRegion.viewportAnchorX); |
| 52 updatedRegion.viewportAnchorX = 59; | 53 assert_equals(regions[0].viewportAnchorY, updatedRegion.viewportAnchorY); |
| 53 updatedRegion.viewportAnchorY = 68; | 54 assert_equals(regions[0].regionAnchorX, updatedRegion.regionAnchorX); |
| 54 updatedRegion.regionAnchorX = 20; | 55 assert_equals(regions[0].regionAnchorY, updatedRegion.regionAnchorY); |
| 55 updatedRegion.regionAnchorY = 30; | 56 assert_equals(regions[0].height, updatedRegion.height); |
| 56 updatedRegion.height = 5; | 57 assert_equals(regions[0].width, updatedRegion.width); |
| 57 updatedRegion.width = 87; | 58 assert_equals(regions[0].scroll, updatedRegion.scroll); |
| 58 updatedRegion.scroll = "up"; | |
| 59 | 59 |
| 60 consoleWrite("<br>** Adding a region with an existing id should upda te the existing region **"); | 60 assert_not_equals(regions[0], updatedRegion); |
| 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 | 61 |
| 70 testExpected("regions[0] != updatedRegion", true); | 62 testTrack.track.addRegion(region); |
| 63 assert_equals(regions.length, 1); | |
| 64 testTrack.track.removeRegion(region); | |
| 65 assert_equals(regions.length, 0); | |
| 71 | 66 |
| 72 consoleWrite("<br>** Add the region back and check if removeRegion() removes it properly **"); | 67 assert_throws("NotFoundError", function() { testTrack.track.removeRegion(reg ion); }); |
| 73 testTrack.track.addRegion(region); | |
| 74 testExpected("regions.length", 1); | |
| 75 testTrack.track.removeRegion(region); | |
| 76 testExpected("regions.length", 0); | |
| 77 | 68 |
| 78 consoleWrite("<br>** In case the region is not found, NotFoundError should be thrown **"); | 69 // FIXME(109818): Update test for multiple initial regions (after parsing is supported). |
| 79 try { | 70 }); |
| 80 testTrack.track.removeRegion(region); | 71 </script> |
| 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> | 72 </html> |
| OLD | NEW |