Index: LayoutTests/media/track/track-datacue.html |
diff --git a/LayoutTests/media/track/track-datacue.html b/LayoutTests/media/track/track-datacue.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f08c7ea95585e94ac08c384de354c16f67d5fb1a |
--- /dev/null |
+++ b/LayoutTests/media/track/track-datacue.html |
@@ -0,0 +1,76 @@ |
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
+ |
+ <script src=../media-file.js></script> |
+ <script src=../video-test.js></script> |
+ <script> |
+ function loaded() |
+ { |
+ expectedData = new Uint8Array([4, 5, 2, 1, 9]); |
+ cue = new DataCue(3, 10, expectedData.buffer); |
+ |
+ consoleWrite("<br>*** Test DataCue's TextTrackCue interface."); |
+ testExpected("cue", TextTrackCue, "instanceof"); |
+ testExpected("cue.track", null); |
+ testExpected("cue.id", ""); |
+ testExpected("cue.startTime", 3); |
+ testExpected("cue.endTime", 10); |
+ testExpected("cue.pauseOnExit", false); |
+ |
+ consoleWrite("<br>*** Test DataCue interface."); |
+ testExpected("cue", DataCue, "instanceof"); |
+ testArraysEqual("new Uint8Array(cue.data)", expectedData); |
+ testExpected("cue.text", null); |
+ |
+ // https://www.w3.org/Bugs/Public/show_bug.cgi?id=24687 |
+ consoleWrite("<br>*** Changing the original buffer data should not effect DataCue.data."); |
+ |
+ // Passing data to constructor then changing the original buffer |
+ run("expectedData[0] = 7"); |
+ testExpected("new Uint8Array(cue.data)[0]", 4); |
+ |
+ // Setting .data then changing the original buffer |
+ run("cue.data = expectedData.buffer"); |
+ testExpected("new Uint8Array(cue.data)[0]", 7); |
+ run("expectedData[0] = 11"); |
+ testExpected("new Uint8Array(cue.data)[0]", 7); |
+ |
+ // Getting .data then changing the original buffer |
+ run("new Uint8Array(cue.data)[0] = 8"); |
+ testExpected("(new Uint8Array(cue.data))[0]", 7); |
+ |
+ consoleWrite("<br>*** Throw exception if data is not an ArrayBuffer."); |
+ var error = "'TypeError: Type error'"; |
+ testDOMException("cue.data = null", "DOMException.INVALID_NODE_TYPE_ERR"); |
acolwell GONE FROM CHROMIUM
2014/04/04 23:25:27
Shouldn't all these invalid assignments be TypeErr
|
+ testDOMException("cue.data = 'test'", "DOMException.INVALID_NODE_TYPE_ERR"); |
+ testDOMException("cue.data = [5]", "DOMException.INVALID_NODE_TYPE_ERR"); |
+ testDOMException("badCue = new DataCue(1, 2, null)", "DOMException.INVALID_NODE_TYPE_ERR"); |
+ testDOMException("badCue = new DataCue(1, 2, 'test')", "DOMException.INVALID_NODE_TYPE_ERR"); |
+ testDOMException("badCue = new DataCue(1, 2, [5])", "DOMException.INVALID_NODE_TYPE_ERR"); |
+ |
+ consoleWrite("<br>*** Test adding DataCue to track with kind = 'metadata'."); |
+ var video = document.createElement("video"); |
+ metadataTrack = video.addTextTrack("metadata"); |
+ metadataTrack.addCue(cue); |
+ |
+ testExpected("cue.track", metadataTrack); |
+ testExpected("metadataTrack.cues[0]", cue); |
+ |
+ consoleWrite("<br>*** Test adding DataCue to track with kind != 'metadata'."); |
+ ["subtitles", "captions", "descriptions", "chapters"].forEach(function(kind) { |
+ track = video.addTextTrack(kind); |
+ |
+ testDOMException("track.addCue(cue)", "DOMException.INVALID_NODE_TYPE_ERR"); |
+ testExpected("track.cues.length", 0); |
+ }); |
+ |
+ endTest(); |
+ } |
+ </script> |
+ </head> |
+ <body onload="loaded()"> |
+ <p>Tests DataCue interface</p> |
+ </body> |
+</html> |