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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/appcache/remove-cache.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/appcache/remove-cache.html b/third_party/WebKit/LayoutTests/http/tests/appcache/remove-cache.html
index d9026d4166781f35efaf96fedb53b09ba1934b59..ca45be24f7cb721ebabb02b52fdcc8170e133049 100644
--- a/third_party/WebKit/LayoutTests/http/tests/appcache/remove-cache.html
+++ b/third_party/WebKit/LayoutTests/http/tests/appcache/remove-cache.html
@@ -21,11 +21,12 @@ function log(message)
document.getElementById("result").innerHTML += message + "<br>";
}
-function setManifestDeleted(state)
+function setManifestDeleted(state, callback)
{
var req = new XMLHttpRequest;
- req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"), false);
+ req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"));
req.send(null);
+ req.onload = callback;
}
function test()
@@ -44,12 +45,14 @@ function test2()
applicationCache.onnoupdate = function() { log("Unexpected noupdate event") }
applicationCache.oncached = function() { log("Unexpected cached event") }
- setManifestDeleted(true);
- // The frame will be associated to a cache, but update will obsolete it.
- var ifr = document.createElement("iframe");
- ifr.setAttribute("src", "resources/remove-cache-frame.html");
- document.body.appendChild(ifr);
- applicationCache.onobsolete = test3;
+ setManifestDeleted(true, () => {
+ // The frame will be associated to a cache, but update will obsolete it.
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/remove-cache-frame.html");
+ document.body.appendChild(ifr);
+ applicationCache.onobsolete = test3;
+
+ });
}
function test3()
@@ -69,16 +72,16 @@ function test3()
function test4()
{
- setManifestDeleted(false);
-
- window.removeEventListener("message", test4, false);
- applicationCache.onupdateready = null;
-
- // The frame will be associated to a cache.
- var ifr = document.createElement("iframe");
- ifr.setAttribute("src", "resources/remove-cache-frame-2.html");
- document.body.appendChild(ifr);
- window.addEventListener("message", test5, false);
+ setManifestDeleted(false, () => {
+ window.removeEventListener("message", test4, false);
+ applicationCache.onupdateready = null;
+
+ // The frame will be associated to a cache.
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/remove-cache-frame-2.html");
+ document.body.appendChild(ifr);
+ window.addEventListener("message", test5, false);
+ });
}
function test5()
@@ -95,8 +98,9 @@ function resetManifest()
return;
}
- setManifestDeleted(false);
- location.reload();
+ setManifestDeleted(false, () => {
+ location.reload();
+ });
}
applicationCache.onupdateready = function() { log("Unexpected updateready event") }

Powered by Google App Engine
This is Rietveld 408576698