Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / appcache / fail-on-update-2.html
blobee856682661cdafe33dcced4da96e6b82df4c268
1 <!DOCTYPE HTML>
2 <html manifest="resources/fail-on-update-2.php">
3 <script>
4 if (window.testRunner) {
5 testRunner.dumpAsText();
6 testRunner.waitUntilDone();
9 function setManifestDeleted(state, callback)
11 var req = new XMLHttpRequest;
12 req.onreadystatechange = function() {
13 if (req.readyState == 4)
14 callback();
16 req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"));
17 req.send(null);
20 function test()
22 clearTimeout(timeoutId);
24 setManifestDeleted(true, afterDelete);
26 function afterDelete()
28 applicationCache.update();
30 // Create two subframes at different times to make hitting the race condition more likely.
31 var ifr = document.createElement("iframe");
32 ifr.setAttribute("src", 'resources/fail-on-update-2.html');
33 document.body.appendChild(ifr);
35 setTimeout(function() {
36 var ifr = document.createElement("iframe");
37 ifr.setAttribute("src", 'resources/fail-on-update-2.html');
38 document.body.appendChild(ifr);
39 }, 0);
43 var subframesLeft = 2;
44 function subframeLoaded()
46 if (!--subframesLeft) {
47 document.write('<p>SUCCESS: No crash.</p>');
48 if (window.testRunner)
49 testRunner.notifyDone();
53 function resetManifest()
55 if (applicationCache.status != applicationCache.UNCACHED && applicationCache.status != applicationCache.OBSOLETE) {
56 timeoutId = setTimeout(resetManifest, 100);
57 return;
60 setManifestDeleted(false, function() {
61 location.reload();
62 });
65 applicationCache.addEventListener('noupdate', function() { setTimeout(test, 0) }, false);
66 applicationCache.addEventListener('cached', function() { setTimeout(test, 0) }, false);
68 // If the manifest script happened to be in a wrong state, reset it.
69 var timeoutId = setTimeout(resetManifest, 100);
71 </script>
72 <p>Test for a particular incorrect assertion failure.</p>
74 </html>