OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
5 | 5 |
6 <style> | 6 <style> |
7 video { background-color: yellow; width: 320px; height: 240px;} | 7 video { background-color: yellow; width: 320px; height: 240px;} |
8 </style> | 8 </style> |
9 <script src=../media-file.js></script> | 9 <script src=../media-file.js></script> |
| 10 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
| 11 (Please avoid writing new tests using video-test.js) --> |
10 <script src=../video-test.js></script> | 12 <script src=../video-test.js></script> |
11 <script> | 13 <script> |
12 | 14 |
13 var timer = null; | 15 var timer = null; |
14 var expectedLanguage; | 16 var expectedLanguage; |
15 var testList = | 17 var testList = |
16 { | 18 { |
17 current : -1, | 19 current : -1, |
18 tests : | 20 tests : |
19 [ | 21 [ |
20 { | 22 { |
21 description: "a track language matches one of the user's
preferred languages exactly", | 23 description: "a track language matches one of the user's
preferred languages exactly", |
22 languages : ['fr', 'en', 'jp'], | 24 languages : ['fr', 'en', 'jp'], |
23 expectedLanguage : "jp", | 25 expectedLanguage : "jp", |
24 }, | 26 }, |
25 { | 27 { |
26 description: "a track language without locale exactly ma
tches one of the user's preferred languages", | 28 description: "a track language without locale exactly ma
tches one of the user's preferred languages", |
27 languages : ['fr-CH', 'da'], | 29 languages : ['fr-CH', 'da'], |
28 expectedLanguage : "fr-CH", | 30 expectedLanguage : "fr-CH", |
29 }, | 31 }, |
30 { | 32 { |
31 description: "a track language without locale matches on
e of the user's preferred languages without locale", | 33 description: "a track language without locale matches on
e of the user's preferred languages without locale", |
32 languages : ['fr', 'es-MX'], | 34 languages : ['fr', 'es-MX'], |
33 expectedLanguage : "es-MX", | 35 expectedLanguage : "es-MX", |
34 }, | 36 }, |
35 { | 37 { |
36 description: "no track language matches any of the user'
s preferred languages", | 38 description: "no track language matches any of the user'
s preferred languages", |
37 languages : ['fa', 'ru', 'no'], | 39 languages : ['fa', 'ru', 'no'], |
38 expectedLanguage : "fa", | 40 expectedLanguage : "fa", |
39 }, | 41 }, |
40 ] | 42 ] |
41 }; | 43 }; |
42 | 44 |
43 function runNextTest() | 45 function runNextTest() |
44 { | 46 { |
45 consoleWrite(""); | 47 consoleWrite(""); |
46 testList.current++; | 48 testList.current++; |
47 if (testList.current >= testList.tests.length) { | 49 if (testList.current >= testList.tests.length) { |
48 var tracks = document.querySelectorAll('track'); | 50 var tracks = document.querySelectorAll('track'); |
49 testExpected("video.textTracks.length", tracks.length); | 51 testExpected("video.textTracks.length", tracks.length); |
50 endTest(); | 52 endTest(); |
51 return; | 53 return; |
52 } | 54 } |
53 | 55 |
54 consoleWrite("<b>Test: </b> <em>"+ testList.tests[testList.curre
nt].description + ".</em>"); | 56 consoleWrite("<b>Test: </b> <em>"+ testList.tests[testList.curre
nt].description + ".</em>"); |
55 createTrackElements(testList.tests[testList.current].languages); | 57 createTrackElements(testList.tests[testList.current].languages); |
56 } | 58 } |
57 | 59 |
58 function trackLoaded() | 60 function trackLoaded() |
59 { | 61 { |
60 consoleWrite("EVENT(load)"); | 62 consoleWrite("EVENT(load)"); |
61 | 63 |
62 // Don't log the event name because the order of the two events
in not predictable. | 64 // Don't log the event name because the order of the two events
in not predictable. |
63 track = event.target; | 65 track = event.target; |
64 testExpected("track.readyState", HTMLTrackElement.LOADED); | 66 testExpected("track.readyState", HTMLTrackElement.LOADED); |
65 testExpected("track.srclang", testList.tests[testList.current].e
xpectedLanguage); | 67 testExpected("track.srclang", testList.tests[testList.current].e
xpectedLanguage); |
66 | 68 |
67 timer = setTimeout(runNextTest, 200); | 69 timer = setTimeout(runNextTest, 200); |
68 } | 70 } |
69 | 71 |
70 function setPreferences() | 72 function setPreferences() |
71 { | 73 { |
72 if (!window.internals) { | 74 if (!window.internals) { |
73 consoleWrite("<b>** This test only works in DRT! **<" + "/b>
"); | 75 consoleWrite("<b>** This test only works in DRT! **<" + "/b>
"); |
74 return; | 76 return; |
75 } | 77 } |
76 | 78 |
77 consoleWrite("<i>**Set user preferred languages<" + "/i>"); | 79 consoleWrite("<i>**Set user preferred languages<" + "/i>"); |
78 run("internals.setUserPreferredLanguages(['jp', 'es-ES', 'en', '
fr'])"); | 80 run("internals.setUserPreferredLanguages(['jp', 'es-ES', 'en', '
fr'])"); |
79 window.internals.settings.setTextTrackKindUserPreference('captio
ns'); | 81 window.internals.settings.setTextTrackKindUserPreference('captio
ns'); |
80 } | 82 } |
81 | 83 |
82 function createTrackElement(language, src) | 84 function createTrackElement(language, src) |
83 { | 85 { |
84 var track = document.createElement('track'); | 86 var track = document.createElement('track'); |
85 track.setAttribute('kind', "captions"); | 87 track.setAttribute('kind', "captions"); |
86 track.setAttribute('src', src); | 88 track.setAttribute('src', src); |
87 track.setAttribute('srclang', language); | 89 track.setAttribute('srclang', language); |
88 track.setAttribute('onload', 'trackLoaded()'); | 90 track.setAttribute('onload', 'trackLoaded()'); |
89 video.appendChild(track); | 91 video.appendChild(track); |
90 } | 92 } |
91 | 93 |
(...skipping 18 matching lines...) Expand all Loading... |
110 } | 112 } |
111 | 113 |
112 </script> | 114 </script> |
113 </head> | 115 </head> |
114 <body onload="setup()"> | 116 <body onload="setup()"> |
115 <p>Tests that the user's preferred languages are honored.</p> | 117 <p>Tests that the user's preferred languages are honored.</p> |
116 <video> | 118 <video> |
117 </video> | 119 </video> |
118 </body> | 120 </body> |
119 </html> | 121 </html> |
OLD | NEW |