[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/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", "?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");
33
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'); "));
38
39     function dumpHref(dumpLinkClass)
40     {
41         var hrefNode;
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];
46                 break;
47             }
48         }
49         if (!hrefNode) {
50             InspectorTest.addResult("href property not found");
51             return;
52         }
53
54         var styleClass = "";
55         if (dumpLinkClass) {
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 ";
60         }
61
62         var href = hrefNode.href;
63         var segments = href.split("/");
64         var output = [];
65         for (var i = segments.length - 1, minSegment = i - 3; i >= 0 && i >= minSegment; --i)
66             output.unshift(segments[i]);
67
68         InspectorTest.addResult(styleClass + output.join("/"));
69     }
70
71     InspectorTest.selectNodeAndWaitForStyles("local", step1);
72
73     function step1()
74     {
75         InspectorTest.addResult("Link for a URI from CSS document:");
76         dumpHref(true);
77         InspectorTest.selectNodeAndWaitForStyles("iframed", step2);
78     }
79
80     function step2()
81     {
82         InspectorTest.addResult("Link for a URI from iframe inline stylesheet:");
83         dumpHref();
84         InspectorTest.completeTest();
85     }
86 }
87
88 </script>
89 </head>
90 <body onload="runAfterIframeIsLoaded()">
91 <p>
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>
93 </p>
94 <div id="local"></div>
95 <iframe src="resources/styles-url-linkify-iframe.html"></iframe>
96
97 </body>
98 </html>