3 <link rel="stylesheet" href="resources/styles-url-linkify.css">
5 <script src="../../http/tests/inspector/inspector-test.js"></script>
6 <script src="../../http/tests/inspector/elements-test.js"></script>
11 function completeURL(baseURL, href)
13 InspectorTest.addResult(WebInspector.completeURL(baseURL, href));
16 InspectorTest.addResult("URLs completed:");
17 completeURL("http://example.com", "/");
18 completeURL("http://example.com", "moo");
19 completeURL("http://example.com/", "https://secure.com/moo");
20 completeURL("https://example.com/foo", "//secure.com/moo");
21 completeURL("http://example.com/foo/zoo", "/moo");
22 completeURL("http://example.com/foo/zoo/", "moo");
23 completeURL("http://example.com/foo/zoo", "boo/moo");
24 completeURL("http://example.com/foo", "moo");
25 completeURL("http://example.com/foo", "?a=b");
26 completeURL("http://example.com/foo", "?a=/b");
27 completeURL("http://example.com/?c=/d#anchor", "?a=/b");
28 completeURL("http://example.com/foo?c=d", "?a=b");
29 completeURL("http://example.com/foo?c=d#anchor", "?a=/b");
30 completeURL("http://example.com/foo?c=/d/e", "?a=b");
31 completeURL("http://example.com/foo?c=/d/e", "cat.jpeg");
32 completeURL("http://example.com/foo#anchor", "cat.jpeg");
34 const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCAgMAAACeOuh7AAAABGdBTUEAAK/INwWK6QAAAAlQTFRF////AAAA////fu+PTwAAAAF0Uk5TAEDm2GYAAACHSURBVDjLxdLbDYAgDAVQGELn0R3oEHYf2KGdUqtE46OFRCP3oyTng1xCnWsaD5JRRtCkQ2YmkBkHRXqWJBn0j0TICbrsWVoWhRShCdcGyZCtHxMaUnVPRZ9KSbmBJdsX2vJVnwqRD0Rb4rpzgIbE/AI5NTnWAMvy5l0dXrfuLh5OCe5BmmYGXhTUxlQ5xJ8AAAAASUVORK5CYII=";
35 completeURL("https://example.com/foo", dataURL);
36 completeURL("http://example.com/foo", "javascript:alert('foo');");
37 InspectorTest.addResult(WebInspector.resourceURLForRelatedNode(null, " javascript:alert('foo'); "));
39 function dumpHref(dumpLinkClass)
42 var valueChildNodes = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2].propertiesTreeOutline.children[0].valueElement.childNodes;
43 for (var i = 0; i < valueChildNodes.length; ++i) {
44 if (valueChildNodes[i].href) {
45 hrefNode = valueChildNodes[i];
50 InspectorTest.addResult("href property not found");
56 if (hrefNode.hasStyleClass("webkit-html-resource-link"))
57 styleClass += "webkit-html-resource-link ";
58 if (hrefNode.hasStyleClass("webkit-html-external-link"))
59 styleClass += "webkit-html-external-link ";
62 var href = hrefNode.href;
63 var segments = href.split("/");
65 for (var i = segments.length - 1, minSegment = i - 3; i >= 0 && i >= minSegment; --i)
66 output.unshift(segments[i]);
68 InspectorTest.addResult(styleClass + output.join("/"));
71 InspectorTest.selectNodeAndWaitForStyles("local", step1);
75 InspectorTest.addResult("Link for a URI from CSS document:");
77 InspectorTest.selectNodeAndWaitForStyles("iframed", step2);
82 InspectorTest.addResult("Link for a URI from iframe inline stylesheet:");
84 InspectorTest.completeTest();
90 <body onload="runAfterIframeIsLoaded()">
92 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>
94 <div id="local"></div>
95 <iframe src="resources/styles-url-linkify-iframe.html"></iframe>