2010-04-16 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Apr 2010 07:27:09 +0000 (07:27 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Apr 2010 07:27:09 +0000 (07:27 +0000)
        Reviewed by Adam Barth.

        Test file: URL canonicalization
        https://bugs.webkit.org/show_bug.cgi?id=37700

        * fast/url/script-tests/file.js: Added new test.
        * fast/url/file-expected.txt: Added (expected results).
        * fast/url/file.html: Added (wrapper).

        * fast/url/script-tests/TEMPLATE.html: Add an explicit dependable
        <base> URL to the template, to avoid making test expectations
        system dependent.

        Other test wrappers regenerated for the above change:

        * fast/url/anchor.html:
        * fast/url/ipv4.html:
        * fast/url/path-url.html:
        * fast/url/port.html:
        * fast/url/query.html:
        * fast/url/standard-url.html:
        * fast/url/trivial.html:

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/url/anchor.html
LayoutTests/fast/url/file-expected.txt [new file with mode: 0644]
LayoutTests/fast/url/file.html [new file with mode: 0644]
LayoutTests/fast/url/ipv4.html
LayoutTests/fast/url/path-url.html
LayoutTests/fast/url/port.html
LayoutTests/fast/url/query.html
LayoutTests/fast/url/script-tests/TEMPLATE.html
LayoutTests/fast/url/script-tests/file.js [new file with mode: 0644]
LayoutTests/fast/url/standard-url.html
LayoutTests/fast/url/trivial.html

index 9316b8f..98154ae 100644 (file)
@@ -1,3 +1,28 @@
+2010-04-16  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Adam Barth.
+
+        Test file: URL canonicalization
+        https://bugs.webkit.org/show_bug.cgi?id=37700
+
+        * fast/url/script-tests/file.js: Added new test.
+        * fast/url/file-expected.txt: Added (expected results).
+        * fast/url/file.html: Added (wrapper).
+
+        * fast/url/script-tests/TEMPLATE.html: Add an explicit dependable
+        <base> URL to the template, to avoid making test expectations
+        system dependent.
+        
+        Other test wrappers regenerated for the above change:
+
+        * fast/url/anchor.html:
+        * fast/url/ipv4.html:
+        * fast/url/path-url.html:
+        * fast/url/port.html:
+        * fast/url/query.html:
+        * fast/url/standard-url.html:
+        * fast/url/trivial.html:
+
 2010-04-15  Tony Chang  <tony@chromium.org>
 
         Not reviewed, trying to make the tree green.
index b6162c8..9b8a776 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
+<base href="file:///tmp/LayoutTests/fast/url/">
 <link rel="stylesheet" href="../js/resources/js-test-style.css">
 <script src="../js/resources/js-test-pre.js"></script>
 <script src="resources/utilities.js"></script>
diff --git a/LayoutTests/fast/url/file-expected.txt b/LayoutTests/fast/url/file-expected.txt
new file mode 100644 (file)
index 0000000..9d6c9e9
--- /dev/null
@@ -0,0 +1,37 @@
+Canonicalization of file URLs
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+FAIL canonicalize('file:c:\\foo\\bar.html') should be file:///C:/foo/bar.html. Was file:///tmp/LayoutTests/fast/url/c:/foo/bar.html.
+FAIL canonicalize('  File:c|////foo\\bar.html') should be file:///C:////foo/bar.html. Was file:///tmp/LayoutTests/fast/url/c|////foo/bar.html.
+FAIL canonicalize('file:') should be file:///. Was file:///tmp/LayoutTests/fast/url/.
+FAIL canonicalize('file:UNChost/path') should be file://unchost/path. Was file:///tmp/LayoutTests/fast/url/UNChost/path.
+FAIL canonicalize('c:\\foo\\bar') should be file:///C:/foo/bar. Was c:/foo/bar.
+FAIL canonicalize('C|/foo/bar') should be file:///C:/foo/bar. Was file:///tmp/LayoutTests/fast/url/C|/foo/bar.
+FAIL canonicalize('/C|\\foo\\bar') should be file:///C:/foo/bar. Was file:///C|/foo/bar.
+FAIL canonicalize('//C|/foo/bar') should be file:///C:/foo/bar. Was file://C|/foo/bar.
+PASS canonicalize('//server/file') is 'file://server/file'
+PASS canonicalize('\\\\server\\file') is 'file://server/file'
+PASS canonicalize('/\\server/file') is 'file://server/file'
+FAIL canonicalize('file:c:foo/bar.html') should be file:///C:/foo/bar.html. Was file:///tmp/LayoutTests/fast/url/c:foo/bar.html.
+FAIL canonicalize('file:/\\/\\C:\\\\//foo\\bar.html') should be file:///C:////foo/bar.html. Was file:////C:////foo/bar.html.
+PASS canonicalize('file:///foo/bar.txt') is 'file:///foo/bar.txt'
+FAIL canonicalize('FILE:/\\/\\7:\\\\//foo\\bar.html') should be file://7:////foo/bar.html. Was FILE:////7:////foo/bar.html.
+FAIL canonicalize('file:filer/home\\me') should be file://filer/home/me. Was file:///tmp/LayoutTests/fast/url/filer/home/me.
+FAIL canonicalize('file:///C:/foo/../../../bar.html') should be file:///C:/bar.html. Was file:///bar.html.
+FAIL canonicalize('file:///C:/asdf#\xc2') should be file:///C:/asdf#�. Was file:///C:/asdf#%C2.
+PASS canonicalize('file:///home/me') is 'file:///home/me'
+FAIL canonicalize('file:c:\\foo\\bar.html') should be file:///c:/foo/bar.html. Was file:///tmp/LayoutTests/fast/url/c:/foo/bar.html.
+FAIL canonicalize('file:c|//foo\\bar.html') should be file:///c%7C//foo/bar.html. Was file:///tmp/LayoutTests/fast/url/c|//foo/bar.html.
+FAIL canonicalize('//') should be file:///. Was file:.
+PASS canonicalize('///') is 'file:///'
+PASS canonicalize('///test') is 'file:///test'
+FAIL canonicalize('file://test') should be file://test/. Was file://test.
+FAIL canonicalize('file://localhost') should be file://localhost/. Was file:.
+FAIL canonicalize('file://localhost/') should be file://localhost/. Was file:///.
+FAIL canonicalize('file://localhost/test') should be file://localhost/test. Was file:///test.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/url/file.html b/LayoutTests/fast/url/file.html
new file mode 100644 (file)
index 0000000..883ced5
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<base href="file:///tmp/LayoutTests/fast/url/">
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+<script src="resources/utilities.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/file.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 588e991..79de0c7 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
+<base href="file:///tmp/LayoutTests/fast/url/">
 <link rel="stylesheet" href="../js/resources/js-test-style.css">
 <script src="../js/resources/js-test-pre.js"></script>
 <script src="resources/utilities.js"></script>
index b1bfbbc..f7b35d5 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
+<base href="file:///tmp/LayoutTests/fast/url/">
 <link rel="stylesheet" href="../js/resources/js-test-style.css">
 <script src="../js/resources/js-test-pre.js"></script>
 <script src="resources/utilities.js"></script>
index 9200755..606b66e 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
+<base href="file:///tmp/LayoutTests/fast/url/">
 <link rel="stylesheet" href="../js/resources/js-test-style.css">
 <script src="../js/resources/js-test-pre.js"></script>
 <script src="resources/utilities.js"></script>
index ab8e62d..e95785c 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
+<base href="file:///tmp/LayoutTests/fast/url/">
 <link rel="stylesheet" href="../js/resources/js-test-style.css">
 <script src="../js/resources/js-test-pre.js"></script>
 <script src="resources/utilities.js"></script>
index 1c30984..20252a9 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
+<base href="file:///tmp/LayoutTests/fast/url/">
 <link rel="stylesheet" href="../js/resources/js-test-style.css">
 <script src="../js/resources/js-test-pre.js"></script>
 <script src="resources/utilities.js"></script>
diff --git a/LayoutTests/fast/url/script-tests/file.js b/LayoutTests/fast/url/script-tests/file.js
new file mode 100644 (file)
index 0000000..f7db6e9
--- /dev/null
@@ -0,0 +1,63 @@
+description("Canonicalization of file URLs");
+
+cases = [ 
+    // Windows-style paths
+    ["file:c:\\\\foo\\\\bar.html", "file:///C:/foo/bar.html"],
+    ["  File:c|////foo\\\\bar.html", "file:///C:////foo/bar.html"],
+    ["file:", "file:///"],
+    ["file:UNChost/path", "file://unchost/path"],
+    // CanonicalizeFileURL supports absolute Windows style paths for IE
+    // compatability. Note that the caller must decide that this is a file
+    // URL itself so it can call the file canonicalizer. This is usually
+    // done automatically as part of relative URL resolving.
+    ["c:\\\\foo\\\\bar", "file:///C:/foo/bar"],
+    ["C|/foo/bar", "file:///C:/foo/bar"],
+    ["/C|\\\\foo\\\\bar", "file:///C:/foo/bar"],
+    ["//C|/foo/bar", "file:///C:/foo/bar"],
+    ["//server/file", "file://server/file"],
+    ["\\\\\\\\server\\\\file", "file://server/file"],
+    ["/\\\\server/file", "file://server/file"],
+    // We should preserve the number of slashes after the colon for IE
+    // compatability, except when there is none, in which case we should
+    // add one.
+    ["file:c:foo/bar.html", "file:///C:/foo/bar.html"],
+    ["file:/\\\\/\\\\C:\\\\\\\\//foo\\\\bar.html", "file:///C:////foo/bar.html"],
+    // Three slashes should be non-UNC, even if there is no drive spec (IE
+    // does this, which makes the resulting request invalid).
+    ["file:///foo/bar.txt", "file:///foo/bar.txt"],
+    // TODO(brettw) we should probably fail for invalid host names, which
+    // would change the expected result on this test. We also currently allow
+    // colon even though it's probably invalid, because its currently the
+    // "natural" result of the way the canonicalizer is written. There doesn't
+    // seem to be a strong argument for why allowing it here would be bad, so
+    // we just tolerate it and the load will fail later.
+    ["FILE:/\\\\/\\\\7:\\\\\\\\//foo\\\\bar.html", "file://7:////foo/bar.html"],
+    ["file:filer/home\\\\me", "file://filer/home/me"],
+    // Make sure relative paths can't go above the "C:"
+    ["file:///C:/foo/../../../bar.html", "file:///C:/bar.html"],
+    // Busted refs shouldn't make the whole thing fail.
+    ["file:///C:/asdf#\\xc2", "file:///C:/asdf#\\xef\\xbf\\xbd"],
+
+    // Unix-style paths
+    ["file:///home/me", "file:///home/me"],
+    // Windowsy ones should get still treated as Unix-style.
+    ["file:c:\\\\foo\\\\bar.html", "file:///c:/foo/bar.html"],
+    ["file:c|//foo\\\\bar.html", "file:///c%7C//foo/bar.html"],
+    // file: tests from WebKit (LayoutTests/fast/loader/url-parse-1.html)
+    ["//", "file:///"],
+    ["///", "file:///"],
+    ["///test", "file:///test"],
+    ["file://test", "file://test/"],
+    ["file://localhost",  "file://localhost/"],
+    ["file://localhost/", "file://localhost/"],
+    ["file://localhost/test", "file://localhost/test"],
+];
+
+for (var i = 0; i < cases.length; ++i) {
+  test_vector = cases[i][0];
+  expected_result = cases[i][1];
+  shouldBe("canonicalize('" + test_vector + "')",
+           "'" + expected_result + "'");
+}
+
+var successfullyParsed = true;
index 6f1b1d4..7cbae37 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
+<base href="file:///tmp/LayoutTests/fast/url/">
 <link rel="stylesheet" href="../js/resources/js-test-style.css">
 <script src="../js/resources/js-test-pre.js"></script>
 <script src="resources/utilities.js"></script>
index 30a976a..255e013 100644 (file)
@@ -1,6 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
 <head>
+<base href="file:///tmp/LayoutTests/fast/url/">
 <link rel="stylesheet" href="../js/resources/js-test-style.css">
 <script src="../js/resources/js-test-pre.js"></script>
 <script src="resources/utilities.js"></script>