summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-02-25 10:58:37 +0000
committerSteve Block <steveblock@google.com>2010-02-25 11:17:52 +0000
commitcfb0617749a64f2e177386b030d46007b8c4b179 (patch)
tree033b0b4e1b1eaa96831b52fc1ec6675132f33035 /LayoutTests/http/tests
parent4175d59b46f96005f0c64978b1a94e3fe60f1e8e (diff)
downloadexternal_webkit-cfb0617749a64f2e177386b030d46007b8c4b179.zip
external_webkit-cfb0617749a64f2e177386b030d46007b8c4b179.tar.gz
external_webkit-cfb0617749a64f2e177386b030d46007b8c4b179.tar.bz2
Adds layout tests for HTML5 features
The following layout tests should all pass on Android, as they are for recently implemented HTML5 features ... - fast/dom/Geolocation - storage - http/tests/appcache This change adds these tests to the Android tree, at the current WebKit revision r54731. This is so that we can easily keep track of which tests should always be green, and so that we can add Android-specific test results. We also add the following paths ... - fast/js/resources - used by the Geolocation tests - http/conf - used by the Appcache tests Tests that are currently failing are added to the DumpRenderTree skipped list temporarily, to keep all tests green. Change-Id: Id96c05e3746ed64e4e4c40c99567b8def688f90a
Diffstat (limited to 'LayoutTests/http/tests')
-rw-r--r--LayoutTests/http/tests/appcache/404-manifest-expected.txt4
-rw-r--r--LayoutTests/http/tests/appcache/404-manifest.html59
-rw-r--r--LayoutTests/http/tests/appcache/404-resource-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/404-resource.html39
-rw-r--r--LayoutTests/http/tests/appcache/access-via-redirect-expected.txt3
-rw-r--r--LayoutTests/http/tests/appcache/access-via-redirect.php7
-rw-r--r--LayoutTests/http/tests/appcache/auth-expected.txt5
-rw-r--r--LayoutTests/http/tests/appcache/auth.html28
-rw-r--r--LayoutTests/http/tests/appcache/crash-when-navigating-away-then-back-expected.txt2
-rw-r--r--LayoutTests/http/tests/appcache/crash-when-navigating-away-then-back.html27
-rw-r--r--LayoutTests/http/tests/appcache/cyrillic-uri-expected.txt13
-rw-r--r--LayoutTests/http/tests/appcache/cyrillic-uri.html82
-rw-r--r--LayoutTests/http/tests/appcache/deferred-events-delete-while-raising-expected.txt4
-rw-r--r--LayoutTests/http/tests/appcache/deferred-events-delete-while-raising.html35
-rw-r--r--LayoutTests/http/tests/appcache/deferred-events-expected.txt2
-rw-r--r--LayoutTests/http/tests/appcache/deferred-events.html24
-rw-r--r--LayoutTests/http/tests/appcache/destroyed-frame-expected.txt5
-rw-r--r--LayoutTests/http/tests/appcache/destroyed-frame.html52
-rw-r--r--LayoutTests/http/tests/appcache/detached-iframe-expected.txt3
-rw-r--r--LayoutTests/http/tests/appcache/detached-iframe.html15
-rw-r--r--LayoutTests/http/tests/appcache/different-origin-manifest-expected.txt3
-rw-r--r--LayoutTests/http/tests/appcache/different-origin-manifest.html36
-rw-r--r--LayoutTests/http/tests/appcache/different-scheme-expected.txt3
-rw-r--r--LayoutTests/http/tests/appcache/different-scheme.html28
-rw-r--r--LayoutTests/http/tests/appcache/disabled-expected.txt4
-rw-r--r--LayoutTests/http/tests/appcache/disabled.html51
-rw-r--r--LayoutTests/http/tests/appcache/dynamic-entries-no-cache-expected.txt27
-rw-r--r--LayoutTests/http/tests/appcache/dynamic-entries-no-cache.html-disabled119
-rw-r--r--LayoutTests/http/tests/appcache/empty-manifest-expected.txt2
-rw-r--r--LayoutTests/http/tests/appcache/empty-manifest.html23
-rw-r--r--LayoutTests/http/tests/appcache/fail-on-update-expected.txt1
-rw-r--r--LayoutTests/http/tests/appcache/fail-on-update.html47
-rw-r--r--LayoutTests/http/tests/appcache/fallback-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/fallback.html171
-rw-r--r--LayoutTests/http/tests/appcache/foreign-iframe-main-expected.txt10
-rw-r--r--LayoutTests/http/tests/appcache/foreign-iframe-main.html39
-rw-r--r--LayoutTests/http/tests/appcache/idempotent-update-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/idempotent-update.html56
-rw-r--r--LayoutTests/http/tests/appcache/local-content-expected.txt7
-rw-r--r--LayoutTests/http/tests/appcache/local-content.html51
-rw-r--r--LayoutTests/http/tests/appcache/main-resource-hash-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/main-resource-hash.html51
-rw-r--r--LayoutTests/http/tests/appcache/manifest-containing-itself-expected.txt2
-rw-r--r--LayoutTests/http/tests/appcache/manifest-containing-itself.html24
-rw-r--r--LayoutTests/http/tests/appcache/manifest-parsing-expected.txt4
-rw-r--r--LayoutTests/http/tests/appcache/manifest-parsing.html66
-rw-r--r--LayoutTests/http/tests/appcache/manifest-redirect-2-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/manifest-redirect-2.html40
-rw-r--r--LayoutTests/http/tests/appcache/manifest-redirect-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/manifest-redirect.html40
-rw-r--r--LayoutTests/http/tests/appcache/manifest-with-empty-file-expected.txt2
-rw-r--r--LayoutTests/http/tests/appcache/manifest-with-empty-file.html21
-rw-r--r--LayoutTests/http/tests/appcache/max-size-expected.txt4
-rw-r--r--LayoutTests/http/tests/appcache/max-size.html28
-rw-r--r--LayoutTests/http/tests/appcache/navigating-away-while-cache-attempt-in-progress-expected.txt2
-rw-r--r--LayoutTests/http/tests/appcache/navigating-away-while-cache-attempt-in-progress.html21
-rw-r--r--LayoutTests/http/tests/appcache/non-html-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/non-html.xhtml103
-rw-r--r--LayoutTests/http/tests/appcache/offline-access-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/offline-access.html57
-rw-r--r--LayoutTests/http/tests/appcache/online-whitelist-expected.txt4
-rw-r--r--LayoutTests/http/tests/appcache/online-whitelist.html77
-rw-r--r--LayoutTests/http/tests/appcache/reload-expected.txt8
-rw-r--r--LayoutTests/http/tests/appcache/reload.html40
-rw-r--r--LayoutTests/http/tests/appcache/remove-cache-expected.txt10
-rw-r--r--LayoutTests/http/tests/appcache/remove-cache.html111
-rw-r--r--LayoutTests/http/tests/appcache/resource-redirect-2-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/resource-redirect-2.html40
-rw-r--r--LayoutTests/http/tests/appcache/resource-redirect-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/resource-redirect.html40
-rw-r--r--LayoutTests/http/tests/appcache/resources/.htaccess5
-rw-r--r--LayoutTests/http/tests/appcache/resources/404-resource.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/abe.pngbin0 -> 12242 bytes
-rw-r--r--LayoutTests/http/tests/appcache/resources/access-via-redirect.html46
-rw-r--r--LayoutTests/http/tests/appcache/resources/access-via-redirect.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/auth/iframe.php16
-rw-r--r--LayoutTests/http/tests/appcache/resources/auth/manifest.php12
-rw-r--r--LayoutTests/http/tests/appcache/resources/auth/setup.php10
-rw-r--r--LayoutTests/http/tests/appcache/resources/auth/subresource.php10
-rw-r--r--LayoutTests/http/tests/appcache/resources/counter.php23
-rw-r--r--LayoutTests/http/tests/appcache/resources/crash-when-navigating-away-then-back.html22
-rw-r--r--LayoutTests/http/tests/appcache/resources/crash-when-navigating-away-then-back.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/cyrillic-uri-form.html28
-rw-r--r--LayoutTests/http/tests/appcache/resources/cyrillic-uri.manifest10
-rw-r--r--LayoutTests/http/tests/appcache/resources/different-scheme.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/empty.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/empty.txt0
-rw-r--r--LayoutTests/http/tests/appcache/resources/fail-on-update.php38
-rw-r--r--LayoutTests/http/tests/appcache/resources/fallback-redirect.php8
-rw-r--r--LayoutTests/http/tests/appcache/resources/fallback.manifest5
-rw-r--r--LayoutTests/http/tests/appcache/resources/foreign-iframe-subresource.js1
-rw-r--r--LayoutTests/http/tests/appcache/resources/foreign-iframe.html4
-rw-r--r--LayoutTests/http/tests/appcache/resources/foreign-iframe.manifest4
-rw-r--r--LayoutTests/http/tests/appcache/resources/idempotent-update.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/intercept/.htaccess2
-rw-r--r--LayoutTests/http/tests/appcache/resources/local-content.manifest4
-rw-r--r--LayoutTests/http/tests/appcache/resources/main-resource-hash-frame.html27
-rw-r--r--LayoutTests/http/tests/appcache/resources/main-resource-hash-frame.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/manifest-containing-itself.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/manifest-parsing.manifest6
-rw-r--r--LayoutTests/http/tests/appcache/resources/manifest-redirect-2.php7
-rw-r--r--LayoutTests/http/tests/appcache/resources/manifest-redirect.php7
-rw-r--r--LayoutTests/http/tests/appcache/resources/manifest-with-empty-file.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/maxsize.manifest3
-rw-r--r--LayoutTests/http/tests/appcache/resources/navigating-away-while-cache-attempt-in-progress.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/non-html.manifest8
-rw-r--r--LayoutTests/http/tests/appcache/resources/not-in-cache.txt1
-rw-r--r--LayoutTests/http/tests/appcache/resources/offline-access-frame.html30
-rw-r--r--LayoutTests/http/tests/appcache/resources/offline-access.js18
-rw-r--r--LayoutTests/http/tests/appcache/resources/offline-access.manifest5
-rw-r--r--LayoutTests/http/tests/appcache/resources/online-whitelist.manifest14
-rw-r--r--LayoutTests/http/tests/appcache/resources/print-uri.php7
-rw-r--r--LayoutTests/http/tests/appcache/resources/reload-iframe.html21
-rw-r--r--LayoutTests/http/tests/appcache/resources/reload-iframe.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/remove-cache-frame-2.html37
-rw-r--r--LayoutTests/http/tests/appcache/resources/remove-cache-frame.html64
-rw-r--r--LayoutTests/http/tests/appcache/resources/resource-redirect-2.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/resource-redirect-2.php7
-rw-r--r--LayoutTests/http/tests/appcache/resources/resource-redirect.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/resource-redirect.php7
-rw-r--r--LayoutTests/http/tests/appcache/resources/simple.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/simple.txt1
-rw-r--r--LayoutTests/http/tests/appcache/resources/slow-resource.php3
-rw-r--r--LayoutTests/http/tests/appcache/resources/subframe-1.html7
-rw-r--r--LayoutTests/http/tests/appcache/resources/subframe-2.html11
-rw-r--r--LayoutTests/http/tests/appcache/resources/subframe-3.html26
-rw-r--r--LayoutTests/http/tests/appcache/resources/subframe-4.html26
-rw-r--r--LayoutTests/http/tests/appcache/resources/subframes-1.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/subframes-2.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/subframes-3.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/subframes-4.manifest2
-rw-r--r--LayoutTests/http/tests/appcache/resources/uncacheable-resource.php13
-rw-r--r--LayoutTests/http/tests/appcache/resources/versioned-manifest.php37
-rw-r--r--LayoutTests/http/tests/appcache/resources/whitelist-wildcard.manifest3
-rw-r--r--LayoutTests/http/tests/appcache/resources/wrong-content-type.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/wrong-signature-2.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/wrong-signature.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/xhr-foreign-resource-2.manifest1
-rw-r--r--LayoutTests/http/tests/appcache/resources/xhr-foreign-resource-frame.html36
-rw-r--r--LayoutTests/http/tests/appcache/resources/xhr-foreign-resource.manifest3
-rw-r--r--LayoutTests/http/tests/appcache/simple-expected.txt2
-rw-r--r--LayoutTests/http/tests/appcache/simple.html55
-rw-r--r--LayoutTests/http/tests/appcache/top-frame-1-expected.txt8
-rw-r--r--LayoutTests/http/tests/appcache/top-frame-1.html38
-rw-r--r--LayoutTests/http/tests/appcache/top-frame-2-expected.txt7
-rw-r--r--LayoutTests/http/tests/appcache/top-frame-2.html42
-rw-r--r--LayoutTests/http/tests/appcache/top-frame-3-expected.txt10
-rw-r--r--LayoutTests/http/tests/appcache/top-frame-3.html60
-rw-r--r--LayoutTests/http/tests/appcache/top-frame-4-expected.txt10
-rw-r--r--LayoutTests/http/tests/appcache/top-frame-4.html60
-rw-r--r--LayoutTests/http/tests/appcache/update-cache-expected.txt10
-rw-r--r--LayoutTests/http/tests/appcache/update-cache.html69
-rw-r--r--LayoutTests/http/tests/appcache/whitelist-wildcard-expected.txt3
-rw-r--r--LayoutTests/http/tests/appcache/whitelist-wildcard.html29
-rw-r--r--LayoutTests/http/tests/appcache/wrong-content-type-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/wrong-content-type.html40
-rw-r--r--LayoutTests/http/tests/appcache/wrong-signature-2-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/wrong-signature-2.html40
-rw-r--r--LayoutTests/http/tests/appcache/wrong-signature-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/wrong-signature.html40
-rw-r--r--LayoutTests/http/tests/appcache/xhr-foreign-resource-expected.txt6
-rw-r--r--LayoutTests/http/tests/appcache/xhr-foreign-resource.html79
162 files changed, 3284 insertions, 0 deletions
diff --git a/LayoutTests/http/tests/appcache/404-manifest-expected.txt b/LayoutTests/http/tests/appcache/404-manifest-expected.txt
new file mode 100644
index 0000000..b047077
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/404-manifest-expected.txt
@@ -0,0 +1,4 @@
+Test that subresources can be loaded if manifest is not available. Should say SUCCESS.
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/404-manifest.html b/LayoutTests/http/tests/appcache/404-manifest.html
new file mode 100644
index 0000000..9b9bd30
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/404-manifest.html
@@ -0,0 +1,59 @@
+<html manifest="does-not-exist.manifest">
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function unexpectedEvent(name)
+{
+ log("FAILURE: Unexpected " + name + " event.");
+}
+
+applicationCache.addEventListener('noupdate', function() { unexpectedEvent("noupdate") }, false);
+applicationCache.addEventListener('downloading', function() { unexpectedEvent("downloading") }, false);
+applicationCache.addEventListener('progress', function() { unexpectedEvent("progress") }, false);
+applicationCache.addEventListener('updateready', function() { unexpectedEvent("updateready") }, false);
+applicationCache.addEventListener('cached', function() { unexpectedEvent("cached") }, false);
+applicationCache.addEventListener('obsolete', function() { unexpectedEvent("obsolete") }, false);
+
+function test()
+{
+ if (!gotCheckingEvent)
+ log("FAILURE: Did not get a checking event");
+ if (window.applicationCache.status)
+ log("FAILURE: Cache status is not UNCACHED, " + window.applicationCache.status);
+
+ // The manifest failed to load, so there should be no cache, and subresources should be loaded normally.
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", "resources/simple.txt", false);
+ req.send();
+
+ if (req.responseText == 'Hello, World!')
+ log("SUCCESS");
+ else
+ log("FAILURE: Did not get expected response data.");
+ } catch (e) {
+ log("FAILURE: Could not load data.");
+ }
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+var gotCheckingEvent = false;
+applicationCache.addEventListener('checking', function() { gotCheckingEvent = true; }, false);
+
+applicationCache.addEventListener('error', function() { test() }, false);
+
+</script>
+<p>Test that subresources can be loaded if manifest is not available. Should say SUCCESS.</p>
+
+<div id=result></div>
+</html>
diff --git a/LayoutTests/http/tests/appcache/404-resource-expected.txt b/LayoutTests/http/tests/appcache/404-resource-expected.txt
new file mode 100644
index 0000000..a8e5dea
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/404-resource-expected.txt
@@ -0,0 +1,6 @@
+Test that a missing explicit resource makes caching fail.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/404-resource.html b/LayoutTests/http/tests/appcache/404-resource.html
new file mode 100644
index 0000000..5439b8f
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/404-resource.html
@@ -0,0 +1,39 @@
+<html manifest="resources/404-resource.manifest">
+<body>
+<p>Test that a missing explicit resource makes caching fail.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function unexpectedCallback(eventName)
+{
+ log("FAIL: An unexpected " + eventName + " event was dispatched on window.applicationCache.");
+}
+
+function test()
+{
+ if (applicationCache.status == applicationCache.UNCACHED)
+ log("SUCCESS");
+ else
+ log("FAILURE: cache status is not uncached: " + applicationCache.status);
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', function() { unexpectedCallback("cached"); cacheCallback() }, false);
+applicationCache.addEventListener('noupdate', function() { unexpectedCallback("noupdate"); cacheCallback() }, false);
+applicationCache.addEventListener('error', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/access-via-redirect-expected.txt b/LayoutTests/http/tests/appcache/access-via-redirect-expected.txt
new file mode 100644
index 0000000..8107c5f
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/access-via-redirect-expected.txt
@@ -0,0 +1,3 @@
+This tests that the start of redirect chain doesn't get into an application cache if the end of the chain has a manifest.
+
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/access-via-redirect.php b/LayoutTests/http/tests/appcache/access-via-redirect.php
new file mode 100644
index 0000000..b0a61b0
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/access-via-redirect.php
@@ -0,0 +1,7 @@
+<?php
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header('HTTP/1.1 307 Temporary Redirect');
+header('Location: resources/access-via-redirect.html');
+?>
diff --git a/LayoutTests/http/tests/appcache/auth-expected.txt b/LayoutTests/http/tests/appcache/auth-expected.txt
new file mode 100644
index 0000000..7ec3f83
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/auth-expected.txt
@@ -0,0 +1,5 @@
+Test that appcache works with authentication. Should say SUCCESS:
+
+SUCCESS
+
+
diff --git a/LayoutTests/http/tests/appcache/auth.html b/LayoutTests/http/tests/appcache/auth.html
new file mode 100644
index 0000000..27b0ba6
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/auth.html
@@ -0,0 +1,28 @@
+<body>
+<p>Test that appcache works with authentication. Should say SUCCESS:</p>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+// Store authentication credentials.
+var req = new XMLHttpRequest;
+req.open("GET", "resources/auth/setup.php", false, "login", "pasword");
+req.send();
+
+var ifr = document.createElement("iframe");
+ifr.setAttribute("src", "resources/auth/iframe.php");
+document.body.appendChild(ifr);
+
+function success()
+{
+ var text = document.createElement("p");
+ text.appendChild(document.createTextNode("SUCCESS"));
+ document.body.replaceChild(text, document.getElementsByTagName("iframe")[0]);
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+</script>
+</body>
diff --git a/LayoutTests/http/tests/appcache/crash-when-navigating-away-then-back-expected.txt b/LayoutTests/http/tests/appcache/crash-when-navigating-away-then-back-expected.txt
new file mode 100644
index 0000000..0ad96dc
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/crash-when-navigating-away-then-back-expected.txt
@@ -0,0 +1,2 @@
+This tests that loading a page with a manifest, navigating away from the page, and then back does not cause a crash.
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/crash-when-navigating-away-then-back.html b/LayoutTests/http/tests/appcache/crash-when-navigating-away-then-back.html
new file mode 100644
index 0000000..5b1fd9b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/crash-when-navigating-away-then-back.html
@@ -0,0 +1,27 @@
+<html>
+<script>
+function openWindow()
+{
+ window.open('resources/crash-when-navigating-away-then-back.html')
+}
+
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+ layoutTestController.setCanOpenWindows();
+} else {
+ document.write('<div id="manual-instructions">Click <a href="javascript:openWindow()">this link</a> twice. A window should open and close twice without crashing.</div>')
+}
+
+function closedWindow()
+{
+ if (window.layoutTestController)
+ setTimeout(openWindow, 100);
+}
+
+</script>
+<body onload="if (window.layoutTestController) openWindow()">
+<div>This tests that loading a page with a manifest, navigating away from the page, and then back does not cause a crash.</div>
+<div id="result">FAILURE - test not completed</div>
+</html>
+</div>
diff --git a/LayoutTests/http/tests/appcache/cyrillic-uri-expected.txt b/LayoutTests/http/tests/appcache/cyrillic-uri-expected.txt
new file mode 100644
index 0000000..3c3e640
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/cyrillic-uri-expected.txt
@@ -0,0 +1,13 @@
+Test that non-ASCII URIs work correctly in cache manifests.
+
+Should be a series of PASS messages, followed with DONE.
+
+PASS: resources/intercept/cached-Проверка
+PASS: resources/intercept/cached-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0
+PASS: resources/intercept/cached2-Проверка
+PASS: resources/intercept/cached2-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0
+PASS: resources/intercept/network-Проверка-PASS
+PASS: resources/intercept/network-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0-PASS
+PASS: resources/does-not-exist-Проверка
+DONE
+
diff --git a/LayoutTests/http/tests/appcache/cyrillic-uri.html b/LayoutTests/http/tests/appcache/cyrillic-uri.html
new file mode 100644
index 0000000..c86a261
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/cyrillic-uri.html
@@ -0,0 +1,82 @@
+<html manifest="resources/cyrillic-uri.manifest">
+<head>
+<meta charset="koi8-r">
+</head>
+<body>
+<p>Test that non-ASCII URIs work correctly in cache manifests.</p>
+<p>Should be a series of PASS messages, followed with DONE.</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function load(url)
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", url, false);
+ req.send("");
+ return req.responseText;
+}
+
+function canLoad(url)
+{
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", url, false);
+ req.send("");
+ return true;
+ } catch (ex) {
+ return false;
+ }
+}
+
+function shouldBeLoadable(url)
+{
+ log((canLoad(url) ? "PASS: " : "FAIL: ") + url);
+}
+
+function test()
+{
+ // Path is always UTF-8.
+ shouldBeLoadable("resources/intercept/cached-ðÒÏ×ÅÒËÁ");
+ shouldBeLoadable("resources/intercept/cached-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0");
+ shouldBeLoadable("resources/intercept/cached2-ðÒÏ×ÅÒËÁ");
+ shouldBeLoadable("resources/intercept/cached2-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0");
+ shouldBeLoadable("resources/intercept/network-ðÒÏ×ÅÒËÁ-PASS");
+ shouldBeLoadable("resources/intercept/network-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0-PASS");
+ shouldBeLoadable("resources/does-not-exist-ðÒÏ×ÅÒËÁ");
+
+ // To test encodings other than UTF-8, we need to simulate form submission (for XHR, Firefox
+ // always uses UTF-8, even in query part).
+ applicationCache.onnoupdate = null;
+ applicationCache.oncached = null;
+ window.addEventListener("message", frameDone, false);
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/cyrillic-uri-form.html");
+ document.body.appendChild(ifr);
+}
+
+function frameDone(evt)
+{
+ log("DONE");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.onnoupdate = function() { test() }
+applicationCache.oncached = function() { test() }
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/deferred-events-delete-while-raising-expected.txt b/LayoutTests/http/tests/appcache/deferred-events-delete-while-raising-expected.txt
new file mode 100644
index 0000000..8e41eb6
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/deferred-events-delete-while-raising-expected.txt
@@ -0,0 +1,4 @@
+Test the destruction of an iframe while deferred events are being raised does not crash the system.
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/deferred-events-delete-while-raising.html b/LayoutTests/http/tests/appcache/deferred-events-delete-while-raising.html
new file mode 100644
index 0000000..902d3a8
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/deferred-events-delete-while-raising.html
@@ -0,0 +1,35 @@
+<html manifest="THIS_FILE_DOES_NOT_EXIST.manifest">
+<head>
+ <script src="THIS_FILE_DOES_NOT_EXIST.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ var isParentFrame = window == window.top;
+
+ if (isParentFrame) {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+ }
+
+ window.onmessage = function() {
+ document.getElementById('result').innerHTML = "SUCCESS";
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+ } else {
+ window.applicationCache.onchecking = function() {
+ parent.postMessage("hello", "*");
+ parent.killChildFrame();
+ }
+ }
+
+ function killChildFrame() {
+ document.body.removeChild(document.getElementsByTagName("iframe")[0]);
+ }
+ </script>
+</head>
+<body>
+<p>Test the destruction of an iframe while deferred events are being raised does not crash the system.</p>
+<div id="result">FAILURE</div>
+<iframe src="deferred-events-delete-while-raising.html"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/deferred-events-expected.txt b/LayoutTests/http/tests/appcache/deferred-events-expected.txt
new file mode 100644
index 0000000..45af0af
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/deferred-events-expected.txt
@@ -0,0 +1,2 @@
+Test that AppicationCache events are deferred until after onload has been fired.
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/deferred-events.html b/LayoutTests/http/tests/appcache/deferred-events.html
new file mode 100644
index 0000000..ba9cf83
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/deferred-events.html
@@ -0,0 +1,24 @@
+<html manifest="THIS_FILE_DOES_NOT_EXIST.manifest">
+<head>
+ <script type="text/javascript">
+ var onloadHasBeenCalled = false;
+
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+ }
+
+ window.applicationCache.onchecking = function() {
+ if (onloadHasBeenCalled)
+ document.getElementById('result').innerHTML = "SUCCESS"
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+ </script>
+ <script src="THIS_FILE_DOES_NOT_EXIST.js" type="text/javascript"></script>
+</head>
+<body onload="onloadHasBeenCalled = true">
+Test that AppicationCache events are deferred until after onload has been fired.
+<div id="result">FAILURE</div>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/destroyed-frame-expected.txt b/LayoutTests/http/tests/appcache/destroyed-frame-expected.txt
new file mode 100644
index 0000000..7050859
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/destroyed-frame-expected.txt
@@ -0,0 +1,5 @@
+Test for bug 33813: Crash when using DOMApplicationCache from a destroyed frame.
+
+PASS if didn't crash.
+
+
diff --git a/LayoutTests/http/tests/appcache/destroyed-frame.html b/LayoutTests/http/tests/appcache/destroyed-frame.html
new file mode 100644
index 0000000..c1dd731
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/destroyed-frame.html
@@ -0,0 +1,52 @@
+<body onload="test()">
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=33813">bug 33813</a>: Crash when using DOMApplicationCache from a destroyed frame.</p>
+<p>PASS if didn't crash.</p>
+<iframe src="about:blank"></iframe>
+
+<script>
+
+function gc()
+{
+ if (window.GCController)
+ return GCController.collect();
+
+ for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
+ var s = new String("");
+ }
+}
+
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+var ifrCache;
+
+function test()
+{
+ ifrCache = frames[0].applicationCache;
+ document.body.removeChild(document.getElementsByTagName("iframe")[0]);
+ setTimeout(function() {
+ gc();
+ ifrCache.onchecking = function() { }
+ ifrCache.onerror = function() { }
+ ifrCache.onnoupdate = function() { }
+ ifrCache.ondownloading = function() { }
+ ifrCache.onprogress = function() { }
+ ifrCache.onupdateready = function() { }
+ ifrCache.oncached = function() { }
+ ifrCache.onobsolete = function() { }
+ ifrCache.addEventListener("error", function() { }, true);
+
+ var evt = document.createEvent("Event");
+ evt.initEvent("error", true, true);
+ ifrCache.dispatchEvent(evt);
+
+ try { ifrCache.update(); } catch (ex) { }
+ try { ifrCache.swapCache(); } catch (ex) { }
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }, 0);
+}
+</script>
diff --git a/LayoutTests/http/tests/appcache/detached-iframe-expected.txt b/LayoutTests/http/tests/appcache/detached-iframe-expected.txt
new file mode 100644
index 0000000..1290b75
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/detached-iframe-expected.txt
@@ -0,0 +1,3 @@
+Test that accessing a detached iframe's applicationCache window property doesn't assert. If you don't see an assert, it passed.
+
+
diff --git a/LayoutTests/http/tests/appcache/detached-iframe.html b/LayoutTests/http/tests/appcache/detached-iframe.html
new file mode 100644
index 0000000..ce6aecf
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/detached-iframe.html
@@ -0,0 +1,15 @@
+<body onload = "test()">
+<p>Test that accessing a detached iframe's applicationCache window property doesn't assert. If you don't see an assert, it passed.</p>
+<iframe src="about:blank"></iframe>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function test()
+{
+ var ifr = frames[0];
+ document.body.removeChild(document.getElementsByTagName("iframe")[0]);
+ ifr.applicationCache;
+}
+</script>
+</body>
diff --git a/LayoutTests/http/tests/appcache/different-origin-manifest-expected.txt b/LayoutTests/http/tests/appcache/different-origin-manifest-expected.txt
new file mode 100644
index 0000000..d08f58e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/different-origin-manifest-expected.txt
@@ -0,0 +1,3 @@
+Test that a different origin manifest is completely ignored.
+
+PASS
diff --git a/LayoutTests/http/tests/appcache/different-origin-manifest.html b/LayoutTests/http/tests/appcache/different-origin-manifest.html
new file mode 100644
index 0000000..b58c10a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/different-origin-manifest.html
@@ -0,0 +1,36 @@
+<html manifest="http://localhost:8000/appcache/resources/empty.manifest">
+<p>Test that a different origin manifest is completely ignored.</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.waitUntilDone();
+ layoutTestController.dumpAsText();
+}
+
+var result = document.getElementById("result");
+var originalResult = result.innerHTML;
+
+try {
+ applicationCache.onchecking = function() { result.innerHTML += "FAIL: onchecking called. " }
+ applicationCache.onerror = function() { result.innerHTML += "FAIL: onerror called" }
+ applicationCache.onnoupdate = function() { result.innerHTML += "FAIL: onnoupdate called" }
+ applicationCache.ondownloading = function() { result.innerHTML += "FAIL: ondownloading called" }
+ applicationCache.onprogress = function() { result.innerHTML += "FAIL: onprogress called" }
+ applicationCache.onupdateready = function() { result.innerHTML += "FAIL: onupdateready called" }
+ applicationCache.oncached = function() { result.innerHTML += "FAIL: oncached called" }
+ applicationCache.onobsolete = function() { result.innerHTML += "FAIL: onobsolete called" }
+} catch (ex) {
+ result.innerHTML += "FAIL: " + ex;
+}
+function done()
+{
+ if (result.innerHTML == originalResult)
+ result.innerHTML = applicationCache.status == applicationCache.UNCACHED ? "PASS" : "FAIL: cache status in not UNCACHED";
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+setTimeout(done, 100);
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/different-scheme-expected.txt b/LayoutTests/http/tests/appcache/different-scheme-expected.txt
new file mode 100644
index 0000000..3c2462b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/different-scheme-expected.txt
@@ -0,0 +1,3 @@
+Test that application cache doesn't block loading resources with different schemes.
+
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/different-scheme.html b/LayoutTests/http/tests/appcache/different-scheme.html
new file mode 100644
index 0000000..c874097
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/different-scheme.html
@@ -0,0 +1,28 @@
+<html manifest="resources/different-scheme.manifest">
+<body>
+<p>Test that application cache doesn't block loading resources with different schemes.</p>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function test()
+{
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "javascript:parent.success(), 'PASS'");
+ document.body.appendChild(ifr);
+}
+
+function success()
+{
+ document.body.replaceChild(document.createTextNode("SUCCESS"), document.getElementsByTagName("iframe")[0]);
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.oncached = test;
+applicationCache.onnoupdate = test;
+</script>
+<body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/disabled-expected.txt b/LayoutTests/http/tests/appcache/disabled-expected.txt
new file mode 100644
index 0000000..743bc6a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/disabled-expected.txt
@@ -0,0 +1,4 @@
+Test to ensure the the window.applicationCache attribute is defined but non-functional with the feature disabled.
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/disabled.html b/LayoutTests/http/tests/appcache/disabled.html
new file mode 100644
index 0000000..e89752a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/disabled.html
@@ -0,0 +1,51 @@
+<html>
+<body>
+<p>Test to ensure the the window.applicationCache attribute is defined but non-functional with the feature disabled.</p>
+<div id=result></div>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.overridePreference("WebKitOfflineWebApplicationCacheEnabled", false);
+ layoutTestController.dumpAsText();
+ }
+
+ function log(message)
+ {
+ document.getElementById("result").innerHTML += message + "<br>";
+ }
+
+ function isDefined() {
+ if (window.applicationCache)
+ return true;
+ else
+ return false;
+ }
+
+ function statusIsUncached() {
+ return applicationCache.status == 0;
+ }
+
+ function swapThrows() {
+ try {
+ applicationCache.swapCache();
+ return false;
+ } catch(e) {
+ return true;
+ }
+ }
+
+ function updateThrows() {
+ try {
+ applicationCache.swapCache();
+ return false;
+ } catch(e) {
+ return true;
+ }
+ }
+
+ if (isDefined() && statusIsUncached() && swapThrows() && updateThrows())
+ log("SUCCESS");
+ else
+ log("FAILURE");
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/dynamic-entries-no-cache-expected.txt b/LayoutTests/http/tests/appcache/dynamic-entries-no-cache-expected.txt
new file mode 100644
index 0000000..6aad145
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/dynamic-entries-no-cache-expected.txt
@@ -0,0 +1,27 @@
+Test the behavior of DOMApplicationCache methods related to dynamic entries when the context is not associated with any cache.
+
+PASS: applicationCache.items.length is 0
+PASS: applicationCache.items.item(0) is null
+PASS: applicationCache.items.item(1) is null
+PASS: applicationCache.items.item(0xffffffff) is null
+PASS: applicationCache.items.item(0xfffffffe) is null
+PASS: applicationCache.items.item(-1) is null
+PASS: applicationCache.items.item(-2) is null
+PASS: applicationCache.items[0xfffffffe] is undefined
+PASS: applicationCache.items[0xffffffff] is undefined
+PASS: applicationCache.items['0'] is undefined
+PASS: applicationCache.items[''] is undefined
+PASS: applicationCache.items[0] is undefined
+PASS: applicationCache.items[1] is undefined
+PASS: applicationCache.items[-1] is undefined
+PASS: applicationCache.items[-2] is undefined
+PASS: applicationCache.items[100] is undefined
+PASS: applicationCache.items['100'] is undefined
+PASS: applicationCache.items['foo'] is undefined
+PASS: applicationCache.items[0.1] is undefined
+PASS: hasItem raised INVALID_STATE_ERR
+PASS: add raised INVALID_STATE_ERR
+PASS: remove raised INVALID_STATE_ERR
+PASS: applicationCache.items.length is 0
+DONE
+
diff --git a/LayoutTests/http/tests/appcache/dynamic-entries-no-cache.html-disabled b/LayoutTests/http/tests/appcache/dynamic-entries-no-cache.html-disabled
new file mode 100644
index 0000000..ed6e599
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/dynamic-entries-no-cache.html-disabled
@@ -0,0 +1,119 @@
+<body>
+<p>Test the behavior of DOMApplicationCache methods related to dynamic entries when the context
+is not associated with any cache.</p>
+<div id="result"></div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+
+function isResultCorrect(_actual, _expected)
+{
+ if (_expected === 0)
+ return _actual === _expected && (1/_actual) === (1/_expected);
+ if (_actual === _expected)
+ return true;
+ if (typeof(_expected) == "number" && isNaN(_expected))
+ return typeof(_actual) == "number" && isNaN(_actual);
+ if (Object.prototype.toString.call(_expected) == Object.prototype.toString.call([])) {
+ log("Array comparison is not supported");
+ return false;
+ }
+ return false;
+}
+
+function shouldBe(_a, _b)
+{
+ if (typeof _a != "string" || typeof _b != "string")
+ log("WARN: shouldBe() expects string arguments");
+ var exception;
+ var _av;
+ try {
+ _av = eval(_a);
+ } catch (e) {
+ exception = e;
+ }
+ var _bv = eval(_b);
+
+ if (exception)
+ log("FAIL: " + _a + " should be " + _bv + ". Threw exception " + exception);
+ else if (isResultCorrect(_av, _bv))
+ log("PASS: " + _a + " is " + _b);
+ else if (typeof(_av) == typeof(_bv))
+ log("FAIL: " + _a + " should be " + _bv + ". Was " + stringify(_av) + ".");
+ else
+ log("FAIL: " + _a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ").");
+}
+
+
+shouldBe("applicationCache.items.length", "0");
+shouldBe("applicationCache.items.item(0)", "null");
+shouldBe("applicationCache.items.item(1)", "null");
+shouldBe("applicationCache.items.item(0xffffffff)", "null");
+shouldBe("applicationCache.items.item(0xfffffffe)", "null");
+shouldBe("applicationCache.items.item(-1)", "null");
+shouldBe("applicationCache.items.item(-2)", "null");
+
+shouldBe("applicationCache.items[0xfffffffe]", "undefined");
+shouldBe("applicationCache.items[0xffffffff]", "undefined");
+
+// The below index access tests give different results in WebKit and Firefox 3.1b2 (undefined vs. empty string).
+shouldBe("applicationCache.items['0']", "undefined");
+shouldBe("applicationCache.items['']", "undefined");
+shouldBe("applicationCache.items[0]", "undefined");
+shouldBe("applicationCache.items[1]", "undefined");
+shouldBe("applicationCache.items[-1]", "undefined");
+shouldBe("applicationCache.items[-2]", "undefined");
+applicationCache.items[100] = "foobar";
+applicationCache.items['100'] = "foobar";
+applicationCache.items['foo'] = "bar";
+shouldBe("applicationCache.items[100]", "undefined");
+shouldBe("applicationCache.items['100']", "undefined");
+
+shouldBe("applicationCache.items['foo']", "undefined");
+shouldBe("applicationCache.items[0.1]", "undefined");
+
+try {
+ applicationCache.hasItem('foo');
+ log("FAIL: hasItem didn't raise an exception");
+} catch (ex) {
+ if (ex.code == 11)
+ log("PASS: hasItem raised INVALID_STATE_ERR");
+ else
+ log("FAIL: hasItem raised unexpected exception " + ex);
+}
+
+try {
+ applicationCache.add('foo');
+ log("FAIL: add didn't raise an exception");
+} catch (ex) {
+ if (ex.code == 11)
+ log("PASS: add raised INVALID_STATE_ERR");
+ else
+ log("FAIL: add raised unexpected exception " + ex);
+}
+
+try {
+ applicationCache.remove('bar');
+ log("FAIL: remove didn't raise an exception");
+} catch (ex) {
+ if (ex.code == 11)
+ log("PASS: remove raised INVALID_STATE_ERR");
+ else
+ log("FAIL: remove raised unexpected exception " + ex);
+}
+
+shouldBe("applicationCache.items.length", "0");
+
+
+
+log("DONE");
+
+</script>
+</head>
+</body>
diff --git a/LayoutTests/http/tests/appcache/empty-manifest-expected.txt b/LayoutTests/http/tests/appcache/empty-manifest-expected.txt
new file mode 100644
index 0000000..bba93cf
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/empty-manifest-expected.txt
@@ -0,0 +1,2 @@
+This tests that the cached event gets sent even if the manifest is empty.
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/empty-manifest.html b/LayoutTests/http/tests/appcache/empty-manifest.html
new file mode 100644
index 0000000..67752e6
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/empty-manifest.html
@@ -0,0 +1,23 @@
+<html manifest="resources/empty.manifest">
+
+<div>This tests that the cached event gets sent even if the manifest is empty.</div>
+<div id="result">FAILURE</div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function cached()
+{
+ document.getElementById('result').innerHTML = 'SUCCESS';
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/fail-on-update-expected.txt b/LayoutTests/http/tests/appcache/fail-on-update-expected.txt
new file mode 100644
index 0000000..cd15247
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/fail-on-update-expected.txt
@@ -0,0 +1 @@
+SUCCESS: No crash.
diff --git a/LayoutTests/http/tests/appcache/fail-on-update.html b/LayoutTests/http/tests/appcache/fail-on-update.html
new file mode 100644
index 0000000..b021fcc
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/fail-on-update.html
@@ -0,0 +1,47 @@
+<html manifest="resources/fail-on-update.php">
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function setManifestDeleted(state)
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"), false);
+ req.send(null);
+}
+
+function test()
+{
+ clearTimeout(timeoutId);
+
+ setManifestDeleted(true);
+ applicationCache.update();
+ window.location = 'data:text/html,<p>SUCCESS: No crash.</p>' +
+ '<script>' +
+ 'if (window.layoutTestController) layoutTestController.notifyDone();' +
+ '</scri' + 'pt>';
+}
+
+function resetManifest()
+{
+ if (applicationCache.status != applicationCache.UNCACHED && applicationCache.status != applicationCache.OBSOLETE) {
+ timeoutId = setTimeout(resetManifest, 100);
+ return;
+ }
+
+ setManifestDeleted(false);
+ location.reload();
+}
+
+applicationCache.addEventListener('noupdate', function() { setTimeout(test, 0) }, false);
+applicationCache.addEventListener('cached', function() { setTimeout(test, 0) }, false);
+
+// If the manifest script happened to be in a wrong state, reset it.
+var timeoutId = setTimeout(resetManifest, 100);
+
+</script>
+<p>Test for a particular incorrect assertion failure.</p>
+
+</html>
diff --git a/LayoutTests/http/tests/appcache/fallback-expected.txt b/LayoutTests/http/tests/appcache/fallback-expected.txt
new file mode 100644
index 0000000..6dc0f5a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/fallback-expected.txt
@@ -0,0 +1,6 @@
+Test application cache fallback entries.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/fallback.html b/LayoutTests/http/tests/appcache/fallback.html
new file mode 100644
index 0000000..aaf7a82
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/fallback.html
@@ -0,0 +1,171 @@
+<html manifest="resources/fallback.manifest">
+<body>
+<p>Test application cache fallback entries.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+var hadError = false;
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function setNetworkEnabled(state)
+{
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false);
+ req.send("");
+ } catch (ex) {
+ log("Cannot access network simulator URL");
+ hadError = true;
+ }
+}
+
+function canLoad(url)
+{
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", url, false);
+ req.send("");
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+
+function load(url)
+{
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", url, false);
+ req.send("");
+ return req.responseText;
+ } catch (ex) {
+ alert("Unexpected error loading " + url + ": " + ex);
+ hadError = true;
+ }
+}
+
+var testURL = "/resources/network-simulator.php?path=/appcache/resources/not-in-cache.txt";
+var nonexistentURL = "resources/does-not-exist";
+var redirectURL = "resources/fallback-redirect.php";
+
+function test()
+{
+ applicationCache.onnoupdate = function() { log("FAIL: received unexpected noupdate event") }
+ applicationCache.oncached = function() { log("FAIL: received unexpected cached event") }
+
+ setNetworkEnabled(true);
+
+ if (!canLoad(testURL) || !/not in the cache/.test(load(testURL))) {
+ log("FAIL: Cannot load an URL from fallback namespace when network is enabled");
+ hadError = true;
+ }
+
+ if (!canLoad(nonexistentURL) || load(nonexistentURL) != "Hello, World!") {
+ log("FAIL: Fallback resource wasn't used for a 404 response");
+ hadError = true;
+ }
+
+ if (!canLoad(redirectURL) || load(redirectURL) != "Hello, World!") {
+ log("FAIL: Fallback resource wasn't used for a redirect to a resource with another origin");
+ hadError = true;
+ }
+
+ test2();
+}
+
+function test2()
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", nonexistentURL);
+ req.onerror = function() {
+ log("FAIL: Fallback resource wasn't used for a 404 response (async)");
+ hadError = true;
+ test3();
+ }
+ req.onload = function() {
+ if (req.responseText != "Hello, World!") {
+ log("FAIL: Unexpected result for a 404 response (async)");
+ hadError = true;
+ }
+ test3();
+ }
+
+ req.send("");
+}
+
+function test3()
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", redirectURL);
+ req.onerror = function() {
+ log("FAIL: Fallback resource wasn't used for a redirect to a resource with another origin (async)");
+ hadError = true;
+ test4();
+ }
+ req.onload = function() {
+ if (req.responseText != "Hello, World!") {
+ log("FAIL: Unexpected result for a redirect response (async)");
+ hadError = true;
+ }
+ test4();
+ }
+
+ req.send("");
+}
+
+function test4()
+{
+ // Try loading a fallback resource as main one.
+
+ applicationCache.onnoupdate = test5;
+
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", nonexistentURL);
+ document.body.appendChild(ifr);
+}
+
+function test5()
+{
+ if (!/Hello, World/.test(window.frames[0].document.documentElement.innerHTML)) {
+ log("FAIL: Fallback URL was not honored for main resource");
+ hadError = true;
+ }
+ test6();
+}
+
+function test6()
+{
+ setNetworkEnabled(false);
+
+ if (!canLoad(testURL)) {
+ log("FAIL: Cannot load an URL from fallback namespace when network is disabled");
+ hadError = true;
+ } else if (load(testURL) != load("resources/simple.txt")) {
+ log("FAIL: Loading an URL from fallback namespace when network is disabled returned unexpected response");
+ hadError = true;
+ }
+
+ log(hadError ? "FAILURE" : "SUCCESS");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.onnoupdate = function() { test() }
+applicationCache.oncached = function() { test() }
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/foreign-iframe-main-expected.txt b/LayoutTests/http/tests/appcache/foreign-iframe-main-expected.txt
new file mode 100644
index 0000000..64d4de2
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/foreign-iframe-main-expected.txt
@@ -0,0 +1,10 @@
+Test for <rdar://problem/6284708> AppCache crashes in ApplicationCacheResource::addType().
+
+checking
+downloading
+progress
+progress
+progress
+cached
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/foreign-iframe-main.html b/LayoutTests/http/tests/appcache/foreign-iframe-main.html
new file mode 100644
index 0000000..a543eef
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/foreign-iframe-main.html
@@ -0,0 +1,39 @@
+<html manifest="resources/foreign-iframe.manifest"> <!-- Any manifest would do the trick. -->
+<body>
+<p>Test for <a href="rdar://problem/6284708">&lt;rdar://problem/6284708></a> AppCache crashes in ApplicationCacheResource::addType().</p>
+
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function test()
+{
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "http://localhost:8000/appcache/resources/foreign-iframe.html");
+ document.body.appendChild(ifr);
+}
+
+applicationCache.addEventListener('checking', function() { log("checking") }, false);
+applicationCache.addEventListener('error', function() { log("error") }, false);
+applicationCache.addEventListener('downloading', function() { log("downloading") }, false);
+applicationCache.addEventListener('progress', function() { log("progress") }, false);
+applicationCache.addEventListener('updateready', function() { log("updateready") }, false);
+applicationCache.addEventListener('obsolete', function() { log("obsolete") }, false);
+
+applicationCache.addEventListener('noupdate', function() { log("noupdate"); test() }, false);
+applicationCache.addEventListener('cached', function() { log("cached"); test() }, false);
+
+window.addEventListener("message", function() { log("SUCCESS"); if (window.layoutTestController) layoutTestController.notifyDone() }, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/idempotent-update-expected.txt b/LayoutTests/http/tests/appcache/idempotent-update-expected.txt
new file mode 100644
index 0000000..6fa942a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/idempotent-update-expected.txt
@@ -0,0 +1,6 @@
+Test what applicationCache.update() does if update is already in progess.
+
+Should say DONE, with no failures:
+
+DONE
+
diff --git a/LayoutTests/http/tests/appcache/idempotent-update.html b/LayoutTests/http/tests/appcache/idempotent-update.html
new file mode 100644
index 0000000..652369d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/idempotent-update.html
@@ -0,0 +1,56 @@
+<html manifest="resources/idempotent-update.manifest">
+<body>
+<p>Test what applicationCache.update() does if update is already in progess.</p>
+<p>Should say DONE, with no failures:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function test()
+{
+ // During update, additional update() should be no-op (the spec says that fake checking and
+ // downloading events need to be dispatched, but that's only when the update algorithm is invoked
+ // with a browsing context).
+ if (applicationCache.status != applicationCache.IDLE)
+ log("FAIL: Unexpected cache status while preparing to test: " + applicationCache.status);
+
+ var checkingCount = 0;
+ applicationCache.onchecking = function() { if (++checkingCount != 1) log("FAIL: Too many checking events received.") }
+
+ applicationCache.update();
+ applicationCache.update();
+ applicationCache.update();
+ applicationCache.update();
+ applicationCache.update();
+
+ applicationCache.onnoupdate = done;
+ applicationCache.oncached = function() { log("FAIL: received unexpected cached event") }
+}
+
+function done()
+{
+ setTimeout(function() {
+ log("DONE");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }, 10);
+}
+
+applicationCache.oncached = test;
+applicationCache.onnoupdate = test;
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/local-content-expected.txt b/LayoutTests/http/tests/appcache/local-content-expected.txt
new file mode 100644
index 0000000..5c1aa37
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/local-content-expected.txt
@@ -0,0 +1,7 @@
+CONSOLE MESSAGE: line 0: Not allowed to load local resource: stdio.h
+Test that documents loaded from application cache don't get access to local resources accidentally.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/local-content.html b/LayoutTests/http/tests/appcache/local-content.html
new file mode 100644
index 0000000..0787567
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/local-content.html
@@ -0,0 +1,51 @@
+<html manifest="resources/local-content.manifest">
+<body>
+<p>Test that documents loaded from application cache don't get access to local resources accidentally.</p>
+<p>Should say SUCCESS:</p>
+<div id="result"></div>
+<script type="text/javascript">
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function noupdate()
+{
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "file:///usr/include/stdio.h");
+ ifr.onload = frameCreated;
+ setTimeout(function() {
+ log("SUCCESS");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }, 300);
+
+ document.body.appendChild(ifr);
+}
+
+function frameCreated()
+{
+ log("FAILURE: A local resource was opened in an iframe");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function reload()
+{
+ // Reload to ensure that the main document was loaded from application cache.
+ window.location.reload();
+}
+
+applicationCache.addEventListener('noupdate', noupdate, false);
+
+applicationCache.addEventListener('cached', reload, false);
+applicationCache.addEventListener('error', function() { alert("Unexpected error event") }, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/main-resource-hash-expected.txt b/LayoutTests/http/tests/appcache/main-resource-hash-expected.txt
new file mode 100644
index 0000000..50f4f71
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/main-resource-hash-expected.txt
@@ -0,0 +1,6 @@
+Test that offline applications' main resources are not affected by URL hashes.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/main-resource-hash.html b/LayoutTests/http/tests/appcache/main-resource-hash.html
new file mode 100644
index 0000000..6dbce36
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/main-resource-hash.html
@@ -0,0 +1,51 @@
+<html>
+<body>
+<p>Test that offline applications' main resources are not affected by URL hashes.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function setNetworkEnabled(state)
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false);
+ req.send("");
+}
+
+function frameCreated()
+{
+ if (stage == 0) {
+ stage = 1;
+ setNetworkEnabled(false);
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "/resources/network-simulator.php?path=/appcache/resources/main-resource-hash-frame.html#bar");
+ document.body.appendChild(ifr);
+ } else {
+ log("SUCCESS");
+ setNetworkEnabled(true);
+ if (window.layoutTestController)
+ layoutTestController.notifyDone()
+ }
+}
+
+window.addEventListener("message", frameCreated, false);
+
+var stage = 0;
+setNetworkEnabled(true);
+var ifr = document.createElement("iframe");
+ifr.setAttribute("src", "/resources/network-simulator.php?path=/appcache/resources/main-resource-hash-frame.html#foo");
+document.body.appendChild(ifr);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/manifest-containing-itself-expected.txt b/LayoutTests/http/tests/appcache/manifest-containing-itself-expected.txt
new file mode 100644
index 0000000..77e2506
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-containing-itself-expected.txt
@@ -0,0 +1,2 @@
+This tests that a manifest can contain itself as a resource.
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/manifest-containing-itself.html b/LayoutTests/http/tests/appcache/manifest-containing-itself.html
new file mode 100644
index 0000000..89a5410
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-containing-itself.html
@@ -0,0 +1,24 @@
+<html manifest="resources/manifest-containing-itself.manifest">
+
+<div>This tests that a manifest can contain itself as a resource.</div>
+<div id="result">FAILURE</div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function cached()
+{
+ document.getElementById('result').innerHTML = 'SUCCESS';
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+applicationCache.addEventListener('noupdate', cached, false);
+
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/manifest-parsing-expected.txt b/LayoutTests/http/tests/appcache/manifest-parsing-expected.txt
new file mode 100644
index 0000000..fc15310
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-parsing-expected.txt
@@ -0,0 +1,4 @@
+Test application cache manifest parsing.
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/manifest-parsing.html b/LayoutTests/http/tests/appcache/manifest-parsing.html
new file mode 100644
index 0000000..46a7fdd
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-parsing.html
@@ -0,0 +1,66 @@
+<html manifest="resources/manifest-parsing.manifest">
+<body>
+<p>Test application cache manifest parsing.</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function canLoad(url)
+{
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", url, false);
+ req.send();
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+
+function test()
+{
+ var hadError = false;
+
+ // Check that section name wasn't misparsed as resource URL.
+ if (canLoad("resources/UNKNOWN:")) {
+ log("Loaded 'UNKNOWN:'");
+ hadError = true;
+ }
+
+ // Load a resource that was in UNKNOWN section - in other words, that is not in cache.
+ if (canLoad("resources/not-in-cache.txt")) {
+ log("Loaded 'not-in-cache.txt'");
+ hadError = true;
+ }
+
+ // Load resources were specified with tricky whitespace.
+ if (!canLoad("resources/empty.txt")) {
+ log("Could not load 'empty.txt'");
+ hadError = true;
+ }
+ if (!canLoad("resources/simple.txt")) {
+ log("Could not load 'simple.txt'");
+ hadError = true;
+ }
+
+ log(hadError ? "FAILURE" : "SUCCESS");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.onnoupdate = function() { test() }
+applicationCache.oncached = function() { test() }
+
+applicationCache.onerror = function() { log("error") }
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/manifest-redirect-2-expected.txt b/LayoutTests/http/tests/appcache/manifest-redirect-2-expected.txt
new file mode 100644
index 0000000..420e94b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-redirect-2-expected.txt
@@ -0,0 +1,6 @@
+Test that a redirect makes resource caching fail.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/manifest-redirect-2.html b/LayoutTests/http/tests/appcache/manifest-redirect-2.html
new file mode 100644
index 0000000..7c00d41
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-redirect-2.html
@@ -0,0 +1,40 @@
+<html manifest="resources/manifest-redirect-2.php">
+<body>
+<p>Test that a redirect makes resource caching fail.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function cacheCallback()
+{
+ log("FAIL: An event was dispatched on window.applicationCache, even though it was not associated wuth any cache yet.");
+}
+
+function test()
+{
+ // Wait for cache update to finish.
+ if (window.applicationCache.status != window.applicationCache.UNCACHED)
+ log("FAILURE: Unexpected cache status: " + window.applicationCache.status);
+ else
+ log("SUCCESS");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', function() { log("cached"); cacheCallback() }, false);
+applicationCache.addEventListener('noupdate', function() { log("noupdate"); cacheCallback() }, false);
+applicationCache.addEventListener('error', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/manifest-redirect-expected.txt b/LayoutTests/http/tests/appcache/manifest-redirect-expected.txt
new file mode 100644
index 0000000..420e94b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-redirect-expected.txt
@@ -0,0 +1,6 @@
+Test that a redirect makes resource caching fail.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/manifest-redirect.html b/LayoutTests/http/tests/appcache/manifest-redirect.html
new file mode 100644
index 0000000..3f75547
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-redirect.html
@@ -0,0 +1,40 @@
+<html manifest="resources/manifest-redirect.php">
+<body>
+<p>Test that a redirect makes resource caching fail.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function cacheCallback()
+{
+ log("FAIL: An event was dispatched on window.applicationCache, even though it was not associated wuth any cache yet.");
+}
+
+function test()
+{
+ // Wait for cache update to finish.
+ if (window.applicationCache.status != window.applicationCache.UNCACHED)
+ log("FAILURE: Unexpected cache status: " + window.applicationCache.status);
+ else
+ log("SUCCESS");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', function() { log("cached"); cacheCallback() }, false);
+applicationCache.addEventListener('noupdate', function() { log("noupdate"); cacheCallback() }, false);
+applicationCache.addEventListener('error', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/manifest-with-empty-file-expected.txt b/LayoutTests/http/tests/appcache/manifest-with-empty-file-expected.txt
new file mode 100644
index 0000000..3cf2ce6
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-with-empty-file-expected.txt
@@ -0,0 +1,2 @@
+This tests that a manifest that contains an empty file will not crash the browser.
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/manifest-with-empty-file.html b/LayoutTests/http/tests/appcache/manifest-with-empty-file.html
new file mode 100644
index 0000000..b9ae051
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/manifest-with-empty-file.html
@@ -0,0 +1,21 @@
+<html manifest="resources/manifest-with-empty-file.manifest">
+<div>This tests that a manifest that contains an empty file will not crash the browser.</div>
+<div id="result">FAILURE</div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function cached()
+{
+ document.getElementById('result').innerHTML = 'SUCCESS';
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+
+</script>
+
+</html>
diff --git a/LayoutTests/http/tests/appcache/max-size-expected.txt b/LayoutTests/http/tests/appcache/max-size-expected.txt
new file mode 100644
index 0000000..b915156
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/max-size-expected.txt
@@ -0,0 +1,4 @@
+Cache a manifest that contains a resource that is too large to fit. The layout test controller sets a maximum size of 10KB for the application cache database file.
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/max-size.html b/LayoutTests/http/tests/appcache/max-size.html
new file mode 100644
index 0000000..8f4e855
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/max-size.html
@@ -0,0 +1,28 @@
+<html manifest="resources/maxsize.manifest">
+<body>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.setAppCacheMaximumSize(10 * 1024);
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ function log(message)
+ {
+ document.getElementById("result").innerHTML += message + "<br>";
+ if (window.layoutTestController) {
+ layoutTestController.setAppCacheMaximumSize(100 * 1024 * 1024);
+ layoutTestController.notifyDone();
+ }
+ }
+
+ applicationCache.onerror = function() { log("SUCCESS"); }
+ applicationCache.oncached = function() { log("FAIL: received unexpected cached event"); }
+ applicationCache.onnoupdate = function() { log("FAIL: received unexpected onnoupdate event"); }
+ applicationCache.onupdateready = function() { log("FAIL: received unexpected onupdateready event"); }
+</script>
+
+<p>Cache a manifest that contains a resource that is too large to fit. The layout test controller sets a maximum size of 10KB for the application cache database file.</p>
+<div id=result></div>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/navigating-away-while-cache-attempt-in-progress-expected.txt b/LayoutTests/http/tests/appcache/navigating-away-while-cache-attempt-in-progress-expected.txt
new file mode 100644
index 0000000..ca09f7e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/navigating-away-while-cache-attempt-in-progress-expected.txt
@@ -0,0 +1,2 @@
+This tests that navigating away while a cache is loading does not crash.
+SUCCESS - did not crash
diff --git a/LayoutTests/http/tests/appcache/navigating-away-while-cache-attempt-in-progress.html b/LayoutTests/http/tests/appcache/navigating-away-while-cache-attempt-in-progress.html
new file mode 100644
index 0000000..7e7920a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/navigating-away-while-cache-attempt-in-progress.html
@@ -0,0 +1,21 @@
+<html manifest="resources/navigating-away-while-cache-attempt-in-progress.manifest">
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function navigateAway() {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ else
+ window.location.href = "about:blank"
+}
+
+setTimeout(navigateAway, 1000);
+
+</script>
+<div>This tests that navigating away while a cache is loading does not crash.</div>
+<div>SUCCESS - did not crash</div>
+</html>
diff --git a/LayoutTests/http/tests/appcache/non-html-expected.txt b/LayoutTests/http/tests/appcache/non-html-expected.txt
new file mode 100644
index 0000000..7c0e8c4
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/non-html-expected.txt
@@ -0,0 +1,6 @@
+Test that non-HTML main resources work with application cache correctly.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/non-html.xhtml b/LayoutTests/http/tests/appcache/non-html.xhtml
new file mode 100644
index 0000000..d27681e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/non-html.xhtml
@@ -0,0 +1,103 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+ manifest="/resources/network-simulator.php?path=/appcache/resources/non-html.manifest">
+<head><title/></head>
+<body>
+<p>Test that non-HTML main resources work with application cache correctly.</p>
+<p>Should say SUCCESS:</p>
+<div id="result"></div>
+<script type="text/javascript">
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "&lt;br/>";
+}
+
+function setNetworkEnabled(state)
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false);
+ req.send("");
+}
+
+function createFrame()
+{
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "/resources/network-simulator.php?path=/appcache/resources/abe.png");
+ ifr.onload = frameCreated;
+ document.body.appendChild(ifr);
+}
+
+function cached()
+{
+ var hadError = false;
+
+ applicationCache.removeEventListener('noupdate', cached, false);
+ applicationCache.removeEventListener('cached', cached, false);
+
+ setNetworkEnabled(false);
+
+ // Load a resource that does not exist in the cache.
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", "/resources/network-simulator.php?path=/appcache/resources/not-in-cache.txt", false);
+ req.send();
+ } catch (e) {
+ if (e.code == XMLHttpRequestException.NETWORK_ERR)
+ hadError = true;
+ }
+
+ if (!hadError) {
+ document.getElementById('result').innerHTML = "FAILURE: Did not get the right exception"
+ return;
+ }
+
+ // Load a resource that exists in the cache.
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", "/resources/network-simulator.php?path=/appcache/resources/simple.txt", false);
+ req.send();
+ } catch (e) {
+ document.getElementById('result').innerHTML = "FAILURE: Could not load data from cache"
+ return;
+ }
+
+ if (req.responseText != 'Hello, World!') {
+ document.getElementById('result').innerHTML = "FAILURE: Did not get correct data from cached resource"
+ return;
+ }
+
+ createFrame();
+}
+
+function frameCreated()
+{
+ setNetworkEnabled(true);
+
+ if (frames[0].document.documentElement.innerHTML.match(/abe\.png/))
+ log("SUCCESS")
+ else
+ log("FAIL: Frame.onload was called, but the image doesn't seem to be loaded.");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function error()
+{
+ // The simulator was in a wrong state, reset it.
+ setNetworkEnabled(true);
+ window.location.reload();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+applicationCache.addEventListener('noupdate', cached, false);
+
+applicationCache.addEventListener('error', error, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/offline-access-expected.txt b/LayoutTests/http/tests/appcache/offline-access-expected.txt
new file mode 100644
index 0000000..0fcc923
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/offline-access-expected.txt
@@ -0,0 +1,6 @@
+Test that offline applications work when there is no network access (simulated).
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/offline-access.html b/LayoutTests/http/tests/appcache/offline-access.html
new file mode 100644
index 0000000..45e9d4e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/offline-access.html
@@ -0,0 +1,57 @@
+<html>
+<body>
+<p>Test that offline applications work when there is no network access (simulated).</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function setNetworkEnabled(state)
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false);
+ req.send("");
+}
+
+function createFrame()
+{
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "/resources/network-simulator.php?path=/appcache/resources/offline-access-frame.html");
+ document.body.appendChild(ifr);
+}
+
+function frameCreated()
+{
+ if (stage == 0) {
+ stage = 1;
+ setNetworkEnabled(false);
+ createFrame();
+ } else if (stage == 1) {
+ stage = 2;
+ setNetworkEnabled(true);
+ createFrame();
+ } else {
+ log("SUCCESS");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone()
+ }
+}
+
+window.addEventListener("message", frameCreated, false);
+
+var stage = 0;
+setNetworkEnabled(true);
+createFrame();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/online-whitelist-expected.txt b/LayoutTests/http/tests/appcache/online-whitelist-expected.txt
new file mode 100644
index 0000000..a605108
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/online-whitelist-expected.txt
@@ -0,0 +1,4 @@
+Test online whitelist functionality. Should say PASS:
+
+PASS
+
diff --git a/LayoutTests/http/tests/appcache/online-whitelist.html b/LayoutTests/http/tests/appcache/online-whitelist.html
new file mode 100644
index 0000000..f33fb6d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/online-whitelist.html
@@ -0,0 +1,77 @@
+<html manifest="resources/online-whitelist.manifest">
+<body>
+<p>Test online whitelist functionality. Should say PASS:</p>
+
+<div id="result"></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+var hadError = false;
+
+function canLoad(url)
+{
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", url, false);
+ req.send("");
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+
+function load(url)
+{
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", url, false);
+ req.send("");
+ return req.responseText;
+ } catch (ex) {
+ alert("Unexpected error loading " + url + ": " + ex);
+ hadError = true;
+ }
+}
+
+function test()
+{
+ if (load("resources/counter.php?cached") != load("resources/counter.php?cached")) {
+ log("FAIL: Explicit entry didn't override online whitelist.");
+ hadError = true;
+ }
+
+ if (load("resources/counter.php?uncached") == load("resources/counter.php?uncached")) {
+ log("FAIL: Online whitelist resource wasn't reloaded from network.");
+ hadError = true;
+ }
+
+ if (load("resources/counter.php?uncachedxxx") == load("resources/counter.php?uncachedxxx")) {
+ log("FAIL: Online whitelist resource wasn't reloaded from network (prefix matching).");
+ hadError = true;
+ }
+
+ if (canLoad("resources/counter.php?foobar")) {
+ log("FAIL: Uncached resource was successfully loaded.");
+ hadError = true;
+ }
+
+ log(hadError ? "FAIL" : "PASS");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', test, false);
+applicationCache.addEventListener('noupdate', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/reload-expected.txt b/LayoutTests/http/tests/appcache/reload-expected.txt
new file mode 100644
index 0000000..7bfc07b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/reload-expected.txt
@@ -0,0 +1,8 @@
+Test that the manifest is picked correctly when reloading.
+
+Should say SUCCESS:
+
+Frame loaded
+Frame loaded
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/reload.html b/LayoutTests/http/tests/appcache/reload.html
new file mode 100644
index 0000000..6e2da56
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/reload.html
@@ -0,0 +1,40 @@
+<html>
+<body>
+<p>Test that the manifest is picked correctly when reloading.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+var state = 0;
+function receivedMessage(message)
+{
+ log(message);
+
+ if (state == 0) {
+ state = 1;
+ setTimeout("frames[0].location.reload()", 0);
+ } else if (state == 1) {
+ state = 2;
+ setTimeout("frames[0].test()", 0);
+ } else if (state == 2) {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+}
+
+window.addEventListener("message", function(e) { receivedMessage(e.data) }, false);
+
+</script>
+<iframe src="resources/reload-iframe.html"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/remove-cache-expected.txt b/LayoutTests/http/tests/appcache/remove-cache-expected.txt
new file mode 100644
index 0000000..9e23ba1
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/remove-cache-expected.txt
@@ -0,0 +1,10 @@
+Test that a 404 response for manifest results in cache removal.
+
+Frame 1: Manifest is still available, so a new master resource is added to the cache.
+Frame 2: Manifest loading results in 404 response, so the cache group becomes obsolete, and an obsolete event is dispatched (because the document in frame was associated with a cache in the group).
+Frame 3: Manifest is still 404 - the document is never associated with a cache.
+Frame 4: Manifest is now available, so the document gets associated with a cache in a newly created group; the obsolete cache group is not affected.
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/remove-cache.html b/LayoutTests/http/tests/appcache/remove-cache.html
new file mode 100644
index 0000000..954418c
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/remove-cache.html
@@ -0,0 +1,111 @@
+<html manifest="resources/fail-on-update.php">
+<p>Test that a 404 response for manifest results in cache removal.</p>
+<body>
+<ul>
+<li>Frame 1: Manifest is still available, so a new master resource is added to the cache.
+<li>Frame 2: Manifest loading results in 404 response, so the cache group becomes obsolete, and an obsolete event is dispatched (because the document in frame was associated with a cache in the group).
+<li>Frame 3: Manifest is still 404 - the document is never associated with a cache.
+<li>Frame 4: Manifest is now available, so the document gets associated with a cache in a newly created group; the obsolete cache group is not affected.
+</ul>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function setManifestDeleted(state)
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"), false);
+ req.send(null);
+}
+
+function test()
+{
+ clearTimeout(timeoutId);
+
+ // The frame will be associated to a cache, and its main resource will be added to the cache.
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/remove-cache-frame.html");
+ document.body.appendChild(ifr);
+ applicationCache.onnoupdate = test2;
+}
+
+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;
+}
+
+function test3()
+{
+ applicationCache.onchecking = function() { log("Unexpected checking event after obsolete event") }
+ applicationCache.onupdateready = function() { log("Unexpected updateready event after obsolete event") }
+ applicationCache.onerror = function() { log("Unexpected error event after obsolete event") }
+ applicationCache.onnoupdate = function() { log("Unexpected noupdate event after obsolete event") }
+ applicationCache.oncached = function() { log("Unexpected cached event after obsolete event") }
+
+ // The frame will not be associated to a cache.
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/remove-cache-frame.html");
+ document.body.appendChild(ifr);
+ window.addEventListener("message", test4, false);
+}
+
+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);
+}
+
+function test5()
+{
+ log("SUCCESS");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function resetManifest()
+{
+ if (applicationCache.status != applicationCache.UNCACHED && applicationCache.status != applicationCache.OBSOLETE) {
+ timeoutId = setTimeout(resetManifest, 100);
+ return;
+ }
+
+ setManifestDeleted(false);
+ location.reload();
+}
+
+applicationCache.onupdateready = function() { log("Unexpected updateready event") }
+applicationCache.onnoupdate = test;
+applicationCache.oncached = test;
+
+// If the manifest script happened to be in a wrong state, reset it.
+var timeoutId = setTimeout(resetManifest, 100);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resource-redirect-2-expected.txt b/LayoutTests/http/tests/appcache/resource-redirect-2-expected.txt
new file mode 100644
index 0000000..420e94b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resource-redirect-2-expected.txt
@@ -0,0 +1,6 @@
+Test that a redirect makes resource caching fail.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/resource-redirect-2.html b/LayoutTests/http/tests/appcache/resource-redirect-2.html
new file mode 100644
index 0000000..cf0d3a8
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resource-redirect-2.html
@@ -0,0 +1,40 @@
+<html manifest="resources/resource-redirect-2.manifest">
+<body>
+<p>Test that a redirect makes resource caching fail.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function cacheCallback()
+{
+ log("FAIL: An unexpected event was dispatched on window.applicationCache.");
+}
+
+function test()
+{
+ // Wait for cache update to finish.
+ if (window.applicationCache.status != window.applicationCache.UNCACHED)
+ log("FAILURE: Unexpected cache status: " + window.applicationCache.status);
+ else
+ log("SUCCESS");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', function() { log("cached"); cacheCallback() }, false);
+applicationCache.addEventListener('noupdate', function() { log("noupdate"); cacheCallback() }, false);
+applicationCache.addEventListener('error', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resource-redirect-expected.txt b/LayoutTests/http/tests/appcache/resource-redirect-expected.txt
new file mode 100644
index 0000000..420e94b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resource-redirect-expected.txt
@@ -0,0 +1,6 @@
+Test that a redirect makes resource caching fail.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/resource-redirect.html b/LayoutTests/http/tests/appcache/resource-redirect.html
new file mode 100644
index 0000000..7fdf5f8
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resource-redirect.html
@@ -0,0 +1,40 @@
+<html manifest="resources/resource-redirect.manifest">
+<body>
+<p>Test that a redirect makes resource caching fail.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function cacheCallback()
+{
+ log("FAIL: An unexpected event was dispatched on window.applicationCache.");
+}
+
+function test()
+{
+ // Wait for cache update to finish.
+ if (window.applicationCache.status != window.applicationCache.UNCACHED)
+ log("FAILURE: Unexpected cache status: " + window.applicationCache.status);
+ else
+ log("SUCCESS");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', function() { log("cached"); cacheCallback() }, false);
+applicationCache.addEventListener('noupdate', function() { log("noupdate"); cacheCallback() }, false);
+applicationCache.addEventListener('error', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/.htaccess b/LayoutTests/http/tests/appcache/resources/.htaccess
new file mode 100644
index 0000000..dfa433b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/.htaccess
@@ -0,0 +1,5 @@
+RewriteEngine on
+RewriteRule ^UNKNOWN_SECTION: simple.txt [L,NS]
+<Files wrong-content-type.manifest>
+ForceType text/plain
+</Files>
diff --git a/LayoutTests/http/tests/appcache/resources/404-resource.manifest b/LayoutTests/http/tests/appcache/resources/404-resource.manifest
new file mode 100644
index 0000000..b2c066d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/404-resource.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+does-not-exist.txt
diff --git a/LayoutTests/http/tests/appcache/resources/abe.png b/LayoutTests/http/tests/appcache/resources/abe.png
new file mode 100644
index 0000000..c932536
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/abe.png
Binary files differ
diff --git a/LayoutTests/http/tests/appcache/resources/access-via-redirect.html b/LayoutTests/http/tests/appcache/resources/access-via-redirect.html
new file mode 100644
index 0000000..510f841
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/access-via-redirect.html
@@ -0,0 +1,46 @@
+<html manifest="access-via-redirect.manifest">
+
+<p>This tests that the start of redirect chain doesn't get into an application cache if the end of the chain has a manifest.</p>
+<p id="result">FAILURE</p>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function canLoad(url)
+{
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", url, false);
+ req.send("");
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+
+function cached()
+{
+ if (canLoad("/appcache/access-via-redirect.php")) {
+ document.getElementById('result').innerHTML = "FAILURE: Start of redirect chain is in cache."
+ return;
+ }
+
+ if (!canLoad("access-via-redirect.html")) {
+ document.getElementById('result').innerHTML = "FAILURE: Could not load main resource from cache."
+ return;
+ }
+
+ document.getElementById('result').innerHTML = "SUCCESS"
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+applicationCache.addEventListener('noupdate', cached, false);
+
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/access-via-redirect.manifest b/LayoutTests/http/tests/appcache/resources/access-via-redirect.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/access-via-redirect.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/auth/iframe.php b/LayoutTests/http/tests/appcache/resources/auth/iframe.php
new file mode 100644
index 0000000..7e5d30d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/auth/iframe.php
@@ -0,0 +1,16 @@
+<?php
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ header('WWW-Authenticate: Basic realm="WebKit AppCache Test Realm"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo 'Authentication canceled';
+ exit;
+ } else {
+ echo "<html manifest='manifest.php'>\n";
+ echo "<p>Subframe, should disappear.</p>\n";
+ echo "<script>\n";
+ echo " applicationCache.oncached = parent.success;\n";
+ echo " applicationCache.onnoupdate = parent.success;\n";
+ echo "</script>\n";
+ echo "</html>\n";
+ }
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/auth/manifest.php b/LayoutTests/http/tests/appcache/resources/auth/manifest.php
new file mode 100644
index 0000000..ea09957
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/auth/manifest.php
@@ -0,0 +1,12 @@
+<?php
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ header('WWW-Authenticate: Basic realm="WebKit AppCache Test Realm"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo 'Authentication canceled';
+ exit;
+ } else {
+ header("Content-Type: text/cache-manifest");
+ echo "CACHE MANIFEST\n";
+ echo "subresource.php\n";
+ }
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/auth/setup.php b/LayoutTests/http/tests/appcache/resources/auth/setup.php
new file mode 100644
index 0000000..c0f3965
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/auth/setup.php
@@ -0,0 +1,10 @@
+<?php
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ header('WWW-Authenticate: Basic realm="WebKit AppCache Test Realm"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo 'Authentication canceled';
+ exit;
+ } else {
+ echo "OK\n";
+ }
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/auth/subresource.php b/LayoutTests/http/tests/appcache/resources/auth/subresource.php
new file mode 100644
index 0000000..0945d53
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/auth/subresource.php
@@ -0,0 +1,10 @@
+<?php
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ header('WWW-Authenticate: Basic realm="WebKit AppCache Test Realm"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo 'Authentication canceled';
+ exit;
+ } else {
+ echo "/* Empty subresource */";
+ }
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/counter.php b/LayoutTests/http/tests/appcache/resources/counter.php
new file mode 100644
index 0000000..7926faf
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/counter.php
@@ -0,0 +1,23 @@
+<?php
+require_once '../../resources/portabilityLayer.php';
+
+$tmpFile = sys_get_temp_dir() . "/" . "appcache_counter";
+
+function stepCounter($file)
+{
+ if (!file_exists($file)) {
+ file_put_contents($file, "0");
+ return "0";
+ }
+ $value = file_get_contents($file);
+ file_put_contents($file, ++$value);
+ return $value;
+}
+
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-Type: text/plain");
+
+print(stepCounter($tmpFile));
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/crash-when-navigating-away-then-back.html b/LayoutTests/http/tests/appcache/resources/crash-when-navigating-away-then-back.html
new file mode 100644
index 0000000..28bbeb3
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/crash-when-navigating-away-then-back.html
@@ -0,0 +1,22 @@
+<html manifest="crash-when-navigating-away-then-back.manifest">
+<script>
+
+function cached()
+{
+ window.close();
+ window.opener.closedWindow();
+}
+
+function noupdate()
+{
+ window.opener.document.getElementById('result').innerHTML = 'SUCCESS';
+ window.close();
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+applicationCache.addEventListener('noupdate', noupdate, false);
+
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/crash-when-navigating-away-then-back.manifest b/LayoutTests/http/tests/appcache/resources/crash-when-navigating-away-then-back.manifest
new file mode 100644
index 0000000..a9fb276
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/crash-when-navigating-away-then-back.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+crash-when-navigating-away-then-back.html
diff --git a/LayoutTests/http/tests/appcache/resources/cyrillic-uri-form.html b/LayoutTests/http/tests/appcache/resources/cyrillic-uri-form.html
new file mode 100644
index 0000000..a97c508
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/cyrillic-uri-form.html
@@ -0,0 +1,28 @@
+<html manifest="cyrillic-uri.manifest">
+<head>
+<meta charset="koi8-r">
+</head>
+<body>
+<form method=GET action="?">
+<input type=text name=i value="ðÒÏ×ÅÒËÁ">
+</form>
+<script>
+document.write(location);
+function test() {
+ if (location.search == "") {
+ document.forms[0].submit();
+ } else if (location.search == "?i=%F0%D2%CF%D7%C5%D2%CB%C1") {
+ document.forms[0].elements[0].value="ðÒÏ×ÅÒËÁ-2";
+ document.forms[0].submit();
+ } else if (location.search == "?i=%F0%D2%CF%D7%C5%D2%CB%C1-2") {
+ parent.postMessage("allDone", "*");
+ } else {
+ alert("Unexpected URI: " + location);
+ parent.postMessage("allDone", "*");
+ }
+}
+applicationCache.onnoupdate = function() { test() }
+applicationCache.oncached = function() { test() }
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/cyrillic-uri.manifest b/LayoutTests/http/tests/appcache/resources/cyrillic-uri.manifest
new file mode 100644
index 0000000..574ab9e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/cyrillic-uri.manifest
@@ -0,0 +1,10 @@
+CACHE MANIFEST
+intercept/cached-Проверка
+intercept/cached2-%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0
+cyrillic-uri-form.html
+cyrillic-uri-form.html?i=Проверка
+NETWORK:
+intercept/network-Проверка
+cyrillic-uri-form.html?i=Проверка-2
+FALLBACK:
+does-not-exist-Проверка intercept/fallback-Проверка
diff --git a/LayoutTests/http/tests/appcache/resources/different-scheme.manifest b/LayoutTests/http/tests/appcache/resources/different-scheme.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/different-scheme.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/empty.manifest b/LayoutTests/http/tests/appcache/resources/empty.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/empty.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/empty.txt b/LayoutTests/http/tests/appcache/resources/empty.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/empty.txt
diff --git a/LayoutTests/http/tests/appcache/resources/fail-on-update.php b/LayoutTests/http/tests/appcache/resources/fail-on-update.php
new file mode 100644
index 0000000..b66da78
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/fail-on-update.php
@@ -0,0 +1,38 @@
+<?php
+require_once '../../resources/portabilityLayer.php';
+
+$tmpFile = sys_get_temp_dir() . "/" . "fail_on_update_state";
+
+function setState($newState, $file)
+{
+ file_put_contents($file, $newState);
+}
+
+function getState($file)
+{
+ if (!file_exists($file)) {
+ return "Uninitialized";
+ }
+ return file_get_contents($file);
+}
+
+$command = $_GET['command'];
+$state = getState($tmpFile);
+
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+if ($command == "reset") {
+ unlink($tmpFile);
+} else if ($command == "delete") {
+ setState("Deleted", $tmpFile);
+} else if ($state == "Uninitialized") {
+ header("Content-Type: text/cache-manifest");
+ print("CACHE MANIFEST\n");
+ print("NETWORK:\n");
+ print("fail-on-update.php?command=\n");
+} else if ($state == "Deleted") {
+ header('HTTP/1.0 404 Not Found');
+}
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/fallback-redirect.php b/LayoutTests/http/tests/appcache/resources/fallback-redirect.php
new file mode 100644
index 0000000..deb101a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/fallback-redirect.php
@@ -0,0 +1,8 @@
+<?php
+ header('HTTP/1.1 307 Temporary Redirect');
+ header('Location: http://localhost:8000/appcache/resources/simple.txt');
+
+ header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+ header("Cache-Control: no-cache, must-revalidate");
+ header("Pragma: no-cache");
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/fallback.manifest b/LayoutTests/http/tests/appcache/resources/fallback.manifest
new file mode 100644
index 0000000..7375c7d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/fallback.manifest
@@ -0,0 +1,5 @@
+CACHE MANIFEST
+FALLBACK:
+/resources/network-simulator.php? simple.txt
+fallback-redirect simple.txt
+does-not-exist simple.txt \ No newline at end of file
diff --git a/LayoutTests/http/tests/appcache/resources/foreign-iframe-subresource.js b/LayoutTests/http/tests/appcache/resources/foreign-iframe-subresource.js
new file mode 100644
index 0000000..01b2b2a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/foreign-iframe-subresource.js
@@ -0,0 +1 @@
+parent.postMessage("allDone", "*");
diff --git a/LayoutTests/http/tests/appcache/resources/foreign-iframe.html b/LayoutTests/http/tests/appcache/resources/foreign-iframe.html
new file mode 100644
index 0000000..0b008bc
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/foreign-iframe.html
@@ -0,0 +1,4 @@
+<html manifest="foreign-iframe.manifest">
+<div>Subframe</div>
+<script src="foreign-iframe-subresource.js"></script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/foreign-iframe.manifest b/LayoutTests/http/tests/appcache/resources/foreign-iframe.manifest
new file mode 100644
index 0000000..fc0c2f9
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/foreign-iframe.manifest
@@ -0,0 +1,4 @@
+CACHE MANIFEST
+simple.txt
+foreign-iframe.html
+foreign-iframe-subresource.js
diff --git a/LayoutTests/http/tests/appcache/resources/idempotent-update.manifest b/LayoutTests/http/tests/appcache/resources/idempotent-update.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/idempotent-update.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/intercept/.htaccess b/LayoutTests/http/tests/appcache/resources/intercept/.htaccess
new file mode 100644
index 0000000..bfd3b30
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/intercept/.htaccess
@@ -0,0 +1,2 @@
+RewriteEngine on
+RewriteRule ^.* /appcache/resources/print-uri.php [L,NS]
diff --git a/LayoutTests/http/tests/appcache/resources/local-content.manifest b/LayoutTests/http/tests/appcache/resources/local-content.manifest
new file mode 100644
index 0000000..d62c274
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/local-content.manifest
@@ -0,0 +1,4 @@
+CACHE MANIFEST
+/appcache/local-content.html
+NETWORK:
+file:/ # Should be ignored due to different URL scheme, but it doesn't hurt to try.
diff --git a/LayoutTests/http/tests/appcache/resources/main-resource-hash-frame.html b/LayoutTests/http/tests/appcache/resources/main-resource-hash-frame.html
new file mode 100644
index 0000000..6fc1260
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/main-resource-hash-frame.html
@@ -0,0 +1,27 @@
+<html manifest="/appcache/resources/main-resource-hash-frame.manifest#foo">
+<div id=result></div>
+<script>
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+applicationCache.onchecking = function() { log("checking"); }
+applicationCache.ondownloading = function() { log("downloading") }
+applicationCache.onprogress = function() { log("progress") }
+applicationCache.onupdateready = function() { log("updateready") }
+applicationCache.onobsolete = function() { log("obsolete") }
+applicationCache.oncached = function() { log("cached"); loaded(); }
+applicationCache.onnoupdate = function() { log("noupdate"); loaded(); }
+applicationCache.onerror = function() { log("error"); loaded(); }
+
+var once = 1;
+function loaded()
+{
+ if (once) {
+ once = 0;
+ parent.postMessage("loaded", "*");
+ }
+}
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/main-resource-hash-frame.manifest b/LayoutTests/http/tests/appcache/resources/main-resource-hash-frame.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/main-resource-hash-frame.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/manifest-containing-itself.manifest b/LayoutTests/http/tests/appcache/resources/manifest-containing-itself.manifest
new file mode 100644
index 0000000..eb5c126
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/manifest-containing-itself.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+manifest-containing-itself.manifest
diff --git a/LayoutTests/http/tests/appcache/resources/manifest-parsing.manifest b/LayoutTests/http/tests/appcache/resources/manifest-parsing.manifest
new file mode 100644
index 0000000..db694ac
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/manifest-parsing.manifest
@@ -0,0 +1,6 @@
+CACHE MANIFEST ignored text
+ empty.txt
+
+simple.txt ignored text
+UNKNOWN_SECTION:
+not-in-cache.txt
diff --git a/LayoutTests/http/tests/appcache/resources/manifest-redirect-2.php b/LayoutTests/http/tests/appcache/resources/manifest-redirect-2.php
new file mode 100644
index 0000000..e3bc158
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/manifest-redirect-2.php
@@ -0,0 +1,7 @@
+<?php
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header('HTTP/1.1 307 Temporary Redirect');
+header('Location: manifest-redirect-2.php');
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/manifest-redirect.php b/LayoutTests/http/tests/appcache/resources/manifest-redirect.php
new file mode 100644
index 0000000..e2f32eb
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/manifest-redirect.php
@@ -0,0 +1,7 @@
+<?php
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header('HTTP/1.1 307 Temporary Redirect');
+header('Location: simple.manifest');
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/manifest-with-empty-file.manifest b/LayoutTests/http/tests/appcache/resources/manifest-with-empty-file.manifest
new file mode 100644
index 0000000..aab054b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/manifest-with-empty-file.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+empty.txt
diff --git a/LayoutTests/http/tests/appcache/resources/maxsize.manifest b/LayoutTests/http/tests/appcache/resources/maxsize.manifest
new file mode 100644
index 0000000..934fa6c
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/maxsize.manifest
@@ -0,0 +1,3 @@
+CACHE MANIFEST
+#v1
+abe.png
diff --git a/LayoutTests/http/tests/appcache/resources/navigating-away-while-cache-attempt-in-progress.manifest b/LayoutTests/http/tests/appcache/resources/navigating-away-while-cache-attempt-in-progress.manifest
new file mode 100644
index 0000000..10f6ddb
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/navigating-away-while-cache-attempt-in-progress.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+slow-resource.php
diff --git a/LayoutTests/http/tests/appcache/resources/non-html.manifest b/LayoutTests/http/tests/appcache/resources/non-html.manifest
new file mode 100644
index 0000000..dc8db7a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/non-html.manifest
@@ -0,0 +1,8 @@
+CACHE MANIFEST
+/appcache/non-html.xhtml
+/resources/network-simulator.php?path=/appcache/resources/simple.txt
+/resources/network-simulator.php?path=/appcache/resources/abe.png
+/resources/network-simulator.php?path=/appcache/resources/non-html.manifest
+NETWORK:
+/favicon.ico
+/resources/network-simulator.php?command=
diff --git a/LayoutTests/http/tests/appcache/resources/not-in-cache.txt b/LayoutTests/http/tests/appcache/resources/not-in-cache.txt
new file mode 100644
index 0000000..a580081
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/not-in-cache.txt
@@ -0,0 +1 @@
+This file is not in the cache and is thus not possible to load. \ No newline at end of file
diff --git a/LayoutTests/http/tests/appcache/resources/offline-access-frame.html b/LayoutTests/http/tests/appcache/resources/offline-access-frame.html
new file mode 100644
index 0000000..68ef274
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/offline-access-frame.html
@@ -0,0 +1,30 @@
+<html manifest="/resources/network-simulator.php?path=/appcache/resources/offline-access.manifest">
+<div id=result></div>
+<script>
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+applicationCache.onchecking = function() { log("checking"); }
+applicationCache.ondownloading = function() { log("downloading") }
+applicationCache.onprogress = function() { log("progress") }
+applicationCache.onupdateready = function() { log("updateready") }
+applicationCache.onobsolete = function() { log("obsolete") }
+</script>
+<script src="/resources/network-simulator.php?path=/appcache/resources/offline-access.js"></script>
+<script>
+
+applicationCache.oncached = function() { log("cached"); test() }
+applicationCache.onnoupdate = function() { log("noupdate"); test() }
+applicationCache.onerror = function() { log("error"); test() }
+
+if (applicationCache.status == applicationCache.IDLE) {
+ // Update finished while we were waiting for offline-access.js to load.
+ applicationCache.oncached = function() { log("cached") }
+ applicationCache.onnoupdate = function() { log("noupdate") }
+ applicationCache.onerror = function() { log("error") }
+ test();
+}
+
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/offline-access.js b/LayoutTests/http/tests/appcache/resources/offline-access.js
new file mode 100644
index 0000000..a69d73e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/offline-access.js
@@ -0,0 +1,18 @@
+function test()
+{
+ applicationCache.oncached = function() { log("cached") }
+ applicationCache.onnoupdate = function() { log("noupdate") }
+ applicationCache.onerror = function() { log("error") }
+
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "/resources/network-simulator.php?path=/appcache/resources/simple.txt", false);
+ req.send(null);
+ if (req.responseText == "Hello, World!")
+ parent.postMessage("done", "*");
+ else
+ alert("FAIL, unexpected response: " + ex);
+ } catch (ex) {
+ alert("FAIL, unexpected error: " + ex);
+ }
+}
diff --git a/LayoutTests/http/tests/appcache/resources/offline-access.manifest b/LayoutTests/http/tests/appcache/resources/offline-access.manifest
new file mode 100644
index 0000000..5142e38
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/offline-access.manifest
@@ -0,0 +1,5 @@
+CACHE MANIFEST
+/resources/network-simulator.php?path=/appcache/resources/offline-access-frame.html
+/resources/network-simulator.php?path=/appcache/resources/offline-access.manifest
+/resources/network-simulator.php?path=/appcache/resources/simple.txt
+/resources/network-simulator.php?path=/appcache/resources/offline-access.js
diff --git a/LayoutTests/http/tests/appcache/resources/online-whitelist.manifest b/LayoutTests/http/tests/appcache/resources/online-whitelist.manifest
new file mode 100644
index 0000000..892bf8d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/online-whitelist.manifest
@@ -0,0 +1,14 @@
+CACHE MANIFEST
+counter.php?cached
+
+NETWORK:
+# These are prefixes for requests we test, but they are not same origin, so they will be skipped.
+http://
+http://127
+http://127.0.0.1:8
+
+# This should be ignored, because explicit entries are checked before online whitelist
+counter.php?cached
+
+# This should work normally.
+counter.php?uncached \ No newline at end of file
diff --git a/LayoutTests/http/tests/appcache/resources/print-uri.php b/LayoutTests/http/tests/appcache/resources/print-uri.php
new file mode 100644
index 0000000..23358f1
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/print-uri.php
@@ -0,0 +1,7 @@
+<?php
+ header("Content-Type: text/javascript");
+ header("Expires: Thu, 01 Dec 2003 16:00:00 GMT\n");
+ header("Cache-Control: no-cache, must-revalidate\n");
+ header("Pragma: no-cache\n");
+ echo $_SERVER['REQUEST_URI'];
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/reload-iframe.html b/LayoutTests/http/tests/appcache/resources/reload-iframe.html
new file mode 100644
index 0000000..7575bab
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/reload-iframe.html
@@ -0,0 +1,21 @@
+<html manifest="reload-iframe.manifest">
+<body>
+<script>
+function test()
+{
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", "resources/not-in-cache.txt", false);
+ req.send("");
+ parent.postMessage("FAIL: Loading an uncached resource didn't raise an exception", "*");
+ } catch (e) {
+ parent.postMessage("SUCCESS", "*");
+ }
+}
+
+applicationCache.onnoupdate = function() { parent.postMessage("Frame loaded", "*") }
+applicationCache.oncached = function() { parent.postMessage("Frame loaded", "*") }
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/reload-iframe.manifest b/LayoutTests/http/tests/appcache/resources/reload-iframe.manifest
new file mode 100644
index 0000000..668f974
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/reload-iframe.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+/appcache/resources/simple.txt
diff --git a/LayoutTests/http/tests/appcache/resources/remove-cache-frame-2.html b/LayoutTests/http/tests/appcache/resources/remove-cache-frame-2.html
new file mode 100644
index 0000000..009a8b6
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/remove-cache-frame-2.html
@@ -0,0 +1,37 @@
+<html manifest="fail-on-update.php">
+<body>
+<div id=result></div>
+<script>
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function test()
+{
+ log("cached")
+ log("status=" + applicationCache.status);
+ applicationCache.onnoupdate = null;
+
+ // Associated to a cache, so loading should fail
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "empty.txt", false);
+ req.send(null);
+ alert("FAIL: XMLHttpRequest for an uncached resource didn't raise an exception");
+ } catch (ex) {
+ }
+ log("There should be no messages below.");
+ parent.postMessage("frameDone", "*");
+}
+
+applicationCache.onupdateready = function() { log("updateready"); alert("Unexpected onupdateready event in frame") }
+applicationCache.onerror = function() { log("error"); alert("Unexpected error event in frame") }
+applicationCache.onnoupdate = function() { log("noupdate"); alert("Unexpected noupdate event in frame") }
+applicationCache.onobsolete = function() { log("obsolete"); alert("Unexpected obsolete event in frame") }
+
+applicationCache.oncached = test;
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/remove-cache-frame.html b/LayoutTests/http/tests/appcache/resources/remove-cache-frame.html
new file mode 100644
index 0000000..30e8553
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/remove-cache-frame.html
@@ -0,0 +1,64 @@
+<html manifest="fail-on-update.php">
+<body>
+<div id=result></div>
+<script>
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function onObsolete()
+{
+ log("obsolete")
+ log("status=" + applicationCache.status + " (expected 5)");
+ applicationCache.onobsolete = function() { log("obsolete") }
+ applicationCache.onupdateready = function() { log("updateready") }
+ applicationCache.onnoupdate = function() { log("noupdate") }
+ applicationCache.onnoupdate = function() { log("error") }
+
+ // We still have a cache, so loading should fail
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "empty.txt", false);
+ req.send(null);
+ alert("FAIL: XMLHttpRequest for an uncached resource didn't raise an exception");
+ } catch (ex) {
+ }
+ log("There should be no messages below.");
+}
+
+function onError()
+{
+ if (applicationCache.status != applicationCache.UNCACHED && applicationCache.status != applicationCache.OBSOLETE) {
+ timeoutId = setTimeout(onNoManifest, 100);
+ return;
+ }
+
+ log("error");
+ applicationCache.onobsolete = function() { log("obsolete") }
+ applicationCache.onupdateready = function() { log("updateready") }
+ applicationCache.onnoupdate = function() { log("noupdate") }
+ applicationCache.onnoupdate = function() { log("error") }
+
+ // Ensure that we are not associated with a cache.
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "empty.txt", false);
+ req.send(null);
+ } catch (ex) {
+ alert("FAIL: XMLHttpRequest raised an exception, " + ex);
+ }
+ log("There should be no messages below.");
+ parent.postMessage("frameDone - timeout", "*");
+}
+
+applicationCache.onupdateready = function() { log("updateready"); alert("Unexpected updateready event in frame") }
+applicationCache.onnoupdate = function() { log("noupdate") }
+applicationCache.oncached = function() { log("cached"); alert("Unexpected cached event in frame") }
+
+applicationCache.onobsolete = onObsolete;
+applicationCache.onerror = onError;
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/resource-redirect-2.manifest b/LayoutTests/http/tests/appcache/resources/resource-redirect-2.manifest
new file mode 100644
index 0000000..66cd3fe
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/resource-redirect-2.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+resource-redirect-2.php
diff --git a/LayoutTests/http/tests/appcache/resources/resource-redirect-2.php b/LayoutTests/http/tests/appcache/resources/resource-redirect-2.php
new file mode 100644
index 0000000..ac1e8f5
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/resource-redirect-2.php
@@ -0,0 +1,7 @@
+<?php
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header('HTTP/1.1 307 Temporary Redirect');
+header('Location: resource-redirect-2.php');
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/resource-redirect.manifest b/LayoutTests/http/tests/appcache/resources/resource-redirect.manifest
new file mode 100644
index 0000000..e94651d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/resource-redirect.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+resource-redirect.php
diff --git a/LayoutTests/http/tests/appcache/resources/resource-redirect.php b/LayoutTests/http/tests/appcache/resources/resource-redirect.php
new file mode 100644
index 0000000..07931fb
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/resource-redirect.php
@@ -0,0 +1,7 @@
+<?php
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header('HTTP/1.1 307 Temporary Redirect');
+header('Location: simple.txt');
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/simple.manifest b/LayoutTests/http/tests/appcache/resources/simple.manifest
new file mode 100644
index 0000000..3a210f3
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/simple.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+simple.txt
diff --git a/LayoutTests/http/tests/appcache/resources/simple.txt b/LayoutTests/http/tests/appcache/resources/simple.txt
new file mode 100644
index 0000000..b45ef6f
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/simple.txt
@@ -0,0 +1 @@
+Hello, World! \ No newline at end of file
diff --git a/LayoutTests/http/tests/appcache/resources/slow-resource.php b/LayoutTests/http/tests/appcache/resources/slow-resource.php
new file mode 100644
index 0000000..b720ba1
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/slow-resource.php
@@ -0,0 +1,3 @@
+<?php
+sleep(10);
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/subframe-1.html b/LayoutTests/http/tests/appcache/resources/subframe-1.html
new file mode 100644
index 0000000..629c030
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/subframe-1.html
@@ -0,0 +1,7 @@
+<script>
+var req = new XMLHttpRequest;
+req.open("GET", "simple.txt", false);
+req.send(null);
+if (req.responseText.length > 0)
+ parent.postMessage("allDone", "*");
+</script>
diff --git a/LayoutTests/http/tests/appcache/resources/subframe-2.html b/LayoutTests/http/tests/appcache/resources/subframe-2.html
new file mode 100644
index 0000000..9fb6c0f
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/subframe-2.html
@@ -0,0 +1,11 @@
+<script>
+try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "simple.txt", false);
+ req.send(null);
+ alert("FAIL, unexpected response: " + req.responseText);
+} catch (ex) {
+ // Loading should fail, because simple.txt is not in cache manifest.
+ parent.postMessage("allDone", "*");
+}
+</script>
diff --git a/LayoutTests/http/tests/appcache/resources/subframe-3.html b/LayoutTests/http/tests/appcache/resources/subframe-3.html
new file mode 100644
index 0000000..b708408
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/subframe-3.html
@@ -0,0 +1,26 @@
+<html manifest="subframes-3.manifest">
+<script>
+function test()
+{
+ applicationCache.onnoupdate = null;
+
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "simple.txt", false);
+ req.send(null);
+ alert("FAIL, unexpected response: " + req.responseText);
+ } catch (ex) {
+ // Loading should fail, because simple.txt is not in cache manifest.
+ parent.postMessage("allDone", "*");
+ }
+}
+
+// The cache has been fully created before the iframe was inserted, and the manifest didn't change.
+applicationCache.onnoupdate = test;
+
+applicationCache.onupdateready = function() { alert("Unexpected updateready event") }
+applicationCache.oncached = function() { alert("Unexpected cached event") }
+applicationCache.onerror = function() { alert("Unexpected error event") }
+
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/subframe-4.html b/LayoutTests/http/tests/appcache/resources/subframe-4.html
new file mode 100644
index 0000000..da03679
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/subframe-4.html
@@ -0,0 +1,26 @@
+<html manifest="subframes-4.manifest">
+<script>
+function test()
+{
+ applicationCache.onnoupdate = null;
+
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "simple.txt", false);
+ req.send(null);
+ alert("FAIL, unexpected response: " + req.responseText);
+ } catch (ex) {
+ // Loading should fail, because simple.txt is not in cache manifest.
+ parent.postMessage("allDone", "*");
+ }
+}
+
+// The cache has been fully created before the iframe was inserted, and the manifest didn't change.
+applicationCache.onnoupdate = test;
+
+applicationCache.onupdateready = function() { alert("Unexpected updateready event") }
+applicationCache.oncached = function() { alert("Unexpected cached event") }
+applicationCache.onerror = function() { alert("Unexpected error event") }
+
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/subframes-1.manifest b/LayoutTests/http/tests/appcache/resources/subframes-1.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/subframes-1.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/subframes-2.manifest b/LayoutTests/http/tests/appcache/resources/subframes-2.manifest
new file mode 100644
index 0000000..645a34f
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/subframes-2.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+subframe-2.html
diff --git a/LayoutTests/http/tests/appcache/resources/subframes-3.manifest b/LayoutTests/http/tests/appcache/resources/subframes-3.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/subframes-3.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/subframes-4.manifest b/LayoutTests/http/tests/appcache/resources/subframes-4.manifest
new file mode 100644
index 0000000..f4e7937
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/subframes-4.manifest
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+subframe-4.html
diff --git a/LayoutTests/http/tests/appcache/resources/uncacheable-resource.php b/LayoutTests/http/tests/appcache/resources/uncacheable-resource.php
new file mode 100644
index 0000000..ddfe07d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/uncacheable-resource.php
@@ -0,0 +1,13 @@
+<?php
+# This resource won't be cached by network layer, but will be cached by appcache.
+header("Last-Modified: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, no-store");
+header("Pragma: no-cache");
+header("Content-Type: text/plain");
+
+if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] || $_SERVER['HTTP_IF_NONE_MATCH'])
+ header("HTTP/1.1 304 Not Modified");
+else
+ print("Hello, world!\n");
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/versioned-manifest.php b/LayoutTests/http/tests/appcache/resources/versioned-manifest.php
new file mode 100644
index 0000000..84a7a91
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/versioned-manifest.php
@@ -0,0 +1,37 @@
+<?php
+require_once '../../resources/portabilityLayer.php';
+
+$tmpFile = sys_get_temp_dir() . "/" . "appcache_manifest_counter";
+
+function getCount($file)
+{
+ if (!file_exists($file)) {
+ file_put_contents($file, "0");
+ return "0";
+ }
+ return file_get_contents($file);
+}
+
+function stepCounter($file)
+{
+ if (file_exists($file)) {
+ $value = getCount($file);
+ file_put_contents($file, ++$value);
+ }
+}
+
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+header("Content-Type: text/cache-manifest");
+
+if ("step" == $_GET['command'])
+ stepCounter($tmpFile);
+
+print("CACHE MANIFEST\n");
+print("# version " . getCount($tmpFile) . "\n");
+print("counter.php\n");
+print("uncacheable-resource.php\n"); // with Cache-control: no-store
+print("NETWORK:\n");
+print("versioned-manifest.php?command=\n");
+?>
diff --git a/LayoutTests/http/tests/appcache/resources/whitelist-wildcard.manifest b/LayoutTests/http/tests/appcache/resources/whitelist-wildcard.manifest
new file mode 100644
index 0000000..8f88a4a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/whitelist-wildcard.manifest
@@ -0,0 +1,3 @@
+CACHE MANIFEST
+NETWORK:
+*
diff --git a/LayoutTests/http/tests/appcache/resources/wrong-content-type.manifest b/LayoutTests/http/tests/appcache/resources/wrong-content-type.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/wrong-content-type.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/wrong-signature-2.manifest b/LayoutTests/http/tests/appcache/resources/wrong-signature-2.manifest
new file mode 100644
index 0000000..d7d3f8d
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/wrong-signature-2.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST;V2
diff --git a/LayoutTests/http/tests/appcache/resources/wrong-signature.manifest b/LayoutTests/http/tests/appcache/resources/wrong-signature.manifest
new file mode 100644
index 0000000..aab49be
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/wrong-signature.manifest
@@ -0,0 +1 @@
+A CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource-2.manifest b/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource-2.manifest
new file mode 100644
index 0000000..af16a0e
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource-2.manifest
@@ -0,0 +1 @@
+CACHE MANIFEST
diff --git a/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource-frame.html b/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource-frame.html
new file mode 100644
index 0000000..57093fa
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource-frame.html
@@ -0,0 +1,36 @@
+<html manifest="xhr-foreign-resource-2.manifest">
+<body>
+<div id=result></div>
+<script>
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function cached()
+{
+ applicationCache.onnoupdate = null;
+ applicationCache.oncached = null;
+
+ // simple.txt is only listed s a resource in main frame's manifest, so loading should fail.
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "simple.txt", false);
+ req.send("");
+ log("FAIL");
+ log("applicationCache.status = " + applicationCache.status);
+ parent.postMessage("FAIL", "*");
+ } catch (ex) {
+ log("Frame OK");
+ parent.postMessage("SUCCESS", "*");
+ }
+}
+
+applicationCache.onnoupdate = cached;
+applicationCache.oncached = cached;
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource.manifest b/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource.manifest
new file mode 100644
index 0000000..8cfe428
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/xhr-foreign-resource.manifest
@@ -0,0 +1,3 @@
+CACHE MANIFEST
+xhr-foreign-resource-frame.html
+simple.txt
diff --git a/LayoutTests/http/tests/appcache/simple-expected.txt b/LayoutTests/http/tests/appcache/simple-expected.txt
new file mode 100644
index 0000000..1c1a58c
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/simple-expected.txt
@@ -0,0 +1,2 @@
+This tests that the application cache works by first loading a file that does not exist in the cache (to verify that a cache has been associated) and then loads a file that is in the cache
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/simple.html b/LayoutTests/http/tests/appcache/simple.html
new file mode 100644
index 0000000..4342cb7
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/simple.html
@@ -0,0 +1,55 @@
+<html manifest="resources/simple.manifest">
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function cached()
+{
+ var hadError = false;
+
+ // Load a resource that does not exist in the cache.
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", "resources/not-in-cache.txt", false);
+ req.send();
+ } catch (e) {
+ if (e.code == XMLHttpRequestException.NETWORK_ERR)
+ hadError = true;
+ }
+
+ if (!hadError) {
+ document.getElementById('result').innerHTML = "FAILURE: Did not get the right exception"
+ return;
+ }
+
+ // Load a resource that exists in the cache.
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", "resources/simple.txt", false);
+ req.send();
+ } catch (e) {
+ document.getElementById('result').innerHTML = "FAILURE: Could not load data from cache"
+ return;
+ }
+
+ if (req.responseText != 'Hello, World!') {
+ document.getElementById('result').innerHTML = "FAILURE: Did not get correct data from cached resource"
+ return;
+ }
+
+ document.getElementById('result').innerHTML = "SUCCESS"
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+applicationCache.addEventListener('noupdate', cached, false);
+
+</script>
+<div>This tests that the application cache works by first loading a file that does not exist in the cache (to verify that a cache has been associated) and then loads a file that is in the cache</div>
+
+<div id="result">FAILURE</div>
+</html>
diff --git a/LayoutTests/http/tests/appcache/top-frame-1-expected.txt b/LayoutTests/http/tests/appcache/top-frame-1-expected.txt
new file mode 100644
index 0000000..c7f7e37
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/top-frame-1-expected.txt
@@ -0,0 +1,8 @@
+Test that a subframe without manifest doesn't pick an application cache from parent frame (as long as no relevant cache contains its resource).
+
+Techically, the check is that iframe subresources that are not in top frame cache are loaded anyway, so it can also pass if the UA fails to reject loads for cache misses.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/top-frame-1.html b/LayoutTests/http/tests/appcache/top-frame-1.html
new file mode 100644
index 0000000..9e29300
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/top-frame-1.html
@@ -0,0 +1,38 @@
+<html manifest="resources/subframes-1.manifest">
+<body>
+<p>Test that a subframe without manifest doesn't pick an application cache from parent frame
+(as long as no relevant cache contains its resource).</p>
+<p>Techically, the check is that iframe subresources that are not in top frame cache are loaded
+anyway, so it can also pass if the UA fails to reject loads for cache misses.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function test()
+{
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/subframe-1.html");
+ document.body.appendChild(ifr);
+}
+
+applicationCache.addEventListener('noupdate', function() { test() }, false);
+applicationCache.addEventListener('cached', function() { test() }, false);
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+
+window.addEventListener("message", function() { log("SUCCESS"); if (window.layoutTestController) layoutTestController.notifyDone() }, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/top-frame-2-expected.txt b/LayoutTests/http/tests/appcache/top-frame-2-expected.txt
new file mode 100644
index 0000000..6e99bb6
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/top-frame-2-expected.txt
@@ -0,0 +1,7 @@
+Test that a subframe without manifest gets picked by a relevant application cache that contains its resource.
+
+Should say SUCCESS:
+
+checking
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/top-frame-2.html b/LayoutTests/http/tests/appcache/top-frame-2.html
new file mode 100644
index 0000000..c239d08
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/top-frame-2.html
@@ -0,0 +1,42 @@
+<html manifest="resources/subframes-2.manifest">
+<body>
+<p>Test that a subframe without manifest gets picked by a relevant application cache that
+contains its resource.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function test()
+{
+ applicationCache.onnoupdate = null;
+ applicationCache.oncached = null;
+
+ // When a new main resource is associated with the cache, an update should be started.
+ applicationCache.onchecking = function() { log("checking") }
+
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/subframe-2.html");
+ document.body.appendChild(ifr);
+}
+
+applicationCache.onnoupdate = function() { test() }
+applicationCache.oncached = function() { test() }
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+
+window.addEventListener("message", function() { log("SUCCESS"); if (window.layoutTestController) layoutTestController.notifyDone() }, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/top-frame-3-expected.txt b/LayoutTests/http/tests/appcache/top-frame-3-expected.txt
new file mode 100644
index 0000000..a10dbee
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/top-frame-3-expected.txt
@@ -0,0 +1,10 @@
+Test that a subframe with manifest that matches top frame manifest works correctly.
+
+In this case, the subframe resource is NOT listed in manifest explicitly.
+
+Should say SUCCESS:
+
+checking
+checking
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/top-frame-3.html b/LayoutTests/http/tests/appcache/top-frame-3.html
new file mode 100644
index 0000000..9fc9dde
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/top-frame-3.html
@@ -0,0 +1,60 @@
+<html manifest="resources/subframes-3.manifest">
+<body>
+<p>Test that a subframe with manifest that matches top frame manifest works correctly.</p>
+<p>In this case, the subframe resource is NOT listed in manifest explicitly.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function test()
+{
+ applicationCache.onnoupdate = null;
+ applicationCache.oncached = null;
+
+ // When a new main resource is associated with the cache, an update should be started.
+ applicationCache.onchecking = function() { log("checking") }
+
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/subframe-3.html");
+ document.body.appendChild(ifr);
+}
+
+function test2()
+{
+ window.removeEventListener("message", test2, false);
+ window.addEventListener("message", test3, false);
+
+ // Add an identical frame, to test that loading its resources from appcache works.
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/subframe-3.html");
+ document.body.appendChild(ifr);
+}
+
+function test3()
+{
+ log("SUCCESS");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.onnoupdate = function() { test() }
+applicationCache.oncached = function() { test() }
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+
+window.addEventListener("message", test2, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/top-frame-4-expected.txt b/LayoutTests/http/tests/appcache/top-frame-4-expected.txt
new file mode 100644
index 0000000..43bfd43
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/top-frame-4-expected.txt
@@ -0,0 +1,10 @@
+Test that a subframe with manifest that matches top frame manifest works correctly.
+
+In this case, the subframe resource is listed in manifest explicitly.
+
+Should say SUCCESS:
+
+checking
+checking
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/top-frame-4.html b/LayoutTests/http/tests/appcache/top-frame-4.html
new file mode 100644
index 0000000..39743b9
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/top-frame-4.html
@@ -0,0 +1,60 @@
+<html manifest="resources/subframes-4.manifest">
+<body>
+<p>Test that a subframe with manifest that matches top frame manifest works correctly.</p>
+<p>In this case, the subframe resource is listed in manifest explicitly.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function test()
+{
+ applicationCache.onnoupdate = null;
+ applicationCache.oncached = null;
+
+ // When a new main resource is associated with the cache, an update should be started.
+ applicationCache.onchecking = function() { log("checking") }
+
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/subframe-4.html");
+ document.body.appendChild(ifr);
+}
+
+function test2()
+{
+ window.removeEventListener("message", test2, false);
+ window.addEventListener("message", test3, false);
+
+ // Add an identical frame, to test that loading its resources from appcache works.
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/subframe-4.html");
+ document.body.appendChild(ifr);
+}
+
+function test3()
+{
+ log("SUCCESS");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.onnoupdate = function() { test() }
+applicationCache.oncached = function() { test() }
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+
+window.addEventListener("message", test2, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/update-cache-expected.txt b/LayoutTests/http/tests/appcache/update-cache-expected.txt
new file mode 100644
index 0000000..a6d95d4
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/update-cache-expected.txt
@@ -0,0 +1,10 @@
+Test a simple offline application self-update process. Should print a series of messages followed with DONE:
+
+Updating cache group...
+Cache status is UPDATEREADY
+Updating cache group once more...
+Cache status is UPDATEREADY
+Associating document with the newest cache version...
+Cache status is IDLE
+DONE
+
diff --git a/LayoutTests/http/tests/appcache/update-cache.html b/LayoutTests/http/tests/appcache/update-cache.html
new file mode 100644
index 0000000..dd48b01
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/update-cache.html
@@ -0,0 +1,69 @@
+<html manifest="resources/versioned-manifest.php">
+<body>
+<p>Test a simple offline application self-update process. Should print a series of messages followed with DONE:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function modifyManifest()
+{
+ var req = new XMLHttpRequest;
+ req.open("GET", "resources/versioned-manifest.php?command=step", false);
+ req.send(false);
+}
+
+function test()
+{
+ modifyManifest();
+
+ applicationCache.oncached = function() { log("FAIL: Unexpected cached event") }
+ applicationCache.onnoupdate = function() { log("FAIL: Unexpected noupdate event") }
+ applicationCache.onupdateready = function() { setTimeout(test2, 0) }
+
+ log("Updating cache group...");
+ setTimeout("applicationCache.update()", 0);
+}
+
+function test2()
+{
+ log((applicationCache.status == applicationCache.UPDATEREADY) ? "Cache status is UPDATEREADY" : ("FAIL: Incorrect cache status, " + applicationCache.status));
+
+ modifyManifest();
+ applicationCache.onupdateready = function() { setTimeout(test3, 0) }
+
+ log("Updating cache group once more...");
+ setTimeout("applicationCache.update()", 0);
+}
+
+function test3()
+{
+ log((applicationCache.status == applicationCache.UPDATEREADY) ? "Cache status is UPDATEREADY" : ("FAIL: Incorrect cache status, " + applicationCache.status));
+
+ log("Associating document with the newest cache version...");
+ applicationCache.swapCache();
+
+ log((applicationCache.status == applicationCache.IDLE) ? "Cache status is IDLE" : ("FAIL: Incorrect cache status, " + applicationCache.status));
+
+ log("DONE");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.oncached = test;
+applicationCache.onnoupdate = test;
+applicationCache.onupdateready = function() { log("FAIL: Unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: Unexpected error event") }
+applicationCache.onobsolete = function() { log("FAIL: Unexpected obsolete event") }
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/whitelist-wildcard-expected.txt b/LayoutTests/http/tests/appcache/whitelist-wildcard-expected.txt
new file mode 100644
index 0000000..b503f12
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/whitelist-wildcard-expected.txt
@@ -0,0 +1,3 @@
+Test that online whitelist wildcard flag is implemented.
+
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/whitelist-wildcard.html b/LayoutTests/http/tests/appcache/whitelist-wildcard.html
new file mode 100644
index 0000000..01bc892
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/whitelist-wildcard.html
@@ -0,0 +1,29 @@
+<html manifest="resources/whitelist-wildcard.manifest">
+<body>
+<p>Test that online whitelist wildcard flag is implemented.</p>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function test()
+{
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "resources/empty.txt", false);
+ req.send();
+ document.body.appendChild(document.createTextNode("SUCCESS"));
+ } catch (ex) {
+ document.body.appendChild(document.createTextNode(ex));
+ }
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.oncached = test;
+applicationCache.onnoupdate = test;
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/wrong-content-type-expected.txt b/LayoutTests/http/tests/appcache/wrong-content-type-expected.txt
new file mode 100644
index 0000000..d13447a
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/wrong-content-type-expected.txt
@@ -0,0 +1,6 @@
+Test that a manifest served with a wrong content-type isn't treated as such.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/wrong-content-type.html b/LayoutTests/http/tests/appcache/wrong-content-type.html
new file mode 100644
index 0000000..7b3bf6c
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/wrong-content-type.html
@@ -0,0 +1,40 @@
+<html manifest="resources/wrong-content-type.manifest">
+<body>
+<p>Test that a manifest served with a wrong content-type isn't treated as such.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function cacheCallback()
+{
+ log("FAIL: An event was dispatched on window.applicationCache, even though it was not associated wuth any cache yet.");
+}
+
+function test()
+{
+ // Wait for cache update to finish.
+ if (window.applicationCache.status != window.applicationCache.UNCACHED)
+ log("FAILURE: Unexpected cache status: " + window.applicationCache.status);
+ else
+ log("SUCCESS");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', function() { log("cached"); cacheCallback() }, false);
+applicationCache.addEventListener('noupdate', function() { log("noupdate"); cacheCallback() }, false);
+applicationCache.addEventListener('error', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/wrong-signature-2-expected.txt b/LayoutTests/http/tests/appcache/wrong-signature-2-expected.txt
new file mode 100644
index 0000000..c89843b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/wrong-signature-2-expected.txt
@@ -0,0 +1,6 @@
+Test that a manifest served with a wrong signature isn't treated as such.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/wrong-signature-2.html b/LayoutTests/http/tests/appcache/wrong-signature-2.html
new file mode 100644
index 0000000..9b26d02
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/wrong-signature-2.html
@@ -0,0 +1,40 @@
+<html manifest="resources/wrong-signature-2.manifest">
+<body>
+<p>Test that a manifest served with a wrong signature isn't treated as such.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function cacheCallback()
+{
+ log("FAIL: An event was dispatched on window.applicationCache, even though it was not associated wuth any cache yet.");
+}
+
+function test()
+{
+ // Wait for cache update to finish.
+ if (window.applicationCache.status != window.applicationCache.UNCACHED)
+ log("FAILURE: Unexpected cache status: " + window.applicationCache.status);
+ else
+ log("SUCCESS");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', function() { log("cached"); cacheCallback() }, false);
+applicationCache.addEventListener('noupdate', function() { log("noupdate"); cacheCallback() }, false);
+applicationCache.addEventListener('error', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/wrong-signature-expected.txt b/LayoutTests/http/tests/appcache/wrong-signature-expected.txt
new file mode 100644
index 0000000..c89843b
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/wrong-signature-expected.txt
@@ -0,0 +1,6 @@
+Test that a manifest served with a wrong signature isn't treated as such.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/wrong-signature.html b/LayoutTests/http/tests/appcache/wrong-signature.html
new file mode 100644
index 0000000..3b5f747
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/wrong-signature.html
@@ -0,0 +1,40 @@
+<html manifest="resources/wrong-signature.manifest">
+<body>
+<p>Test that a manifest served with a wrong signature isn't treated as such.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function cacheCallback()
+{
+ log("FAIL: An event was dispatched on window.applicationCache, even though it was not associated wuth any cache yet.");
+}
+
+function test()
+{
+ // Wait for cache update to finish.
+ if (window.applicationCache.status != window.applicationCache.UNCACHED)
+ log("FAILURE: Unexpected cache status: " + window.applicationCache.status);
+ else
+ log("SUCCESS");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', function() { log("cached"); cacheCallback() }, false);
+applicationCache.addEventListener('noupdate', function() { log("noupdate"); cacheCallback() }, false);
+applicationCache.addEventListener('error', test, false);
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/xhr-foreign-resource-expected.txt b/LayoutTests/http/tests/appcache/xhr-foreign-resource-expected.txt
new file mode 100644
index 0000000..bf67172
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/xhr-foreign-resource-expected.txt
@@ -0,0 +1,6 @@
+Test that a resource marked as foreign can still be loaded via XHR.
+
+Should say SUCCESS:
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/xhr-foreign-resource.html b/LayoutTests/http/tests/appcache/xhr-foreign-resource.html
new file mode 100644
index 0000000..df08d3f
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/xhr-foreign-resource.html
@@ -0,0 +1,79 @@
+<html manifest="resources/xhr-foreign-resource.manifest">
+<body>
+<p>Test that a resource marked as foreign can still be loaded via XHR.</p>
+<p>Should say SUCCESS:</p>
+<div id=result></div>
+
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+ document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function createFrame1()
+{
+ applicationCache.onnoupdate = function() { log("FAIL: Unexpected noupdate event") }
+ applicationCache.oncached = function() { log("FAIL: Unexpected cached event") }
+
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/xhr-foreign-resource-frame.html");
+ document.body.appendChild(ifr);
+}
+
+function createFrame2()
+{
+ // A copy that doesn't have its main resource in cache manifest.
+ var ifr = document.createElement("iframe");
+ ifr.setAttribute("src", "resources/xhr-foreign-resource-frame.html?");
+ document.body.appendChild(ifr);
+}
+
+applicationCache.onnoupdate = function() { createFrame1() }
+applicationCache.oncached = function() { createFrame1() }
+
+applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
+applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
+
+var hadErrorFromSubframe = false;
+var subframeMessagesReceived = 0;
+function frameMessageReceived(evt)
+{
+ ++subframeMessagesReceived;
+ if (evt.data != "SUCCESS")
+ hadErrorFromSubframe = true;
+ if (subframeMessagesReceived == 1)
+ setTimeout(createFrame2, 0);
+ else if (subframeMessagesReceived == 2)
+ test();
+}
+
+function test(evt)
+{
+ if (!hadErrorFromSubframe) {
+ // The subframe has a different cache, but it is also listed as a resource in main frame's
+ // manifest, so it should be loaded successfully despite being marked as foreign now.
+ try {
+ var req = new XMLHttpRequest;
+ req.open("GET", "resources/xhr-foreign-resource-frame.html", false);
+ req.send("");
+ log("SUCCESS");
+ } catch (ex) {
+ log (ex);
+ }
+ } else
+ log("FAIL: subframe didn't get a correct cache");
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+window.addEventListener("message", frameMessageReceived, false);
+
+</script>
+</body>
+</html>