blob: b24779700bea9fd3273c8ce2ab3fdb7b713b7d50 [file] [log] [blame]
<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" ],
// We should interpret escape chars in the href.
// Note that innerHTML escapes '&'s (and other special characters) so
// this is saying we expect the text of the href to be "bar?a&amp;b"
// and the URL to be "http://example.org/foo/bar?a&b"
[ "bar?a&amp;amp;b", "http://example.org/foo/bar?a&b" ]
];
var elements = frame.contentDocument.documentElement.getElementsByTagName("a");
if (!elements || elements.length !== 5) {
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>