Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | <html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changingManifest.sjs"> |
michael@0 | 2 | <head> |
michael@0 | 3 | <title>refetch manifest 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 | |
michael@0 | 8 | <script type="text/javascript"> |
michael@0 | 9 | |
michael@0 | 10 | function finish() |
michael@0 | 11 | { |
michael@0 | 12 | OfflineTest.teardownAndFinish(); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | function failAndFinish(e) |
michael@0 | 16 | { |
michael@0 | 17 | OfflineTest.ok(false, "Unexpected event: " + e.type); |
michael@0 | 18 | finish(); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function manifestUpdated() |
michael@0 | 22 | { |
michael@0 | 23 | // Replace this manifest with a new one. |
michael@0 | 24 | |
michael@0 | 25 | // XXX: After this put, we will no longer have Cache-Control: |
michael@0 | 26 | // no-cache on the manifest, so future updates will just use the |
michael@0 | 27 | // cached manifest. |
michael@0 | 28 | |
michael@0 | 29 | // Get the initial contents of the first two files. |
michael@0 | 30 | fetcher = new OfflineCacheContents([g1SecUrl, g1HourUrl]); |
michael@0 | 31 | fetcher.fetch(function(contents) { |
michael@0 | 32 | gCacheContents = contents; |
michael@0 | 33 | |
michael@0 | 34 | // Now make sure applicationCache.update() does what we expect. |
michael@0 | 35 | applicationCache.onupdateready = OfflineTest.priv(manifestUpdatedAgain); |
michael@0 | 36 | applicationCache.onnoupdate = failAndFinish; |
michael@0 | 37 | applicationCache.oncached = failAndFinish; |
michael@0 | 38 | |
michael@0 | 39 | gGotChecking = false; |
michael@0 | 40 | gGotDownloading = false; |
michael@0 | 41 | |
michael@0 | 42 | // The changing versions give out a new version each second, |
michael@0 | 43 | // make sure it has time to grab a new version, and for the |
michael@0 | 44 | // 1-second cache timeout to pass. |
michael@0 | 45 | window.setTimeout("applicationCache.update()", 5000); |
michael@0 | 46 | }); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function replaceManifest() |
michael@0 | 50 | { |
michael@0 | 51 | // If we replace the manifest after a downloading event, the update |
michael@0 | 52 | // should fail when it revalidates the manifest at the end of the update. |
michael@0 | 53 | OfflineTest.setSJSState("changingManifest.sjs", "2"); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function cached() |
michael@0 | 57 | { |
michael@0 | 58 | OfflineTest.ok(true, "Got the expected cached event."); |
michael@0 | 59 | finish(); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function gotError() |
michael@0 | 63 | { |
michael@0 | 64 | OfflineTest.ok(true, "Got the expected error event."); |
michael@0 | 65 | |
michael@0 | 66 | // Now this update will be rescheduled, and it should succeed. |
michael@0 | 67 | applicationCache.onerror = failAndFinish; |
michael@0 | 68 | applicationCache.oncached = cached; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | if (OfflineTest.setup()) { |
michael@0 | 72 | applicationCache.onerror = gotError; |
michael@0 | 73 | applicationCache.onnoupdate = failAndFinish; |
michael@0 | 74 | |
michael@0 | 75 | applicationCache.ondownloading = replaceManifest; |
michael@0 | 76 | applicationCache.oncached = failAndFinish; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 80 | |
michael@0 | 81 | </script> |
michael@0 | 82 | |
michael@0 | 83 | </head> |
michael@0 | 84 | |
michael@0 | 85 | <body> |
michael@0 | 86 | |
michael@0 | 87 | </body> |
michael@0 | 88 | </html> |