Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / appcache / top-frame-3.html
blob1032d72a5b08fd50daa1f8ba5a674e4e7a2a52f2
1 <html manifest="resources/subframes-3.manifest">
2 <body>
3 <p>Test that a subframe with manifest that matches top frame manifest works correctly.</p>
4 <p>In this case, the subframe resource is NOT listed in manifest explicitly.</p>
5 <p>Should say SUCCESS:</p>
6 <div id=result></div>
8 <script>
9 if (window.testRunner) {
10 testRunner.dumpAsText();
11 testRunner.waitUntilDone();
14 function log(message)
16 document.getElementById("result").innerHTML += message + "<br>";
19 function debug(message)
21 // If running manually in the browser, print the sequence of events.
22 if (!window.testRunner)
23 log(message);
26 var receivedExpectedMessage = false;
27 var receivedCheckingEventsCounter = 0;
28 var receivedNoupdateEventsCounter = 0;
30 function checkDone()
32 if (receivedExpectedMessage && receivedCheckingEventsCounter == 2 && receivedNoupdateEventsCounter == 2) {
33 log("SUCCESS");
34 if (window.testRunner)
35 testRunner.notifyDone();
39 function test()
41 applicationCache.onnoupdate = null;
42 applicationCache.oncached = null;
44 // When a new main resource is associated with the cache, an update should be started.
45 applicationCache.onchecking = function() { debug("checking"); receivedCheckingEventsCounter++; checkDone() }
46 applicationCache.onnoupdate = function() { debug("noupdate"); receivedNoupdateEventsCounter++; checkDone(); }
48 var ifr = document.createElement("iframe");
49 ifr.setAttribute("src", "resources/subframe-3.html");
50 document.body.appendChild(ifr);
53 function test2()
55 window.removeEventListener("message", test2, false);
56 window.addEventListener("message", test3, false);
58 // Add an identical frame, to test that loading its resources from appcache works.
59 var ifr = document.createElement("iframe");
60 ifr.setAttribute("src", "resources/subframe-3.html");
61 document.body.appendChild(ifr);
64 function test3()
66 debug("message");
67 receivedExpectedMessage = true;
68 checkDone();
71 applicationCache.onnoupdate = function() { test() }
72 applicationCache.oncached = function() { test() }
74 applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
75 applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
77 window.addEventListener("message", test2, false);
79 </script>
80 </body>
81 </html>