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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/appcache/remove-cache.html

Issue 2540833002: Deflake tests in http/tests/appcache/ when run in random order (Closed)
Patch Set: Rebased Created 4 years 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
OLDNEW
1 <html manifest="resources/fail-on-update.php"> 1 <html manifest="resources/fail-on-update.php">
2 <p>Test that a 404 response for manifest results in cache removal.</p> 2 <p>Test that a 404 response for manifest results in cache removal.</p>
3 <body> 3 <body>
4 <ul> 4 <ul>
5 <li>Frame 1: Manifest is still available, so a new master resource is added to t he cache. 5 <li>Frame 1: Manifest is still available, so a new master resource is added to t he cache.
6 <li>Frame 2: Manifest loading results in 404 response, so the cache group become s obsolete, and an obsolete event is dispatched (because the document in frame w as associated with a cache in the group). 6 <li>Frame 2: Manifest loading results in 404 response, so the cache group become s obsolete, and an obsolete event is dispatched (because the document in frame w as associated with a cache in the group).
7 <li>Frame 3: Manifest is still 404 - the document is never associated with a cac he. 7 <li>Frame 3: Manifest is still 404 - the document is never associated with a cac he.
8 <li>Frame 4: Manifest is now available, so the document gets associated with a c ache in a newly created group; the obsolete cache group is not affected. 8 <li>Frame 4: Manifest is now available, so the document gets associated with a c ache in a newly created group; the obsolete cache group is not affected.
9 </ul> 9 </ul>
10 <p>Should say SUCCESS:</p> 10 <p>Should say SUCCESS:</p>
11 <div id=result></div> 11 <div id=result></div>
12 12
13 <script> 13 <script>
14 if (window.testRunner) { 14 if (window.testRunner) {
15 testRunner.dumpAsText(); 15 testRunner.dumpAsText();
16 testRunner.waitUntilDone(); 16 testRunner.waitUntilDone();
17 } 17 }
18 18
19 function log(message) 19 function log(message)
20 { 20 {
21 document.getElementById("result").innerHTML += message + "<br>"; 21 document.getElementById("result").innerHTML += message + "<br>";
22 } 22 }
23 23
24 function setManifestDeleted(state) 24 function setManifestDeleted(state, callback)
25 { 25 {
26 var req = new XMLHttpRequest; 26 var req = new XMLHttpRequest;
27 req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"), false); 27 req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"));
28 req.send(null); 28 req.send(null);
29 req.onload = callback;
29 } 30 }
30 31
31 function test() 32 function test()
32 { 33 {
33 clearTimeout(timeoutId); 34 clearTimeout(timeoutId);
34 35
35 // The frame will be associated to a cache, and its main resource will be ad ded to the cache. 36 // The frame will be associated to a cache, and its main resource will be ad ded to the cache.
36 var ifr = document.createElement("iframe"); 37 var ifr = document.createElement("iframe");
37 ifr.setAttribute("src", "resources/remove-cache-frame.html"); 38 ifr.setAttribute("src", "resources/remove-cache-frame.html");
38 document.body.appendChild(ifr); 39 document.body.appendChild(ifr);
39 applicationCache.onnoupdate = test2; 40 applicationCache.onnoupdate = test2;
40 } 41 }
41 42
42 function test2() 43 function test2()
43 { 44 {
44 applicationCache.onnoupdate = function() { log("Unexpected noupdate event") } 45 applicationCache.onnoupdate = function() { log("Unexpected noupdate event") }
45 applicationCache.oncached = function() { log("Unexpected cached event") } 46 applicationCache.oncached = function() { log("Unexpected cached event") }
46 47
47 setManifestDeleted(true); 48 setManifestDeleted(true, () => {
48 // The frame will be associated to a cache, but update will obsolete it. 49 // The frame will be associated to a cache, but update will obsolete it.
49 var ifr = document.createElement("iframe"); 50 var ifr = document.createElement("iframe");
50 ifr.setAttribute("src", "resources/remove-cache-frame.html"); 51 ifr.setAttribute("src", "resources/remove-cache-frame.html");
51 document.body.appendChild(ifr); 52 document.body.appendChild(ifr);
52 applicationCache.onobsolete = test3; 53 applicationCache.onobsolete = test3;
54
55 });
53 } 56 }
54 57
55 function test3() 58 function test3()
56 { 59 {
57 applicationCache.onchecking = function() { log("Unexpected checking event af ter obsolete event") } 60 applicationCache.onchecking = function() { log("Unexpected checking event af ter obsolete event") }
58 applicationCache.onupdateready = function() { log("Unexpected updateready ev ent after obsolete event") } 61 applicationCache.onupdateready = function() { log("Unexpected updateready ev ent after obsolete event") }
59 applicationCache.onerror = function() { log("Unexpected error event after ob solete event") } 62 applicationCache.onerror = function() { log("Unexpected error event after ob solete event") }
60 applicationCache.onnoupdate = function() { log("Unexpected noupdate event af ter obsolete event") } 63 applicationCache.onnoupdate = function() { log("Unexpected noupdate event af ter obsolete event") }
61 applicationCache.oncached = function() { log("Unexpected cached event after obsolete event") } 64 applicationCache.oncached = function() { log("Unexpected cached event after obsolete event") }
62 65
63 // The frame will not be associated to a cache. 66 // The frame will not be associated to a cache.
64 var ifr = document.createElement("iframe"); 67 var ifr = document.createElement("iframe");
65 ifr.setAttribute("src", "resources/remove-cache-frame.html"); 68 ifr.setAttribute("src", "resources/remove-cache-frame.html");
66 document.body.appendChild(ifr); 69 document.body.appendChild(ifr);
67 window.addEventListener("message", test4, false); 70 window.addEventListener("message", test4, false);
68 } 71 }
69 72
70 function test4() 73 function test4()
71 { 74 {
72 setManifestDeleted(false); 75 setManifestDeleted(false, () => {
76 window.removeEventListener("message", test4, false);
77 applicationCache.onupdateready = null;
73 78
74 window.removeEventListener("message", test4, false); 79 // The frame will be associated to a cache.
75 applicationCache.onupdateready = null; 80 var ifr = document.createElement("iframe");
76 81 ifr.setAttribute("src", "resources/remove-cache-frame-2.html");
77 // The frame will be associated to a cache. 82 document.body.appendChild(ifr);
78 var ifr = document.createElement("iframe"); 83 window.addEventListener("message", test5, false);
79 ifr.setAttribute("src", "resources/remove-cache-frame-2.html"); 84 });
80 document.body.appendChild(ifr);
81 window.addEventListener("message", test5, false);
82 } 85 }
83 86
84 function test5() 87 function test5()
85 { 88 {
86 log("SUCCESS"); 89 log("SUCCESS");
87 if (window.testRunner) 90 if (window.testRunner)
88 testRunner.notifyDone(); 91 testRunner.notifyDone();
89 } 92 }
90 93
91 function resetManifest() 94 function resetManifest()
92 { 95 {
93 if (applicationCache.status != applicationCache.UNCACHED && applicationCache .status != applicationCache.OBSOLETE) { 96 if (applicationCache.status != applicationCache.UNCACHED && applicationCache .status != applicationCache.OBSOLETE) {
94 timeoutId = setTimeout(resetManifest, 100); 97 timeoutId = setTimeout(resetManifest, 100);
95 return; 98 return;
96 } 99 }
97 100
98 setManifestDeleted(false); 101 setManifestDeleted(false, () => {
99 location.reload(); 102 location.reload();
103 });
100 } 104 }
101 105
102 applicationCache.onupdateready = function() { log("Unexpected updateready event" ) } 106 applicationCache.onupdateready = function() { log("Unexpected updateready event" ) }
103 applicationCache.onnoupdate = test; 107 applicationCache.onnoupdate = test;
104 applicationCache.oncached = test; 108 applicationCache.oncached = test;
105 109
106 // If the manifest script happened to be in a wrong state, reset it. 110 // If the manifest script happened to be in a wrong state, reset it.
107 var timeoutId = setTimeout(resetManifest, 100); 111 var timeoutId = setTimeout(resetManifest, 100);
108 112
109 </script> 113 </script>
110 </body> 114 </body>
111 </html> 115 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698