Async XMLHttpRequest should get access to AppCache resources stored as flat files
[WebKit-https.git] / LayoutTests / http / tests / appcache / simple-video-async.html
1 <html manifest="resources/simple-video-async.manifest">
2 <script>
3 if (window.testRunner) {
4     testRunner.dumpAsText()
5     testRunner.waitUntilDone();
6 }
7
8 function finishTest(message) {
9     document.getElementById('result').innerHTML = message;
10     testRunner.notifyDone();
11 }
12
13 function cached()
14 {
15     try {
16         var req = new XMLHttpRequest();
17         req.open("GET", "resources/fake-video.mp4");
18         req.send();
19         req.onloadend = function() {
20             if (req.getResponseHeader("Content-Type") != "video/mp4")
21                 finishTest("FAILURE: Did not get correct content type from cached resource");
22             if (req.responseText.trim() != "This is a fake video")
23                finishTest("FAILURE: Did not get correct data from cached resource");
24             finishTest("SUCCESS");
25         }            
26     } catch (e) {
27         finishTest("FAILURE: Could not load video data from cache");
28     }     
29 }
30
31 applicationCache.addEventListener('cached', cached, false);
32 applicationCache.addEventListener('noupdate', cached, false);
33
34 </script>
35 <div>This tests that the application cache works for video retrieved by async XMLHttpRequest</div>
36
37 <div id="result">FAILURE</div>
38 </html>