diff options
author | Ben Murdoch <benm@google.com> | 2010-10-22 13:02:20 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-10-26 15:21:41 +0100 |
commit | a94275402997c11dd2e778633dacf4b7e630a35d (patch) | |
tree | e66f56c67e3b01f22c9c23cd932271ee9ac558ed /LayoutTests/http/tests/appcache | |
parent | 09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff) | |
download | external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2 |
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'LayoutTests/http/tests/appcache')
23 files changed, 341 insertions, 0 deletions
diff --git a/LayoutTests/http/tests/appcache/document-write-html-element-2-expected.txt b/LayoutTests/http/tests/appcache/document-write-html-element-2-expected.txt new file mode 100644 index 0000000..32581f4 --- /dev/null +++ b/LayoutTests/http/tests/appcache/document-write-html-element-2-expected.txt @@ -0,0 +1,2 @@ +SUCCESS, no assertion failure +applicationCache.status == 1 diff --git a/LayoutTests/http/tests/appcache/document-write-html-element-2.html b/LayoutTests/http/tests/appcache/document-write-html-element-2.html new file mode 100644 index 0000000..bee9fe0 --- /dev/null +++ b/LayoutTests/http/tests/appcache/document-write-html-element-2.html @@ -0,0 +1,19 @@ +<html manifest="resources/document-write-html-element.manifest"> +<script> +if (window.layoutTestController) { + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); +} + +function test() +{ + document.write("SUCCESS, no assertion failure"); + document.write("<br>applicationCache.status == " + applicationCache.status); + + if (window.layoutTestController) + layoutTestController.notifyDone(); +} + +applicationCache.oncached = test; +applicationCache.onnoupdate = test; +</script> diff --git a/LayoutTests/http/tests/appcache/document-write-html-element-expected.txt b/LayoutTests/http/tests/appcache/document-write-html-element-expected.txt new file mode 100644 index 0000000..08dccd3 --- /dev/null +++ b/LayoutTests/http/tests/appcache/document-write-html-element-expected.txt @@ -0,0 +1 @@ +DONE. Passed if there were no alerts displayed. diff --git a/LayoutTests/http/tests/appcache/document-write-html-element.html b/LayoutTests/http/tests/appcache/document-write-html-element.html new file mode 100644 index 0000000..83954bb --- /dev/null +++ b/LayoutTests/http/tests/appcache/document-write-html-element.html @@ -0,0 +1,26 @@ +<script> +if (window.layoutTestController) { + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); +} + +window.onload = function() +{ + document.write("<html manifest='resources/document-write-html-element.manifest'>"); + applicationCache.oncached = function() { + alert("FAIL: appcache cached"); + } + applicationCache.onnoupdate = function() { + alert("FAIL: appcache noupdate"); + } + applicationCache.onerror = function() { + alert("FAIL: appcache error"); + } + + setTimeout(function() { + document.write("DONE. Passed if there were no alerts displayed."); + if (window.layoutTestController) + layoutTestController.notifyDone(); + }, 100); +} +</script> diff --git a/LayoutTests/http/tests/appcache/fail-on-update-2-expected.txt b/LayoutTests/http/tests/appcache/fail-on-update-2-expected.txt new file mode 100644 index 0000000..cd15247 --- /dev/null +++ b/LayoutTests/http/tests/appcache/fail-on-update-2-expected.txt @@ -0,0 +1 @@ +SUCCESS: No crash. diff --git a/LayoutTests/http/tests/appcache/fail-on-update-2.html b/LayoutTests/http/tests/appcache/fail-on-update-2.html new file mode 100644 index 0000000..fcbc3dd --- /dev/null +++ b/LayoutTests/http/tests/appcache/fail-on-update-2.html @@ -0,0 +1,64 @@ +<html manifest="resources/fail-on-update-2.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(); + + // Create two subframes at different times to make hitting the race condition more likely. + var ifr = document.createElement("iframe"); + ifr.setAttribute("src", 'resources/fail-on-update-2.html'); + document.body.appendChild(ifr); + + setTimeout(function() { + var ifr = document.createElement("iframe"); + ifr.setAttribute("src", 'resources/fail-on-update-2.html'); + document.body.appendChild(ifr); + }, 0); +} + +var subframesLeft = 2; +function subframeLoaded() +{ + if (!--subframesLeft) { + document.write('<p>SUCCESS: No crash.</p>'); + 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.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/foreign-fallback-expected.txt b/LayoutTests/http/tests/appcache/foreign-fallback-expected.txt new file mode 100644 index 0000000..dded924 --- /dev/null +++ b/LayoutTests/http/tests/appcache/foreign-fallback-expected.txt @@ -0,0 +1,6 @@ +Test for bug 44406: Application Cache crash when a fallback document has a manifest URL. + +PASS +The frame below should display a Not Found error - the fallback entry is foreign, so it shouldn't be used for main resource. + + diff --git a/LayoutTests/http/tests/appcache/foreign-fallback.html b/LayoutTests/http/tests/appcache/foreign-fallback.html new file mode 100644 index 0000000..7a80046 --- /dev/null +++ b/LayoutTests/http/tests/appcache/foreign-fallback.html @@ -0,0 +1,48 @@ +<html manifest="resources/foreign-fallback.manifest"> +<body> +<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=44406">bug 44406</a>: +Application Cache crash when a fallback document has a manifest URL.</p> +<div id="result">Testing...</div> +<script> +if (window.layoutTestController) { + layoutTestController.waitUntilDone(); + layoutTestController.dumpAsText(); +} + + +applicationCache.addEventListener('cached', test, false); +applicationCache.addEventListener('noupdate', test, false); + +function test() +{ + var ifr = document.createElement("iframe"); + ifr.setAttribute("src", "resources/foreign-fallback/does-not-exist.html"); + document.body.appendChild(ifr); + + // I couldn't find any event that would fire on frame loading failure, so let's poll. + setTimeout(frameDone, 100); +} + +function frameDone() +{ + try { + var frameContent = frames[0].document.documentElement.innerHTML; + if (frameContent.match("Not Found")) + document.getElementById("result").innerHTML = "PASS"; + else if (frameContent.match("FAIL")) + document.getElementById("result").innerHTML = "FAIL"; + else + throw "Try again"; + + if (window.layoutTestController) + layoutTestController.notifyDone(); + } catch (ex) { + // Not done yet. + setTimeout(frameDone, 100); + } +} + +</script> +<p>The frame below should display a Not Found error - the fallback entry is foreign, so it shouldn't be used for main resource.</p> +</body> +</html> diff --git a/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-2-expected.txt b/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-2-expected.txt new file mode 100644 index 0000000..08dccd3 --- /dev/null +++ b/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-2-expected.txt @@ -0,0 +1 @@ +DONE. Passed if there were no alerts displayed. diff --git a/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-2.html b/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-2.html new file mode 100644 index 0000000..539d28b --- /dev/null +++ b/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-2.html @@ -0,0 +1,30 @@ +<html> +<div></div> +<script> +if (window.layoutTestController) { + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); +} + +var div = document.getElementsByTagName("div")[0]; +div.innerHTML = '<html manifest="resources/insert-html-element-with-manifest.manifest">' + +window.onload = function() +{ + applicationCache.oncached = function() { + alert("FAIL: appcache cached"); + } + applicationCache.onnoupdate = function() { + alert("FAIL: appcache noupdate"); + } + applicationCache.onerror = function() { + alert("FAIL: appcache error"); + } + + setTimeout(function() { + document.write("DONE. Passed if there were no alerts displayed."); + if (window.layoutTestController) + layoutTestController.notifyDone(); + }, 100); +} +</script> diff --git a/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-expected.txt b/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-expected.txt new file mode 100644 index 0000000..08dccd3 --- /dev/null +++ b/LayoutTests/http/tests/appcache/insert-html-element-with-manifest-expected.txt @@ -0,0 +1 @@ +DONE. Passed if there were no alerts displayed. diff --git a/LayoutTests/http/tests/appcache/insert-html-element-with-manifest.html b/LayoutTests/http/tests/appcache/insert-html-element-with-manifest.html new file mode 100644 index 0000000..694392c --- /dev/null +++ b/LayoutTests/http/tests/appcache/insert-html-element-with-manifest.html @@ -0,0 +1,31 @@ +<html> +<script> +if (window.layoutTestController) { + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); +} + +document.removeChild(document.documentElement); +var newHTML = document.createElement("html"); +newHTML.setAttribute("manifest", "resources/insert-html-element-with-manifest.manifest"); +document.appendChild(newHTML); + +window.onload = function() +{ + applicationCache.oncached = function() { + alert("FAIL: appcache cached"); + } + applicationCache.onnoupdate = function() { + alert("FAIL: appcache noupdate"); + } + applicationCache.onerror = function() { + alert("FAIL: appcache error"); + } + + setTimeout(function() { + document.write("DONE. Passed if there were no alerts displayed."); + if (window.layoutTestController) + layoutTestController.notifyDone(); + }, 100); +} +</script> diff --git a/LayoutTests/http/tests/appcache/main-resource-redirect-expected.txt b/LayoutTests/http/tests/appcache/main-resource-redirect-expected.txt new file mode 100644 index 0000000..0a727f5 --- /dev/null +++ b/LayoutTests/http/tests/appcache/main-resource-redirect-expected.txt @@ -0,0 +1,4 @@ +Test that application cache is consulted again after a redirect response. + +PASS + diff --git a/LayoutTests/http/tests/appcache/main-resource-redirect.html b/LayoutTests/http/tests/appcache/main-resource-redirect.html new file mode 100644 index 0000000..3ede636 --- /dev/null +++ b/LayoutTests/http/tests/appcache/main-resource-redirect.html @@ -0,0 +1,39 @@ +<html manifest="resources/main-resource-redirect.manifest"> +<body> +<p>Test that application cache is consulted again after a redirect response.</p> +<div id="result">Testing...</div> +<script> +if (window.layoutTestController) { + layoutTestController.waitUntilDone(); + layoutTestController.dumpAsText(); +} + +function setNetworkEnabled(state) +{ + var req = new XMLHttpRequest; + req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false); + req.send(""); +} + +function test() +{ + applicationCache.oncached = null; + applicationCache.onnoupdate = null; + setNetworkEnabled(false); + var ifr = document.createElement("iframe"); + ifr.setAttribute("src", "resources/main-resource-redirect-frame.php"); + document.body.appendChild(ifr); +} + +function done() +{ + if (window.layoutTestController) + layoutTestController.notifyDone(); + setNetworkEnabled(true); +} + +applicationCache.oncached=test; +applicationCache.onnoupdate=test; +applicationCache.onerror = function() { setNetworkEnabled(true); window.location.reload(); } +</script> +</body> diff --git a/LayoutTests/http/tests/appcache/resources/document-write-html-element.manifest b/LayoutTests/http/tests/appcache/resources/document-write-html-element.manifest new file mode 100644 index 0000000..af16a0e --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/document-write-html-element.manifest @@ -0,0 +1 @@ +CACHE MANIFEST diff --git a/LayoutTests/http/tests/appcache/resources/fail-on-update-2.html b/LayoutTests/http/tests/appcache/resources/fail-on-update-2.html new file mode 100644 index 0000000..7e78de7 --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/fail-on-update-2.html @@ -0,0 +1,7 @@ +<html manifest="fail-on-update-2.php"> +<body> +<script> + top.subframeLoaded(); +</script> +</body> +</html> diff --git a/LayoutTests/http/tests/appcache/resources/fail-on-update-2.php b/LayoutTests/http/tests/appcache/resources/fail-on-update-2.php new file mode 100644 index 0000000..4e11735 --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/fail-on-update-2.php @@ -0,0 +1,39 @@ +<?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("fail-on-update-2.html\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/foreign-fallback-fallback.html b/LayoutTests/http/tests/appcache/resources/foreign-fallback-fallback.html new file mode 100644 index 0000000..9996bf6 --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/foreign-fallback-fallback.html @@ -0,0 +1,2 @@ +<html manifest="foobar.manifest"> +FAIL diff --git a/LayoutTests/http/tests/appcache/resources/foreign-fallback.manifest b/LayoutTests/http/tests/appcache/resources/foreign-fallback.manifest new file mode 100644 index 0000000..ddaf602 --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/foreign-fallback.manifest @@ -0,0 +1,4 @@ +CACHE MANIFEST + +FALLBACK: +/appcache/resources/foreign-fallback/ foreign-fallback-fallback.html diff --git a/LayoutTests/http/tests/appcache/resources/insert-html-element-with-manifest.manifest b/LayoutTests/http/tests/appcache/resources/insert-html-element-with-manifest.manifest new file mode 100644 index 0000000..af16a0e --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/insert-html-element-with-manifest.manifest @@ -0,0 +1 @@ +CACHE MANIFEST diff --git a/LayoutTests/http/tests/appcache/resources/main-resource-redirect-frame-2.html b/LayoutTests/http/tests/appcache/resources/main-resource-redirect-frame-2.html new file mode 100644 index 0000000..0acc1e2 --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/main-resource-redirect-frame-2.html @@ -0,0 +1,6 @@ +<html manifest="http://127.0.0.1:8000/appcache/resources/main-resource-redirect.manifest"> +<script> +parent.document.getElementById("result").innerHTML = (applicationCache.status) > 0 ? "PASS" : "FAIL: child frame status is UNCACHED"; +parent.done(); + +</script> diff --git a/LayoutTests/http/tests/appcache/resources/main-resource-redirect-frame.php b/LayoutTests/http/tests/appcache/resources/main-resource-redirect-frame.php new file mode 100644 index 0000000..638057b --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/main-resource-redirect-frame.php @@ -0,0 +1,4 @@ +<?php + header('HTTP/1.0 302 Found'); + header('Location: http://127.0.0.1:8000/resources/network-simulator.php?path=/appcache/resources/main-resource-redirect-frame-2.html'); +?> diff --git a/LayoutTests/http/tests/appcache/resources/main-resource-redirect.manifest b/LayoutTests/http/tests/appcache/resources/main-resource-redirect.manifest new file mode 100644 index 0000000..beffe84 --- /dev/null +++ b/LayoutTests/http/tests/appcache/resources/main-resource-redirect.manifest @@ -0,0 +1,4 @@ +CACHE MANIFEST +http://127.0.0.1:8000/resources/network-simulator.php?path=/appcache/resources/main-resource-redirect-frame-2.html +NETWORK: +http://127.0.0.1:8000/resources/network-simulator.php?command |