1 <html manifest="resources/fail-on-update.php">
2 <script src="/js-test-resources/js-test.js"></script>
4 var jsTestIsAsync = true;
5 description("Test that master list entries receive errors when manifest becomes obsolete.");
7 function setManifestState(state)
9 var req = new XMLHttpRequest;
10 req.open("GET", "resources/fail-on-update.php?command=" + (state), false);
14 var eventDetailsFromFrame = null;
15 function onMessage(e) {
16 eventDetailsFromFrame = e.data;
20 var eventDetailsFromWindow = null;
21 function onObsolete(e) {
22 eventDetailsFromWindow = e;
26 // Event order is indeterminate, so wait for both to arrive.
27 function checkEvents() {
28 if (!eventDetailsFromFrame || !eventDetailsFromWindow)
31 shouldBeEqualToString("eventDetailsFromWindow.type", "obsolete");
33 shouldBeEqualToString("eventDetailsFromFrame.type", "error");
34 shouldBeEqualToString("eventDetailsFromFrame.reason", "manifest");
35 shouldBeEqualToString("eventDetailsFromFrame.url", "");
36 shouldBe("eventDetailsFromFrame.status", "404");
43 applicationCache.onnoupdate = function() { testFailed("Unexpected noupdate event") }
44 applicationCache.oncached = function() { testFailed("Unexpected cached event") }
46 setManifestState('delete');
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);
53 applicationCache.onobsolete = onObsolete;
54 window.onmessage = onMessage;
57 function resetManifest()
59 if (applicationCache.status !== applicationCache.UNCACHED && applicationCache.status !== applicationCache.OBSOLETE) {
60 timeoutId = setTimeout(resetManifest, 100);
64 setManifestState('reset');
68 applicationCache.oncached = function() {
69 clearTimeout(timeoutId);
73 // If the manifest script happened to be in a wrong state, reset it.
74 var timeoutId = setTimeout(resetManifest, 100);