summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/loader/url-parse-1.html
blob: 486d9f42081f03ccf10bafd27e69bbeaaa8236c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<head>
    <base href="file:///BASE/">
    <style>

        table { border-spacing: 0; border-collapse: collapse; border: 1px solid #999; }
        thead { font: x-small 'Lucida Grande'; }
        thead > tr { background-color: #dee; border-bottom: 1px solid #999; }
        td, th { padding: 4px; border-width: 0 1px; border-style: solid; border-color: #999 }
        tbody { font: small monospace; }
        tbody > tr:nth-child(odd) { background-color: #eee; }
    </style>
</head>
<body>
    <p>
        The following table shows how URLs are parsed and canonicalized. The base URI
        for this document is <tt>file:///BASE/</tt>.
    </p>
    <table>
        <thead>
            <tr>
                <th>URL</th>
                <th>href</th>
                <th>host</th>
                <th>pathname</th>
            </tr>
        </thead>
        <tbody id = "results"></tbody>
    </table>
    <script>
        if (window.testRunner)
            testRunner.dumpAsText();

        function test(url)
        {
            var anchor = document.createElement("a");
            anchor.href = url;
    
            var row = document.getElementById("results").appendChild(document.createElement("tr"));
            row.appendChild(document.createElement("td")).appendChild(anchor).appendChild(document.createTextNode(url));
            row.appendChild(document.createElement("td")).appendChild(document.createTextNode(anchor.href));
            row.appendChild(document.createElement("td")).appendChild(document.createTextNode(anchor.host));
            row.appendChild(document.createElement("td")).appendChild(document.createTextNode(anchor.pathname));
        }
    
        var testCases = [
            "",
            "test",
            "/",
            "/test",
            "//",
            "//test",
            "///",
            "///test",
            "file:",
            "file:test",
            "file:/",
            "file:/test",
            "file://",
            "file://test",
            "file:///",
            "file:///test",
            "file://localhost",
            "file://localhost/",
            "file://localhost/test",
            "http:",
            "http:/",
            "http://",
            "http:///",
            "http:////",
            "http://localhost",
            "http://localhost/",
            "http://localhost/test",
            "x-webkit:",
            "x-webkit:test",
            "x-webkit:/",
            "x-webkit:/test",
            "x-webkit://",
            "x-webkit://test",
            "x-webkit:///",
            "x-webkit:///test",
        ];
    
        for (var i = 0; i < testCases.length; ++i)
            test(testCases[i]);
    </script>
</body>