OLD | NEW |
(Empty) | |
| 1 <html manifest="resources/fail-on-update.php"> |
| 2 <script src="/js-test-resources/js-test.js"></script> |
| 3 <script> |
| 4 var jsTestIsAsync = true; |
| 5 description("Test that master list entries receive errors when manifest becomes
obsolete."); |
| 6 |
| 7 function setManifestState(state) |
| 8 { |
| 9 var req = new XMLHttpRequest; |
| 10 req.open("GET", "resources/fail-on-update.php?command=" + (state), false); |
| 11 req.send(null); |
| 12 } |
| 13 |
| 14 var eventDetailsFromFrame = null; |
| 15 function onMessage(e) { |
| 16 eventDetailsFromFrame = e.data; |
| 17 checkEvents(); |
| 18 }; |
| 19 |
| 20 var eventDetailsFromWindow = null; |
| 21 function onObsolete(e) { |
| 22 eventDetailsFromWindow = e; |
| 23 checkEvents(); |
| 24 } |
| 25 |
| 26 // Event order is indeterminate, so wait for both to arrive. |
| 27 function checkEvents() { |
| 28 if (!eventDetailsFromFrame || !eventDetailsFromWindow) |
| 29 return; |
| 30 |
| 31 shouldBeEqualToString("eventDetailsFromWindow.type", "obsolete"); |
| 32 |
| 33 shouldBeEqualToString("eventDetailsFromFrame.type", "error"); |
| 34 shouldBeEqualToString("eventDetailsFromFrame.reason", "manifest"); |
| 35 shouldBeEqualToString("eventDetailsFromFrame.url", ""); |
| 36 shouldBe("eventDetailsFromFrame.status", "404"); |
| 37 |
| 38 finishJSTest(); |
| 39 } |
| 40 |
| 41 function test() |
| 42 { |
| 43 applicationCache.onnoupdate = function() { log("Unexpected noupdate event")
} |
| 44 applicationCache.oncached = function() { log("Unexpected cached event") } |
| 45 |
| 46 setManifestState('delete'); |
| 47 |
| 48 // The frame will be associated to a cache, but update will obsolete it. |
| 49 var ifr = document.createElement("iframe"); |
| 50 ifr.setAttribute("src", "resources/obsolete-error-events-frame.html"); |
| 51 document.body.appendChild(ifr); |
| 52 |
| 53 applicationCache.onobsolete = onObsolete; |
| 54 window.onmessage = onMessage; |
| 55 } |
| 56 |
| 57 function resetManifest() |
| 58 { |
| 59 if (applicationCache.status !== applicationCache.UNCACHED && applicationCach
e.status !== applicationCache.OBSOLETE) { |
| 60 timeoutId = setTimeout(resetManifest, 100); |
| 61 return; |
| 62 } |
| 63 |
| 64 setManifestState('reset'); |
| 65 location.reload(); |
| 66 } |
| 67 |
| 68 applicationCache.oncached = function() { |
| 69 clearTimeout(timeoutId); |
| 70 test(); |
| 71 }; |
| 72 |
| 73 // If the manifest script happened to be in a wrong state, reset it. |
| 74 var timeoutId = setTimeout(resetManifest, 100); |
| 75 |
| 76 </script> |
| 77 </body> |
| 78 </html> |
OLD | NEW |