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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/appcache/obsolete-error-events.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 <script src="/js-test-resources/js-test.js"></script> 2 <script src="/js-test-resources/js-test.js"></script>
3 <script> 3 <script>
4 var jsTestIsAsync = true; 4 var jsTestIsAsync = true;
5 description("Test that master list entries receive errors when manifest becomes obsolete."); 5 description("Test that master list entries receive errors when manifest becomes obsolete.");
6 6
7 function setManifestState(state) 7 function setManifestState(state, callback)
8 { 8 {
9 var req = new XMLHttpRequest; 9 var req = new XMLHttpRequest;
10 req.open("GET", "resources/fail-on-update.php?command=" + (state), false); 10 req.open("GET", "resources/fail-on-update.php?command=" + (state));
11 req.send(null); 11 req.send(null);
12 req.onload = callback;
12 } 13 }
13 14
14 var eventDetailsFromFrame = null; 15 var eventDetailsFromFrame = null;
15 function onMessage(e) { 16 function onMessage(e) {
16 eventDetailsFromFrame = e.data; 17 eventDetailsFromFrame = e.data;
17 checkEvents(); 18 checkEvents();
18 }; 19 };
19 20
20 var eventDetailsFromWindow = null; 21 var eventDetailsFromWindow = null;
21 function onObsolete(e) { 22 function onObsolete(e) {
(...skipping 14 matching lines...) Expand all
36 shouldBe("eventDetailsFromFrame.status", "404"); 37 shouldBe("eventDetailsFromFrame.status", "404");
37 38
38 finishJSTest(); 39 finishJSTest();
39 } 40 }
40 41
41 function test() 42 function test()
42 { 43 {
43 applicationCache.onnoupdate = function() { testFailed("Unexpected noupdate e vent") } 44 applicationCache.onnoupdate = function() { testFailed("Unexpected noupdate e vent") }
44 applicationCache.oncached = function() { testFailed("Unexpected cached event ") } 45 applicationCache.oncached = function() { testFailed("Unexpected cached event ") }
45 46
46 setManifestState('delete'); 47 setManifestState('delete', () => {
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);
47 52
48 // The frame will be associated to a cache, but update will obsolete it. 53 applicationCache.onobsolete = onObsolete;
49 var ifr = document.createElement("iframe"); 54 window.onmessage = onMessage;
50 ifr.setAttribute("src", "resources/obsolete-error-events-frame.html"); 55 });
51 document.body.appendChild(ifr);
52
53 applicationCache.onobsolete = onObsolete;
54 window.onmessage = onMessage;
55 } 56 }
56 57
57 function resetManifest() 58 function resetManifest()
58 { 59 {
59 if (applicationCache.status !== applicationCache.UNCACHED && applicationCach e.status !== applicationCache.OBSOLETE) { 60 if (applicationCache.status !== applicationCache.UNCACHED && applicationCach e.status !== applicationCache.OBSOLETE) {
60 timeoutId = setTimeout(resetManifest, 100); 61 timeoutId = setTimeout(resetManifest, 100);
61 return; 62 return;
62 } 63 }
63 64
64 setManifestState('reset'); 65 setManifestState('reset', () => {
65 location.reload(); 66 location.reload();
67 });
66 } 68 }
67 69
68 applicationCache.oncached = function() { 70 applicationCache.onnoupdate = applicationCache.oncached = function() {
69 clearTimeout(timeoutId); 71 clearTimeout(timeoutId);
70 test(); 72 test();
71 }; 73 };
72 74
73 // If the manifest script happened to be in a wrong state, reset it. 75 // If the manifest script happened to be in a wrong state, reset it.
74 var timeoutId = setTimeout(resetManifest, 100); 76 var timeoutId = setTimeout(resetManifest, 100);
75 77
78 setTimeout(finishJSTest, 2000);
76 </script> 79 </script>
77 </body> 80 </body>
78 </html> 81 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698