Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs"> |
michael@0 | 2 | <head> |
michael@0 | 3 | <title>Cache update test</title> |
michael@0 | 4 | |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 8 | |
michael@0 | 9 | <script class="testbody" type="text/javascript"> |
michael@0 | 10 | |
michael@0 | 11 | /* |
michael@0 | 12 | * The test is checking nsIOfflineCacheUpdateService.checkForUpdate API: |
michael@0 | 13 | * - cache a manifest |
michael@0 | 14 | * - check for an update of it, expected is "no update avail" |
michael@0 | 15 | * - modify the manifest on the server |
michael@0 | 16 | * - check for an update again, expected is "update avail" |
michael@0 | 17 | * - check for an update ones again, expected is "update avail" (secondary check to probe |
michael@0 | 18 | * we didn't screw state of the manifest in the current cache with the first check) |
michael@0 | 19 | * - cache the modified manifest, new version is now in the cache |
michael@0 | 20 | * - last check for an update, expected is "no update avail" again |
michael@0 | 21 | */ |
michael@0 | 22 | |
michael@0 | 23 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 24 | |
michael@0 | 25 | var manifest = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs"; |
michael@0 | 26 | var manifestURI = Cc["@mozilla.org/network/io-service;1"] |
michael@0 | 27 | .getService(Ci.nsIIOService) |
michael@0 | 28 | .newURI(manifest, null, null); |
michael@0 | 29 | var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1'] |
michael@0 | 30 | .getService(Ci.nsIOfflineCacheUpdateService); |
michael@0 | 31 | |
michael@0 | 32 | function manifestCached() |
michael@0 | 33 | { |
michael@0 | 34 | // Run first check for an update |
michael@0 | 35 | updateService.checkForUpdate(manifestURI, 0, false, { |
michael@0 | 36 | observe: function(subject, topic, data) { |
michael@0 | 37 | OfflineTest.is(topic, "offline-cache-update-unavailable", "No update avail"); |
michael@0 | 38 | |
michael@0 | 39 | // Change the manifest content |
michael@0 | 40 | OfflineTest.setSJSState(manifest, "second"); |
michael@0 | 41 | |
michael@0 | 42 | // Check we now get notification on update ready |
michael@0 | 43 | updateService.checkForUpdate(manifestURI, 0, false, { |
michael@0 | 44 | observe: function(subject, topic, data) { |
michael@0 | 45 | OfflineTest.is(topic, "offline-cache-update-available", "Update avail (1)"); |
michael@0 | 46 | |
michael@0 | 47 | // Do the check again. We must get the same result. Double check is here |
michael@0 | 48 | // to make sure we don't overwrite any data in the cache by the check it self. |
michael@0 | 49 | updateService.checkForUpdate(manifestURI, 0, false, { |
michael@0 | 50 | observe: function(subject, topic, data) { |
michael@0 | 51 | OfflineTest.is(topic, "offline-cache-update-available", "Update avail (2)"); |
michael@0 | 52 | |
michael@0 | 53 | // Update the manifest, invokes manifestUpdated() |
michael@0 | 54 | applicationCache.onupdateready = OfflineTest.priv(manifestUpdated); |
michael@0 | 55 | applicationCache.update(); |
michael@0 | 56 | } |
michael@0 | 57 | }); |
michael@0 | 58 | } |
michael@0 | 59 | }); |
michael@0 | 60 | } |
michael@0 | 61 | }); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | function manifestUpdated() |
michael@0 | 65 | { |
michael@0 | 66 | // Check for an update after manifest has been updated |
michael@0 | 67 | updateService.checkForUpdate(manifestURI, 0, false, { |
michael@0 | 68 | observe: function(subject, topic, data) { |
michael@0 | 69 | OfflineTest.is(topic, "offline-cache-update-unavailable", "No update avail (2)"); |
michael@0 | 70 | |
michael@0 | 71 | OfflineTest.teardownAndFinish(); |
michael@0 | 72 | } |
michael@0 | 73 | }); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | if (OfflineTest.setup()) { |
michael@0 | 77 | applicationCache.onerror = OfflineTest.failEvent; |
michael@0 | 78 | applicationCache.oncached = OfflineTest.priv(manifestCached); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | </script> |
michael@0 | 82 | </head> |
michael@0 | 83 | <body> |
michael@0 | 84 | </body> |
michael@0 | 85 | </html> |