|
1 <html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest"> |
|
2 <head> |
|
3 <title>identical manifest test</title> |
|
4 |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script> |
|
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
8 |
|
9 <script type="text/javascript"> |
|
10 |
|
11 var gGotChecking = false; |
|
12 var gGotDownloading = false; |
|
13 |
|
14 function finishTest() |
|
15 { |
|
16 OfflineTest.teardownAndFinish(); |
|
17 } |
|
18 |
|
19 function noUpdate() |
|
20 { |
|
21 OfflineTest.ok(gGotChecking, "Should get a checking event"); |
|
22 OfflineTest.ok(!gGotDownloading, "Should not get a downloading event"); |
|
23 |
|
24 var entries = [ |
|
25 // The document that requested the manifest should be in the cache |
|
26 [window.location.href, true], |
|
27 |
|
28 ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true], |
|
29 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true] |
|
30 ]; |
|
31 OfflineTest.checkCacheEntries(entries, finishTest); |
|
32 } |
|
33 |
|
34 function manifestUpdated() |
|
35 { |
|
36 OfflineTest.ok(gGotChecking, "Should get a checking event"); |
|
37 OfflineTest.ok(gGotDownloading, "Should get a downloading event"); |
|
38 |
|
39 var entries = [ |
|
40 // The manifest itself should be in the cache |
|
41 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true], |
|
42 |
|
43 // The document that requested the manifest should be in the cache |
|
44 [window.location.href, true], |
|
45 |
|
46 // The entries from the manifest should be in the cache |
|
47 ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true], |
|
48 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true], |
|
49 |
|
50 // The bad entries from the manifest should not be in the cache |
|
51 ["bad:/uri/invalid", false] |
|
52 ]; |
|
53 OfflineTest.checkCacheEntries(entries, manifestUpdatedContinue); |
|
54 } |
|
55 |
|
56 function manifestUpdatedContinue() |
|
57 { |
|
58 // Now make sure applicationCache.update() does what we expect. |
|
59 applicationCache.oncached = OfflineTest.failEvent; |
|
60 applicationCache.onnoupdate = OfflineTest.priv(noUpdate); |
|
61 |
|
62 gGotChecking = false; |
|
63 gGotDownloading = false; |
|
64 applicationCache.update(); |
|
65 } |
|
66 |
|
67 if (OfflineTest.setup()) { |
|
68 applicationCache.onerror = OfflineTest.failEvent; |
|
69 applicationCache.onnoupdate = OfflineTest.failEvent; |
|
70 applicationCache.onudpateready = OfflineTest.failEvent; |
|
71 |
|
72 applicationCache.onchecking = function() { gGotChecking = true; }; |
|
73 applicationCache.ondownloading = function() { gGotDownloading = true; }; |
|
74 applicationCache.oncached = OfflineTest.priv(manifestUpdated); |
|
75 } |
|
76 |
|
77 SimpleTest.waitForExplicitFinish(); |
|
78 |
|
79 </script> |
|
80 |
|
81 </head> |
|
82 |
|
83 <body> |
|
84 |
|
85 </body> |
|
86 </html> |