|
1 <html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.cacheManifest"> |
|
2 <head> |
|
3 <title>Fallback entry 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 class="testbody" type="text/javascript"> |
|
10 |
|
11 /** |
|
12 * This tests that we fall back to the correct fallback entries when loading |
|
13 * from fallback namespaces listed in the manifest. The test is performed twice |
|
14 * to make sure that no cache entries are created for the nonexistent items." |
|
15 * That would lead to a failure to fallback, as there would always be an entry |
|
16 * in the application cache. |
|
17 */ |
|
18 |
|
19 var gStep = 1; |
|
20 var gChildLoad = false; |
|
21 var gTopWindow = null; |
|
22 |
|
23 function manifestUpdated() |
|
24 { |
|
25 fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html"; |
|
26 // Invokes load of fallback.html |
|
27 } |
|
28 |
|
29 function onFallbackLoad(fallbackIdentification) |
|
30 { |
|
31 switch (gStep) |
|
32 { |
|
33 case 001: |
|
34 OfflineTest.ok(!gChildLoad, "offline child not load before cache update"); |
|
35 gChildLoad = true; |
|
36 // no break |
|
37 case 101: |
|
38 OfflineTest.is(fallbackIdentification, 1, "fallback for namespace1/ in step " + gStep); |
|
39 |
|
40 fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html"; |
|
41 // Invokes load of fallback.html |
|
42 break; |
|
43 |
|
44 case 002: |
|
45 case 102: |
|
46 OfflineTest.is(fallbackIdentification, 1, "fallback for namespace1/, sub namespace in name of the frame in step " + gStep); |
|
47 |
|
48 fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html"; |
|
49 // Invokes load of fallback2.html |
|
50 break; |
|
51 |
|
52 case 003: |
|
53 case 103: |
|
54 OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep); |
|
55 |
|
56 fallbackFrame.location = "HTTP://MOCHI.TEST:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html"; |
|
57 // Invokes load of fallback2.html |
|
58 break; |
|
59 |
|
60 case 004: |
|
61 case 104: |
|
62 OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep); |
|
63 |
|
64 // Try opening a non-existing page as a top level document. It must |
|
65 // fall to fallbackTop.html that identifies it self as '100'. |
|
66 // Invokes load of fallbackTop.html |
|
67 gTopWindow = window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html"); |
|
68 |
|
69 break; |
|
70 |
|
71 case 005: |
|
72 // Try all over again. This checks there are no entries for non-existing |
|
73 // pages created/leaked. That would prevent fallback load. |
|
74 gStep = 100; |
|
75 |
|
76 fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html"; |
|
77 // Invokes load of fallback1.html, again, from the start |
|
78 // no break |
|
79 case 105: |
|
80 OfflineTest.is(fallbackIdentification, 100, "fallback for namespace2/, invoked by a top level document " + gStep); |
|
81 |
|
82 gTopWindow.close(); |
|
83 gTopWindow = null; |
|
84 |
|
85 break; |
|
86 } |
|
87 |
|
88 if (gStep == 105) { |
|
89 finalize(); |
|
90 return; |
|
91 } |
|
92 |
|
93 ++gStep; |
|
94 } |
|
95 |
|
96 |
|
97 function finishTest() |
|
98 { |
|
99 OfflineTest.teardownAndFinish(); |
|
100 } |
|
101 |
|
102 function finalize() |
|
103 { |
|
104 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); |
|
105 |
|
106 var entries = [ |
|
107 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html", false], |
|
108 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html", false], |
|
109 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html", false], |
|
110 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html", false] |
|
111 ]; |
|
112 OfflineTest.checkCacheEntries(entries, finishTest); |
|
113 } |
|
114 |
|
115 SimpleTest.waitForExplicitFinish(); |
|
116 |
|
117 if (OfflineTest.setup()) { |
|
118 applicationCache.onerror = OfflineTest.failEvent; |
|
119 applicationCache.onupdateready = OfflineTest.failEvent; |
|
120 applicationCache.oncached = OfflineTest.priv(manifestUpdated); |
|
121 } |
|
122 |
|
123 </script> |
|
124 |
|
125 </head> |
|
126 |
|
127 <body> |
|
128 <iframe name="fallbackFrame" src=""></iframe> |
|
129 </body> |
|
130 </html> |