Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-trackdefault.html
blob61dcd786e194baed09f04f75c7706accf63e62ac
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="/w3c/resources/testharness.js"></script>
5 <script src="/w3c/resources/testharnessreport.js"></script>
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
12 function checkConstructionSucceeds(type, language, label, kinds, byteStreamTrackID)
14 var trackDefault = new TrackDefault(type, language, label, kinds, byteStreamTrackID);
15 assert_equals(trackDefault.type, type, "type");
16 assert_equals(trackDefault.language, language, "language");
17 assert_equals(trackDefault.label, label, "label");
18 assert_equals(trackDefault.byteStreamTrackID, byteStreamTrackID, "byteStreamTrackID");
19 assert_array_equals(trackDefault.kinds, kinds, "kinds");
22 function checkConstructionFails(type, language, label, kinds, byteStreamTrackID)
24 assert_throws(new TypeError(),
25 function() { new TrackDefault(type, language, label, kinds, byteStreamTrackID); },
26 "TrackDefault construction threw an exception");
29 function trackDefaultConstructionTest(type, language, label, kinds, byteStreamTrackID, expectation, description)
31 test(function()
33 if (expectation)
34 checkConstructionSucceeds(type, language, label, kinds, byteStreamTrackID);
35 else
36 checkConstructionFails(type, language, label, kinds, byteStreamTrackID);
37 }, description + ": type '" + type + "', language '" + language + "', label '" + label + "', multiple kinds, byteStreamTrackID '" + byteStreamTrackID + "'");
39 // If all of |kinds| are expected to succeed, also test each kind individually.
40 if (!expectation || kinds.length <= 1)
41 return;
42 for (var i = 0; i < kinds.length; ++i) {
43 test(function()
45 checkConstructionSucceeds(type, language, label, new Array(kinds[i]), byteStreamTrackID);
46 }, description + ": type '" + type + "', language '" + language + "', label '" + label + "', kind '" + kinds[i] + "', byteStreamTrackID '" + byteStreamTrackID + "'");
50 var VALID_AUDIO_TRACK_KINDS = [
51 "alternative",
52 "descriptions",
53 "main",
54 "main-desc",
55 "translation",
56 "commentary",
57 "",
60 var VALID_VIDEO_TRACK_KINDS = [
61 "alternative",
62 "captions",
63 "main",
64 "sign",
65 "subtitles",
66 "commentary",
67 "",
70 var VALID_TEXT_TRACK_KINDS = [
71 "subtitles",
72 "captions",
73 "descriptions",
74 "chapters",
75 "metadata",
78 trackDefaultConstructionTest("audio", "en-US", "audio label", VALID_AUDIO_TRACK_KINDS, "1", true, "Test valid audio kinds");
80 trackDefaultConstructionTest("video", "en-US", "video label", VALID_VIDEO_TRACK_KINDS, "1", true, "Test valid video kinds");
82 trackDefaultConstructionTest("text", "en-US", "text label", VALID_TEXT_TRACK_KINDS, "1", true, "Test valid text kinds");
84 trackDefaultConstructionTest("audio", "en-US", "audio label", VALID_VIDEO_TRACK_KINDS, "1", false, "Test mixed valid and invalid audio kinds");
86 trackDefaultConstructionTest("video", "en-US", "video label", VALID_AUDIO_TRACK_KINDS, "1", false, "Test mixed valid and invalid video kinds");
88 trackDefaultConstructionTest("text", "en-US", "text label", VALID_VIDEO_TRACK_KINDS, "1", false, "Test mixed valid and invalid text kinds");
90 trackDefaultConstructionTest("invalid type", "en-US", "label", VALID_AUDIO_TRACK_KINDS, "1", false, "Test invalid 'type' parameter type passed to TrackDefault constructor");
92 test(function()
94 checkConstructionFails("audio", "en-US", "label", "this is not a valid sequence", "1");
95 }, "Test invalid 'kinds' parameter type passed to TrackDefault constructor");
97 test(function()
99 var trackDefault = new TrackDefault("audio", "en-US", "label", VALID_AUDIO_TRACK_KINDS, "1");
100 var kinds = trackDefault.kinds;
101 kinds[0] = "invalid kind";
102 assert_equals(kinds[0], "invalid kind", "local kinds is updated");
103 assert_equals(VALID_AUDIO_TRACK_KINDS[0], "alternative", "local original kinds unchanged");
104 assert_array_equals(trackDefault.kinds, VALID_AUDIO_TRACK_KINDS, "trackDefault kinds unchanged");
105 }, "Test updating the retval of TrackDefault.kinds does not modify TrackDefault.kinds");
107 </script>
108 </body>
109 </html>