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