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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/appcache/obsolete-error-events.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/appcache/obsolete-error-events.html b/third_party/WebKit/LayoutTests/http/tests/appcache/obsolete-error-events.html
index 62571d7a8cdf60b6735c1187eee781b752d3ac87..4f5f21c3ab9d3f574fe436ae10243d9dc1979342 100644
--- a/third_party/WebKit/LayoutTests/http/tests/appcache/obsolete-error-events.html
+++ b/third_party/WebKit/LayoutTests/http/tests/appcache/obsolete-error-events.html
@@ -4,11 +4,12 @@
var jsTestIsAsync = true;
description("Test that master list entries receive errors when manifest becomes obsolete.");
-function setManifestState(state)
+function setManifestState(state, callback)
{
var req = new XMLHttpRequest;
- req.open("GET", "resources/fail-on-update.php?command=" + (state), false);
+ req.open("GET", "resources/fail-on-update.php?command=" + (state));
req.send(null);
+ req.onload = callback;
}
var eventDetailsFromFrame = null;
@@ -43,15 +44,15 @@ function test()
applicationCache.onnoupdate = function() { testFailed("Unexpected noupdate event") }
applicationCache.oncached = function() { testFailed("Unexpected cached event") }
- setManifestState('delete');
+ setManifestState('delete', () => {
+ // The frame will be associated to a cache, but update will obsolete it.
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/obsolete-error-events-frame.html");
+ document.body.appendChild(ifr);
- // The frame will be associated to a cache, but update will obsolete it.
- var ifr = document.createElement("iframe");
- ifr.setAttribute("src", "resources/obsolete-error-events-frame.html");
- document.body.appendChild(ifr);
-
- applicationCache.onobsolete = onObsolete;
- window.onmessage = onMessage;
+ applicationCache.onobsolete = onObsolete;
+ window.onmessage = onMessage;
+ });
}
function resetManifest()
@@ -61,11 +62,12 @@ function resetManifest()
return;
}
- setManifestState('reset');
- location.reload();
+ setManifestState('reset', () => {
+ location.reload();
+ });
}
-applicationCache.oncached = function() {
+applicationCache.onnoupdate = applicationCache.oncached = function() {
clearTimeout(timeoutId);
test();
};
@@ -73,6 +75,7 @@ applicationCache.oncached = function() {
// If the manifest script happened to be in a wrong state, reset it.
var timeoutId = setTimeout(resetManifest, 100);
+setTimeout(finishJSTest, 2000);
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698