| OLD | NEW | 
|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> | 
| 2 <html> | 2 <title>Tests that the TextTrack mode attribute is appropriately set.</title> | 
| 3     <head> | 3 <script src="../media-file.js"></script> | 
|  | 4 <script src="../../resources/testharness.js"></script> | 
|  | 5 <script src="../../resources/testharnessreport.js"></script> | 
|  | 6 <video> | 
|  | 7     <track src="captions-webvtt/captions-fast.vtt" default> | 
|  | 8 </video> | 
|  | 9 <script> | 
|  | 10 async_test(function(t) { | 
|  | 11     var video = document.querySelector("video"); | 
|  | 12     var track = document.querySelector("track"); | 
|  | 13     track.onload = t.step_func(trackLoaded); | 
| 4 | 14 | 
| 5         <script src=../media-file.js></script> | 15     var cueCount = 0; | 
| 6         <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 16     var textTrack; | 
| 7              (Please avoid writing new tests using video-test.js) --> | 17     function trackLoaded() { | 
| 8         <script src=../video-test.js></script> | 18         textTrack = track.track; | 
| 9         <script> | 19         // Test default attribute value. | 
|  | 20         assert_equals(textTrack.mode, "showing"); | 
|  | 21         assert_equals(video.textTracks[0].mode, "showing"); | 
|  | 22         // Set to bogus value, should return default. | 
|  | 23         var value = "bogus"; | 
|  | 24         textTrack.mode = value; | 
|  | 25         assert_equals(textTrack.mode, "showing"); | 
|  | 26         assert_equals(video.textTracks[0].mode, "showing"); | 
| 10 | 27 | 
| 11             var textTrack; | 28         // Set to numeric value (no longer supported), should return default. | 
| 12             var cueCount; | 29         textTrack.mode = 2; | 
|  | 30         assert_equals(textTrack.mode, "showing"); | 
|  | 31         assert_equals(video.textTracks[0].mode, "showing"); | 
| 13 | 32 | 
| 14             function setMode(value) | 33         // Set to known values. | 
| 15             { | 34         setModeAndCheck("disabled"); | 
| 16                 run("textTrack.mode = '" + value + "'"); |  | 
| 17                 testExpected("textTrack.mode", value); |  | 
| 18                 testExpected("video.textTracks[0].mode", value); |  | 
| 19                 if (value == "disabled") |  | 
| 20                     testExpected("textTrack.cues", null); |  | 
| 21                 else |  | 
| 22                     testExpected("textTrack.cues.length", textTrack.cues.length)
    ; |  | 
| 23                 consoleWrite(""); |  | 
| 24             } |  | 
| 25 | 35 | 
| 26             function start() | 36         video.src = findMediaFile("video", "../content/test"); | 
| 27             { | 37         video.play(); | 
| 28                 findMediaElement(); | 38         // Wait for end of first cue (no events should fire while track is disab
    led). | 
| 29                 cueCount = 0; | 39         setTimeout(testHiddenAndShowing, 400); | 
| 30                 consoleWrite(""); | 40     } | 
| 31 | 41 | 
| 32                 textTrack = document.getElementById('track_1').track; | 42     track.oncuechange = t.step_func(function(event) { | 
|  | 43         cueCount++; | 
|  | 44         if (cueCount == textTrack.cues.length) | 
|  | 45             t.done(); | 
|  | 46     }); | 
| 33 | 47 | 
| 34                 consoleWrite("<b>++ Test default attribute value</b>"); | 48     function setModeAndCheck(value) { | 
| 35                 testExpected("textTrack.mode", "showing"); | 49         textTrack.mode =  value; | 
| 36                 testExpected("video.textTracks[0].mode", "showing"); | 50         assert_equals(textTrack.mode, value); | 
| 37                 consoleWrite(""); | 51         assert_equals(video.textTracks[0].mode, value); | 
|  | 52         if (value == "disabled") | 
|  | 53             assert_equals(textTrack.cues, null); | 
|  | 54     } | 
| 38 | 55 | 
| 39                 consoleWrite("<b>*** Set to bogus value, should return default</
    b>"); | 56     function testHiddenAndShowing() { | 
| 40                 var value = "bogus"; | 57         setModeAndCheck("hidden"); | 
| 41                 run("textTrack.mode = '" + value + "'"); | 58         setModeAndCheck("showing"); | 
| 42                 testExpected("textTrack.mode", "showing"); | 59     } | 
| 43                 testExpected("video.textTracks[0].mode", "showing"); | 60 }); | 
| 44                 consoleWrite(""); | 61 </script> | 
| 45 |  | 
| 46                 consoleWrite("<b>*** Set to numeric value (no longer supported),
     should return default</b>"); |  | 
| 47                 run("textTrack.mode = 2"); |  | 
| 48                 testExpected("textTrack.mode", "showing"); |  | 
| 49                 testExpected("video.textTracks[0].mode", "showing"); |  | 
| 50                 consoleWrite(""); |  | 
| 51 |  | 
| 52                 consoleWrite("<b>*** Set to known values</b>"); |  | 
| 53                 consoleWrite("<b>++ 'disabled'</b>"); |  | 
| 54                 setMode("disabled"); |  | 
| 55 |  | 
| 56                 video.src = findMediaFile("video", "../content/test"); |  | 
| 57                 video.play(); |  | 
| 58                 // Wait for end of first cue (no events should fire while track 
    is disabled). |  | 
| 59                 setTimeout(testHiddenAndShowing, 400); |  | 
| 60                 consoleWrite("++ 0 events expected while mode = disabled"); |  | 
| 61                 consoleWrite(""); |  | 
| 62             } |  | 
| 63 |  | 
| 64             function testHiddenAndShowing() |  | 
| 65             { |  | 
| 66                 consoleWrite("<b>++ 'hidden'</b>"); |  | 
| 67                 setMode("hidden"); |  | 
| 68 |  | 
| 69                 consoleWrite("<b>++ 'showing'</b>"); |  | 
| 70                 setMode("showing"); |  | 
| 71 |  | 
| 72                 consoleWrite("++ at least " + textTrack.cues.length + " events e
    xpected while mode = showing"); |  | 
| 73             } |  | 
| 74 |  | 
| 75             waitForEvent('cuechange', |  | 
| 76                 function (event) |  | 
| 77                 { |  | 
| 78                     cueCount++; |  | 
| 79                     if (cueCount == textTrack.cues.length) |  | 
| 80                         endTest(); |  | 
| 81 |  | 
| 82                 } |  | 
| 83             ); |  | 
| 84 |  | 
| 85         </script> |  | 
| 86     </head> |  | 
| 87     <body> |  | 
| 88         <p>Tests that the TextTrack mode attribute is appropriately set.</p> |  | 
| 89         <video> |  | 
| 90             <track id=track_1 src="captions-webvtt/captions-fast.vtt" onload="st
    art()" default> |  | 
| 91         </video> |  | 
| 92     </body> |  | 
| 93 </html> |  | 
| OLD | NEW | 
|---|