summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/frames/viewsource-link-on-href-value.html
blob: 6c2cc82913139cc12ad7104136ef4580d9e93e25 (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
<html>
<!-- This tests that a base element is respected in rendering anchors on viewsource page. -->
<head>
<script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    function checkFrame(id) {
        var frame = document.getElementById(id);

        // Update this list when you modified resources/viewsource-frame-{3,4}.html .
        var expected = [
            // This will be matched with the href in the base element.
            [ "http://example.org/foo/", "http://example.org/foo/" ],
            [ "bar", "http://example.org/foo/bar" ],
            [ "/bar", "http://example.org/bar" ],
            // This shouldn't be affected.
            [ "http://example.org/foobar", "http://example.org/foobar" ]
        ];

        var elements = frame.contentDocument.documentElement.getElementsByTagName("a");
        if (!elements || elements.length !== 4) {
            return false;
        }

        var ok = true;
        for (var i = 0; i < elements.length; ++i) {
            var element = elements.item(i);
            if (element.innerHTML !== expected[i][0] || element.href !== expected[i][1]) {
                ok = false;
                break;
            }
        }
        return ok;
    }

    function report() {
        var resultText = "FAIL";
        // Check that links are added on href values regardless of the case of tag names.
        if (checkFrame("lower") && checkFrame("upper")) {
            resultText = "PASS";
        }
        if (window.testRunner) {
            document.open();
            document.write(resultText);
            document.close();

            testRunner.notifyDone();
        } else {
            document.getElementById("result").textContent = resultText;
        }
    }
</script>
</head>
<body onload="report()">
<p>
In a frame below which is in 'view source' mode, each link on the value of the
href attribute in anchor elements must have the same address as the anchor
element's contents.
</p>
<hr>
<iframe viewsource src="resources/viewsource-frame-3.html" width="600" id="lower"></iframe>
<iframe viewsource src="resources/viewsource-frame-4.html" width="600" id="upper"></iframe>
<hr>
<div id="result"></div>
</body>
</html>