blob: 4fdf2dc70aa45519bb4762dff320986e3699eb59 [file] [log] [blame]
<html>
<head>
<link rel="stylesheet" href="resources/styles-url-linkify.css">
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script>
function test()
{
function completeURL(baseURL, href)
{
InspectorTest.addResult(WebInspector.ParsedURL.completeURL(baseURL, href));
}
InspectorTest.addResult("URLs completed:");
completeURL("http://example.com", "/");
completeURL("http://example.com", "moo");
completeURL("http://example.com/", "https://secure.com/moo");
completeURL("https://example.com/foo", "//secure.com/moo");
completeURL("http://example.com/foo/zoo", "/moo");
completeURL("http://example.com/foo/zoo/", "moo");
completeURL("http://example.com/foo/zoo", "boo/moo");
completeURL("http://example.com/foo", "moo");
completeURL("http://example.com/foo", "?a=b");
completeURL("http://example.com/foo", "?a=/b");
completeURL("http://example.com/?c=/d#anchor", "?a=/b");
completeURL("http://example.com/foo?c=d", "?a=b");
completeURL("http://example.com/foo?c=d#anchor", "?a=/b");
completeURL("http://example.com/foo?c=/d/e", "?a=b");
completeURL("http://example.com/foo?c=/d/e", "cat.jpeg");
completeURL("http://example.com/foo#anchor", "cat.jpeg");
completeURL("http://example.com/", "/foo?bar=http://otherexample.com");
const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCAgMAAACeOuh7AAAABGdBTUEAAK/INwWK6QAAAAlQTFRF////AAAA////fu+PTwAAAAF0Uk5TAEDm2GYAAACHSURBVDjLxdLbDYAgDAVQGELn0R3oEHYf2KGdUqtE46OFRCP3oyTng1xCnWsaD5JRRtCkQ2YmkBkHRXqWJBn0j0TICbrsWVoWhRShCdcGyZCtHxMaUnVPRZ9KSbmBJdsX2vJVnwqRD0Rb4rpzgIbE/AI5NTnWAMvy5l0dXrfuLh5OCe5BmmYGXhTUxlQ5xJ8AAAAASUVORK5CYII=";
const blobURL = "blob:http%3A//example.com/f91b7b00-00-0000-0000-3b7c87055d7a";
completeURL("https://example.com/foo", dataURL);
completeURL("http://example.com/foo", "javascript:alert('foo');");
completeURL("http://example.com/foo", blobURL);
InspectorTest.addResult(WebInspector.ParsedURL.completeURL(blobURL));
function dumpHref(dumpLinkClass)
{
var hrefNode;
var valueChildNodes = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2].propertiesTreeOutline.children[0].valueElement.childNodes;
for (var i = 0; i < valueChildNodes.length; ++i) {
if (valueChildNodes[i].href) {
hrefNode = valueChildNodes[i];
break;
}
}
if (!hrefNode) {
InspectorTest.addResult("href property not found");
return;
}
var styleClass = "";
if (dumpLinkClass) {
if (hrefNode.hasStyleClass("webkit-html-resource-link"))
styleClass += "webkit-html-resource-link ";
if (hrefNode.hasStyleClass("webkit-html-external-link"))
styleClass += "webkit-html-external-link ";
}
var href = hrefNode.href;
var segments = href.split("/");
var output = [];
for (var i = segments.length - 1, minSegment = i - 3; i >= 0 && i >= minSegment; --i)
output.unshift(segments[i]);
InspectorTest.addResult(styleClass + output.join("/"));
}
InspectorTest.selectNodeAndWaitForStyles("local", step1);
function step1()
{
InspectorTest.addResult("Link for a URI from CSS document:");
dumpHref(true);
InspectorTest.selectNodeAndWaitForStyles("iframed", step2);
}
function step2()
{
InspectorTest.addResult("Link for a URI from iframe inline stylesheet:");
dumpHref();
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runAfterIframeIsLoaded()">
<p>
Tests that URLs are linked to and completed correctly. Bugs <a href="http://bugs.webkit.org/show_bug.cgi?id=51663">51663</a>, <a href="http://bugs.webkit.org/show_bug.cgi?id=53171">53171</a>, <a href="http://bugs.webkit.org/show_bug.cgi?id=62643">62643</a>, <a href="http://bugs.webkit.org/show_bug.cgi?id=72373">72373</a>, <a href="http://bugs.webkit.org/show_bug.cgi?id=79905">79905</a>
</p>
<div id="local"></div>
<iframe src="resources/styles-url-linkify-iframe.html"></iframe>
</body>
</html>