OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html manifest="resources/video.manifest"> | 2 <html manifest="resources/video.manifest"> |
3 <head> | 3 <title>Test that "video" can be loaded from the application cache.</title> |
4 <title>test media in the app cache</title> | 4 <script src="../resources/testharness.js"></script> |
5 <style> | 5 <script src="../resources/testharnessreport.js"></script> |
6 video { background-color: yellow; width: 320px; height: 240px; } | 6 <script src="/media-resources/media-file.js"></script> |
7 </style> | 7 <video></video> |
8 <script src=/media-resources/media-file.js></script> | 8 <script> |
9 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 9 async_test(function(t) { |
10 (Please avoid writing new tests using video-test.js) --> | 10 applicationCache.onupdateready = t.unreached_func(); |
11 <script src=/media-resources/video-test.js></script> | 11 applicationCache.onobsolete = t.unreached_func(); |
12 <script> | 12 applicationCache.onerror = t.unreached_func(); |
13 var test; | 13 applicationCache.oncached = t.step_func(test1); |
| 14 applicationCache.onnoupdate = t.step_func(test1); |
14 | 15 |
15 function unexpectedEvent(event) | 16 video = document.querySelector("video"); |
16 { | |
17 failTest(false, '<br>Unexpected "' + event.type + '" event!!'); | |
18 } | |
19 | 17 |
20 function errorEvent() | 18 function test1() { |
21 { | 19 // Setting "src" to file specified in manifest. This file should load. |
22 consoleWrite(""); | 20 video.ondurationchange = t.step_func(test2); |
23 switch(test) | 21 video.onerror = t.unreached_func(); |
24 { | 22 video.src = "/media-resources/content/" + findMediaFile("video", "test")
; |
25 case 1: | 23 } |
26 failTest(false, "Failed loading file included in manifes
t!"); | |
27 break; | |
28 case 2: | |
29 test3() | |
30 break; | |
31 case 3: | |
32 endTest(); | |
33 break; | |
34 } | |
35 } | |
36 | 24 |
37 function durationchangeEvent() | 25 function test2() { |
38 { | 26 // Setting "src" to valid media file not in manifest. This file should f
ail to load. |
39 switch(test) | 27 video.ondurationchange = t.unreached_func(); |
40 { | 28 video.onerror = t.step_func(test3); |
41 case 1: | 29 video.src = "/media-resources/content/" + findMediaFile("audio", "silenc
e"); |
42 test2(); | 30 } |
43 break; | |
44 case 2: | |
45 failTest("<br>Loaded file NOT included in manifest!"); | |
46 break; | |
47 case 3: | |
48 failTest("<br>Loaded JavaScript file as media!"); | |
49 break; | |
50 } | |
51 } | |
52 | 31 |
53 function test3() | 32 function test3() { |
54 { | 33 // Setting "src" to non-media file that is in manifest. This file should
fail to load. |
55 consoleWrite("*** Setting 'src' to non-media file that is in man
ifest. This file should fail to load.<br>"); | 34 video.src = "/media-resources/media-file.js"; |
56 | 35 video.onerror = t.step_func_done(); |
57 test = 3; | 36 } |
58 video = document.getElementsByTagName('video')[0]; | 37 }); |
59 video.src = "/media-resources/media-file.js"; | 38 </script> |
60 } | |
61 | |
62 function test2() | |
63 { | |
64 consoleWrite("<br>*** Setting 'src' to valid media file not in m
anifest. This file should fail to load.<br>"); | |
65 | |
66 test = 2; | |
67 video = document.getElementsByTagName('video')[0]; | |
68 video.src = "/media-resources/content/" + findMediaFile("audio",
"silence"); | |
69 } | |
70 | |
71 function test1() | |
72 { | |
73 consoleWrite("*** Setting 'src' to file specified in manifest. T
his file should load.<br>"); | |
74 test = 1; | |
75 | |
76 waitForEvent('durationchange', durationchangeEvent); | |
77 waitForEvent('error', errorEvent); | |
78 | |
79 video = document.getElementsByTagName('video')[0]; | |
80 video.src = "/media-resources/content/" + findMediaFile("video",
"test"); | |
81 } | |
82 | |
83 function updateready(event) | |
84 { | |
85 applicationCache.swapCache(); | |
86 test1(); | |
87 } | |
88 | |
89 applicationCache.addEventListener("updateready", updateready, false)
; | |
90 applicationCache.addEventListener("noupdate", test1, false); | |
91 applicationCache.addEventListener("cached", test1, false); | |
92 | |
93 applicationCache.addEventListener("obsolete", unexpectedEvent, false
); | |
94 applicationCache.addEventListener("error", unexpectedEvent, false); | |
95 </script> | |
96 | |
97 </head> | |
98 <body> | |
99 | |
100 <video controls ></video> | |
101 | |
102 <p>Test that <video> can be loaded from the application cache.</p> | |
103 </body> | |
104 </html> | |
OLD | NEW |