Reviewed by Darin Adler.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jan 2009 07:14:18 +0000 (07:14 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Jan 2009 07:14:18 +0000 (07:14 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=23286
        Add a test for non-ASCII URIs in application cache

        * http/tests/appcache/cyrillic-uri-expected.txt: Added.
        * http/tests/appcache/cyrillic-uri.html: Added.
        * http/tests/appcache/resources/cyrillic-uri-form.html: Added.
        * http/tests/appcache/resources/cyrillic-uri.manifest: Added.
        * http/tests/appcache/resources/intercept: Added.
        * http/tests/appcache/resources/intercept/.htaccess: Added.
        * http/tests/appcache/resources/print-uri.php: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39883 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/appcache/cyrillic-uri-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/appcache/cyrillic-uri.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/cyrillic-uri-form.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/cyrillic-uri.manifest [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/intercept/.htaccess [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/print-uri.php [new file with mode: 0644]

index 18c92f7f9eb66b4173f2f4123bc767eb4115ba29..ab68184498335c5836b963fe476ebe2cda3942f7 100644 (file)
@@ -1,3 +1,18 @@
+2009-01-13  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=23286
+        Add a test for non-ASCII URIs in application cache
+
+        * http/tests/appcache/cyrillic-uri-expected.txt: Added.
+        * http/tests/appcache/cyrillic-uri.html: Added.
+        * http/tests/appcache/resources/cyrillic-uri-form.html: Added.
+        * http/tests/appcache/resources/cyrillic-uri.manifest: Added.
+        * http/tests/appcache/resources/intercept: Added.
+        * http/tests/appcache/resources/intercept/.htaccess: Added.
+        * http/tests/appcache/resources/print-uri.php: Added.
+
 2009-01-13  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Darin Adler and Oliver Hunt.
diff --git a/LayoutTests/http/tests/appcache/cyrillic-uri-expected.txt b/LayoutTests/http/tests/appcache/cyrillic-uri-expected.txt
new file mode 100644 (file)
index 0000000..3c3e640
--- /dev/null
@@ -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 (file)
index 0000000..c86a261
--- /dev/null
@@ -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/resources/cyrillic-uri-form.html b/LayoutTests/http/tests/appcache/resources/cyrillic-uri-form.html
new file mode 100644 (file)
index 0000000..a97c508
--- /dev/null
@@ -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 (file)
index 0000000..574ab9e
--- /dev/null
@@ -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/intercept/.htaccess b/LayoutTests/http/tests/appcache/resources/intercept/.htaccess
new file mode 100644 (file)
index 0000000..bfd3b30
--- /dev/null
@@ -0,0 +1,2 @@
+RewriteEngine on
+RewriteRule ^.* /appcache/resources/print-uri.php [L,NS]
diff --git a/LayoutTests/http/tests/appcache/resources/print-uri.php b/LayoutTests/http/tests/appcache/resources/print-uri.php
new file mode 100644 (file)
index 0000000..23358f1
--- /dev/null
@@ -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'];
+?>