1 description("Canonicalization of file URLs when the base URL is an http URL");
5 ["file:c:\\\\foo\\\\bar.html", "file:///C:/foo/bar.html"],
6 [" File:c|////foo\\\\bar.html", "file:///C:////foo/bar.html"],
8 ["file:UNChost/path", "file://unchost/path"],
9 // CanonicalizeFileURL supports absolute Windows style paths for IE
10 // compatability. Note that the caller must decide that this is a file
11 // URL itself so it can call the file canonicalizer. This is usually
12 // done automatically as part of relative URL resolving.
13 ["c:\\\\foo\\\\bar", "file:///C:/foo/bar"],
14 ["C|/foo/bar", "file:///C:/foo/bar"],
15 ["/C|\\\\foo\\\\bar", "file:///C:/foo/bar"],
16 ["//C|/foo/bar", "file:///C:/foo/bar"],
17 ["//server/file", "file://server/file"],
18 ["\\\\\\\\server\\\\file", "file://server/file"],
19 ["/\\\\server/file", "file://server/file"],
20 // We should preserve the number of slashes after the colon for IE
21 // compatability, except when there is none, in which case we should
23 ["file:c:foo/bar.html", "file:///C:/foo/bar.html"],
24 ["file:/\\\\/\\\\C:\\\\\\\\//foo\\\\bar.html", "file:///C:////foo/bar.html"],
25 // Three slashes should be non-UNC, even if there is no drive spec (IE
26 // does this, which makes the resulting request invalid).
27 ["file:///foo/bar.txt", "file:///foo/bar.txt"],
28 // TODO(brettw) we should probably fail for invalid host names, which
29 // would change the expected result on this test. We also currently allow
30 // colon even though it's probably invalid, because its currently the
31 // "natural" result of the way the canonicalizer is written. There doesn't
32 // seem to be a strong argument for why allowing it here would be bad, so
33 // we just tolerate it and the load will fail later.
34 ["FILE:/\\\\/\\\\7:\\\\\\\\//foo\\\\bar.html", "file://7:////foo/bar.html"],
35 ["file:filer/home\\\\me", "file://filer/home/me"],
36 // Make sure relative paths can't go above the "C:"
37 ["file:///C:/foo/../../../bar.html", "file:///C:/bar.html"],
38 // Busted refs shouldn't make the whole thing fail.
39 ["file:///C:/asdf#\\xc2", "file:///C:/asdf#\\xc2"],
40 ["file:///C:/asdf#\xc2", "file:///C:/asdf#\xc2"],
43 ["file:///home/me", "file:///home/me"],
44 // Windowsy ones should get still treated as Unix-style.
45 ["file:c:\\\\foo\\\\bar.html", "file:///c:/foo/bar.html"],
46 ["file:c|//foo\\\\bar.html", "file:///c%7C//foo/bar.html"],
47 // file: tests from WebKit (LayoutTests/fast/loader/url-parse-1.html)
50 ["///test", "file:///test"],
51 ["file://test", "file://test/"],
52 ["file://localhost", "file://localhost/"],
53 ["file://localhost/", "file://localhost/"],
54 ["file://localhost/test", "file://localhost/test"],
57 var originalBaseURL = canonicalize(".");
58 setBaseURL("http://example.com/mock/path");
60 for (var i = 0; i < cases.length; ++i) {
61 test_vector = cases[i][0];
62 expected_result = cases[i][1];
63 shouldBe("canonicalize('" + test_vector + "')",
64 "'" + expected_result + "'");
67 setBaseURL(originalBaseURL);