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

Unified Diff: LayoutTests/http/tests/appcache/obsolete-error-events.html

Issue 217133002: AppCache error details tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Restore missing files Created 6 years, 9 months 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: LayoutTests/http/tests/appcache/obsolete-error-events.html
diff --git a/LayoutTests/http/tests/appcache/obsolete-error-events.html b/LayoutTests/http/tests/appcache/obsolete-error-events.html
new file mode 100644
index 0000000000000000000000000000000000000000..e26e89d9e89d39e5211b37f7fed7e20f87a80edc
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/obsolete-error-events.html
@@ -0,0 +1,78 @@
+<html manifest="resources/fail-on-update.php">
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+var jsTestIsAsync = true;
+description("Test that master list entries receive errors when manifest becomes obsolete.");
+
+function setManifestState(state)
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "resources/fail-on-update.php?command=" + (state), false);
+ req.send(null);
+}
+
+var eventDetailsFromFrame = null;
+function onMessage(e) {
+ eventDetailsFromFrame = e.data;
+ checkEvents();
+};
+
+var eventDetailsFromWindow = null;
+function onObsolete(e) {
+ eventDetailsFromWindow = e;
+ checkEvents();
+}
+
+// Event order is indeterminate, so wait for both to arrive.
+function checkEvents() {
+ if (!eventDetailsFromFrame || !eventDetailsFromWindow)
+ return;
+
+ shouldBeEqualToString("eventDetailsFromWindow.type", "obsolete");
+
+ shouldBeEqualToString("eventDetailsFromFrame.type", "error");
+ shouldBeEqualToString("eventDetailsFromFrame.reason", "manifest");
+ shouldBeEqualToString("eventDetailsFromFrame.url", "");
+ shouldBe("eventDetailsFromFrame.status", "404");
+
+ finishJSTest();
+}
+
+function test()
+{
+ applicationCache.onnoupdate = function() { log("Unexpected noupdate event") }
+ applicationCache.oncached = function() { log("Unexpected cached event") }
+
+ 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);
+
+ applicationCache.onobsolete = onObsolete;
+ window.onmessage = onMessage;
+}
+
+function resetManifest()
+{
+ if (applicationCache.status !== applicationCache.UNCACHED && applicationCache.status !== applicationCache.OBSOLETE) {
+ timeoutId = setTimeout(resetManifest, 100);
+ return;
+ }
+
+ setManifestState('reset');
+ location.reload();
+}
+
+applicationCache.oncached = function() {
+ clearTimeout(timeoutId);
+ test();
+};
+
+// If the manifest script happened to be in a wrong state, reset it.
+var timeoutId = setTimeout(resetManifest, 100);
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698