OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 |
| 6 <script src=../media-file.js></script> |
| 7 <script src=../video-test.js></script> |
| 8 <script> |
| 9 function loaded() |
| 10 { |
| 11 expectedData = new Uint8Array([4, 5, 2, 1, 9]); |
| 12 cue = new DataCue(3, 10, expectedData.buffer); |
| 13 |
| 14 consoleWrite("<br>*** Test DataCue's TextTrackCue interface."); |
| 15 testExpected("cue", TextTrackCue, "instanceof"); |
| 16 testExpected("cue.track", null); |
| 17 testExpected("cue.id", ""); |
| 18 testExpected("cue.startTime", 3); |
| 19 testExpected("cue.endTime", 10); |
| 20 testExpected("cue.pauseOnExit", false); |
| 21 |
| 22 consoleWrite("<br>*** Test DataCue interface."); |
| 23 testExpected("cue", DataCue, "instanceof"); |
| 24 testArraysEqual("new Uint8Array(cue.data)", expectedData); |
| 25 testExpected("cue.text", null); |
| 26 |
| 27 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=24687 |
| 28 consoleWrite("<br>*** Changing the original buffer data should n
ot effect DataCue.data."); |
| 29 |
| 30 // Passing data to constructor then changing the original buffer |
| 31 run("expectedData[0] = 7"); |
| 32 testExpected("new Uint8Array(cue.data)[0]", 4); |
| 33 |
| 34 // Setting .data then changing the original buffer |
| 35 run("cue.data = expectedData.buffer"); |
| 36 testExpected("new Uint8Array(cue.data)[0]", 7); |
| 37 run("expectedData[0] = 11"); |
| 38 testExpected("new Uint8Array(cue.data)[0]", 7); |
| 39 |
| 40 // Getting .data then changing the original buffer |
| 41 run("new Uint8Array(cue.data)[0] = 8"); |
| 42 testExpected("(new Uint8Array(cue.data))[0]", 7); |
| 43 |
| 44 consoleWrite("<br>*** Throw exception if data is not an ArrayBuf
fer."); |
| 45 testExceptionType("cue.data = null", "TypeError"); |
| 46 testExceptionType("cue.data = 'test'", "TypeError"); |
| 47 testExceptionType("cue.data = [5]", "TypeError"); |
| 48 testExceptionType("badCue = new DataCue(1, 2, null)", "TypeError
"); |
| 49 testExceptionType("badCue = new DataCue(1, 2, 'test')", "TypeErr
or"); |
| 50 testExceptionType("badCue = new DataCue(1, 2, [5])", "TypeError"
); |
| 51 testExceptionType("badCue = new DataCue(NaN, 2, expectedData.buf
fer)", "TypeError"); |
| 52 testExceptionType("badCue = new DataCue(1, NaN, expectedData.buf
fer)", "TypeError"); |
| 53 |
| 54 consoleWrite("<br>*** Test adding DataCue to track with kind = '
metadata'."); |
| 55 var video = document.createElement("video"); |
| 56 metadataTrack = video.addTextTrack("metadata"); |
| 57 metadataTrack.addCue(cue); |
| 58 |
| 59 testExpected("cue.track", metadataTrack); |
| 60 testExpected("metadataTrack.cues[0]", cue); |
| 61 |
| 62 consoleWrite("<br>*** Test adding DataCue to track with kind !=
'metadata'."); |
| 63 ["subtitles", "captions", "descriptions", "chapters"].forEach(fu
nction(kind) { |
| 64 track = video.addTextTrack(kind); |
| 65 track.addCue(cue); |
| 66 testExpected("cue.track", track); |
| 67 testExpected("track.cues[0]", cue); |
| 68 }); |
| 69 |
| 70 endTest(); |
| 71 } |
| 72 </script> |
| 73 </head> |
| 74 <body onload="loaded()"> |
| 75 <p>Tests DataCue interface</p> |
| 76 </body> |
| 77 </html> |
OLD | NEW |