OLD | NEW |
| 1 <!DOCTYPE HTML> |
1 <html manifest="resources/fail-on-update-2.php"> | 2 <html manifest="resources/fail-on-update-2.php"> |
2 <script> | 3 <script> |
3 if (window.testRunner) { | 4 if (window.testRunner) { |
4 testRunner.dumpAsText(); | 5 testRunner.dumpAsText(); |
5 testRunner.waitUntilDone(); | 6 testRunner.waitUntilDone(); |
6 } | 7 } |
7 | 8 |
8 function setManifestDeleted(state) | 9 function setManifestDeleted(state, callback) |
9 { | 10 { |
10 var req = new XMLHttpRequest; | 11 var req = new XMLHttpRequest; |
11 req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete"
: "reset"), false); | 12 req.onreadystatechange = function() { |
| 13 if (req.readyState == 4) |
| 14 callback(); |
| 15 } |
| 16 req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete"
: "reset")); |
12 req.send(null); | 17 req.send(null); |
13 } | 18 } |
14 | 19 |
15 function test() | 20 function test() |
16 { | 21 { |
17 clearTimeout(timeoutId); | 22 clearTimeout(timeoutId); |
18 | 23 |
19 setManifestDeleted(true); | 24 setManifestDeleted(true, afterDelete); |
20 applicationCache.update(); | |
21 | |
22 // Create two subframes at different times to make hitting the race conditio
n more likely. | |
23 var ifr = document.createElement("iframe"); | |
24 ifr.setAttribute("src", 'resources/fail-on-update-2.html'); | |
25 document.body.appendChild(ifr); | |
26 | 25 |
27 setTimeout(function() { | 26 function afterDelete() |
| 27 { |
| 28 applicationCache.update(); |
| 29 |
| 30 // Create two subframes at different times to make hitting the race cond
ition more likely. |
28 var ifr = document.createElement("iframe"); | 31 var ifr = document.createElement("iframe"); |
29 ifr.setAttribute("src", 'resources/fail-on-update-2.html'); | 32 ifr.setAttribute("src", 'resources/fail-on-update-2.html'); |
30 document.body.appendChild(ifr); | 33 document.body.appendChild(ifr); |
31 }, 0); | 34 |
| 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); |
| 40 } |
32 } | 41 } |
33 | 42 |
34 var subframesLeft = 2; | 43 var subframesLeft = 2; |
35 function subframeLoaded() | 44 function subframeLoaded() |
36 { | 45 { |
37 if (!--subframesLeft) { | 46 if (!--subframesLeft) { |
38 document.write('<p>SUCCESS: No crash.</p>'); | 47 document.write('<p>SUCCESS: No crash.</p>'); |
39 if (window.testRunner) | 48 if (window.testRunner) |
40 testRunner.notifyDone(); | 49 testRunner.notifyDone(); |
41 } | 50 } |
42 } | 51 } |
43 | 52 |
44 function resetManifest() | 53 function resetManifest() |
45 { | 54 { |
46 if (applicationCache.status != applicationCache.UNCACHED && applicationCache
.status != applicationCache.OBSOLETE) { | 55 if (applicationCache.status != applicationCache.UNCACHED && applicationCache
.status != applicationCache.OBSOLETE) { |
47 timeoutId = setTimeout(resetManifest, 100); | 56 timeoutId = setTimeout(resetManifest, 100); |
48 return; | 57 return; |
49 } | 58 } |
50 | 59 |
51 setManifestDeleted(false); | 60 setManifestDeleted(false, function() { |
52 location.reload(); | 61 location.reload(); |
| 62 }); |
53 } | 63 } |
54 | 64 |
55 applicationCache.addEventListener('noupdate', function() { setTimeout(test, 0) }
, false); | 65 applicationCache.addEventListener('noupdate', function() { setTimeout(test, 0) }
, false); |
56 applicationCache.addEventListener('cached', function() { setTimeout(test, 0) },
false); | 66 applicationCache.addEventListener('cached', function() { setTimeout(test, 0) },
false); |
57 | 67 |
58 // If the manifest script happened to be in a wrong state, reset it. | 68 // If the manifest script happened to be in a wrong state, reset it. |
59 var timeoutId = setTimeout(resetManifest, 100); | 69 var timeoutId = setTimeout(resetManifest, 100); |
60 | 70 |
61 </script> | 71 </script> |
62 <p>Test for a particular incorrect assertion failure.</p> | 72 <p>Test for a particular incorrect assertion failure.</p> |
63 | 73 |
64 </html> | 74 </html> |
OLD | NEW |