Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: LayoutTests/http/tests/appcache/obsolete-error-events.html

Issue 217133002: AppCache error details tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Restore missing files Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698