|
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>Bug 460353</title> |
|
4 |
|
5 <!-- |
|
6 This test checks that each iframe creates its own |
|
7 scope. Actually, we just check that it loads and updates |
|
8 its associated cache. There is no check that the cache is the |
|
9 expected one, there is no API to gain that information. |
|
10 --> |
|
11 |
|
12 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
14 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script> |
|
15 |
|
16 <script class="testbody" type="text/javascript"> |
|
17 |
|
18 var result = new Array(); |
|
19 var expectedUpdates = 3; // 2 iframes and our self |
|
20 |
|
21 applicationCache.oncached = onUpdatePassed; |
|
22 applicationCache.onnoupdate = onUpdatePassed; |
|
23 |
|
24 SpecialPowers.pushPermissions([{'type': 'offline-app', 'allow': true, 'context': document}], init); |
|
25 |
|
26 function onUpdatePassed() |
|
27 { |
|
28 if (!(--expectedUpdates)) |
|
29 SimpleTest.executeSoon(finish); |
|
30 } |
|
31 |
|
32 function init() |
|
33 { |
|
34 var iframes = document.getElementsByTagName('iframe'); |
|
35 iframes[0].src = "460353_iframe_nomanifest.html"; |
|
36 iframes[1].src = "460353_iframe_ownmanifest.html"; |
|
37 iframes[2].src = "460353_iframe_samemanifest.html"; |
|
38 } |
|
39 |
|
40 function frameOnLoad(frameid, status) |
|
41 { |
|
42 var obj = new Object(); |
|
43 result[frameid] = obj; |
|
44 |
|
45 result[frameid].load = true; |
|
46 result[frameid].cacheStatus = status; |
|
47 } |
|
48 |
|
49 function frameOnUpdate(frameid, ok, status) |
|
50 { |
|
51 result[frameid].update = true; |
|
52 result[frameid].updateOK = ok; |
|
53 result[frameid].cacheStatus = status; |
|
54 |
|
55 onUpdatePassed(); |
|
56 } |
|
57 |
|
58 function finish() |
|
59 { |
|
60 SimpleTest.ok(result["same"].load || false, "Frame with the same manifest loads"); |
|
61 SimpleTest.ok(result["same"].update || false, "Frame with the same manifest cache update notification"); |
|
62 SimpleTest.ok(result["same"].updateOK || false, "Frame with the same manifest cache update passed OK"); |
|
63 SimpleTest.is(result["same"].cacheStatus || -1, 1, "Frame with the same manifest cache status was IDLE"); |
|
64 |
|
65 SimpleTest.ok(result["diff"].load || false, "Frame with different manifest loads"); |
|
66 SimpleTest.ok(result["diff"].update || false, "Frame with different manifest cache update notification"); |
|
67 SimpleTest.ok(result["diff"].updateOK || false, "Frame with different manifest cache update passed OK"); |
|
68 SimpleTest.is(result["diff"].cacheStatus || -1, 1, "Frame with different manifest cache status was IDLE"); |
|
69 |
|
70 SimpleTest.ok(result["noman"].load || false, "Frame with no manifest loads"); |
|
71 SimpleTest.ok(result["noman"].update == undefined, "Frame with no manifest cache update didn't notify"); |
|
72 SimpleTest.ok(result["noman"].updateOK == undefined, "Frame with no manifest cache update didn't pass"); |
|
73 SimpleTest.is(result["noman"].cacheStatus || -1, -1, "Frame with no manifest cache status was undefined"); |
|
74 |
|
75 OfflineTest.waitForUpdates(function() { |
|
76 cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest"); |
|
77 cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs"); |
|
78 |
|
79 SimpleTest.finish(); |
|
80 }); |
|
81 } |
|
82 |
|
83 function cleanCache(manifestURL) |
|
84 { |
|
85 var cache = OfflineTest.getActiveCache(manifestURL); |
|
86 dump("Discarding cache for " + manifestURL + " cache=" + cache + "\n"); |
|
87 if (cache) |
|
88 cache.discard(); |
|
89 } |
|
90 |
|
91 SimpleTest.waitForExplicitFinish(); |
|
92 |
|
93 </script> |
|
94 |
|
95 <body> |
|
96 <iframe></iframe> |
|
97 <iframe></iframe> |
|
98 <iframe></iframe> |
|
99 </body> |
|
100 </html> |