tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / inspector / styles / styles-url-linkify.html
1 <html>
2 <head>
3 <link rel="stylesheet" href="resources/styles-url-linkify.css">
4
5 <script src="../../http/tests/inspector/inspector-test.js"></script>
6 <script src="../../http/tests/inspector/elements-test.js"></script>
7 <script>
8
9 function test()
10 {
11     function completeURL(baseURL, href)
12     {
13         InspectorTest.addResult(WebInspector.completeURL(baseURL, href));
14     }
15
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?c=d", "?a=b");
27
28     const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCAgMAAACeOuh7AAAABGdBTUEAAK/INwWK6QAAAAlQTFRF////AAAA////fu+PTwAAAAF0Uk5TAEDm2GYAAACHSURBVDjLxdLbDYAgDAVQGELn0R3oEHYf2KGdUqtE46OFRCP3oyTng1xCnWsaD5JRRtCkQ2YmkBkHRXqWJBn0j0TICbrsWVoWhRShCdcGyZCtHxMaUnVPRZ9KSbmBJdsX2vJVnwqRD0Rb4rpzgIbE/AI5NTnWAMvy5l0dXrfuLh5OCe5BmmYGXhTUxlQ5xJ8AAAAASUVORK5CYII=";
29     completeURL("https://example.com/foo", dataURL);
30     completeURL("http://example.com/foo", "javascript:alert('foo');");
31     InspectorTest.addResult(WebInspector.resourceURLForRelatedNode(null, " javascript:alert('foo'); "));
32
33     function dumpHref(dumpLinkClass)
34     {
35         var hrefNode;
36         var valueChildNodes = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2].propertiesTreeOutline.children[0].valueElement.childNodes;
37         for (var i = 0; i < valueChildNodes.length; ++i) {
38             if (valueChildNodes[i].href) {
39                 hrefNode = valueChildNodes[i];
40                 break;
41             }
42         }
43         if (!hrefNode) {
44             InspectorTest.addResult("href property not found");
45             return;
46         }
47
48         var styleClass = "";
49         if (dumpLinkClass) {
50             if (hrefNode.hasStyleClass("webkit-html-resource-link"))
51                 styleClass += "webkit-html-resource-link ";
52             if (hrefNode.hasStyleClass("webkit-html-external-link"))
53                 styleClass += "webkit-html-external-link ";
54         }
55
56         var href = hrefNode.href;
57         var segments = href.split("/");
58         var output = [];
59         for (var i = segments.length - 1, minSegment = i - 3; i >= 0 && i >= minSegment; --i)
60             output.unshift(segments[i]);
61
62         InspectorTest.addResult(styleClass + output.join("/"));
63     }
64
65     InspectorTest.selectNodeAndWaitForStyles("local", step1);
66
67     function step1()
68     {
69         InspectorTest.addResult("Link for a URI from CSS document:");
70         dumpHref(true);
71         InspectorTest.selectNodeAndWaitForStyles("iframed", step2);
72     }
73
74     function step2()
75     {
76         InspectorTest.addResult("Link for a URI from iframe inline stylesheet:");
77         dumpHref();
78         InspectorTest.completeTest();
79     }
80 }
81
82 </script>
83 </head>
84 <body onload="runAfterIframeIsLoaded()">
85 <p>
86 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>
87 </p>
88 <div id="local"></div>
89 <iframe src="resources/styles-url-linkify-iframe.html"></iframe>
90
91 </body>
92 </html>