| OLD | NEW |
| (Empty) |
| 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.ParsedURL.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 completeURL("http://example.com/", "/foo?bar=http://otherexample.com"); | |
| 34 | |
| 35 const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCAgMAA
ACeOuh7AAAABGdBTUEAAK/INwWK6QAAAAlQTFRF////AAAA////fu+PTwAAAAF0Uk5TAEDm2GYAAACHS
URBVDjLxdLbDYAgDAVQGELn0R3oEHYf2KGdUqtE46OFRCP3oyTng1xCnWsaD5JRRtCkQ2YmkBkHRXqWJ
Bn0j0TICbrsWVoWhRShCdcGyZCtHxMaUnVPRZ9KSbmBJdsX2vJVnwqRD0Rb4rpzgIbE/AI5NTnWAMvy5
l0dXrfuLh5OCe5BmmYGXhTUxlQ5xJ8AAAAASUVORK5CYII="; | |
| 36 const blobURL = "blob:http%3A//example.com/f91b7b00-00-0000-0000-3b7c87055d7
a"; | |
| 37 completeURL("https://example.com/foo", dataURL); | |
| 38 completeURL("http://example.com/foo", "javascript:alert('foo');"); | |
| 39 completeURL("http://example.com/foo", blobURL); | |
| 40 InspectorTest.addResult(WebInspector.ParsedURL.completeURL(blobURL)); | |
| 41 | |
| 42 function dumpHref(dumpLinkClass) | |
| 43 { | |
| 44 var hrefNode; | |
| 45 var valueChildNodes = InspectorTest.firstMatchedStyleSection().propertie
sTreeOutline.firstChild().valueElement.childNodes; | |
| 46 for (var i = 0; i < valueChildNodes.length; ++i) { | |
| 47 if (valueChildNodes[i].href) { | |
| 48 hrefNode = valueChildNodes[i]; | |
| 49 break; | |
| 50 } | |
| 51 } | |
| 52 if (!hrefNode) { | |
| 53 InspectorTest.addResult("href property not found"); | |
| 54 return; | |
| 55 } | |
| 56 | |
| 57 var styleClass = ""; | |
| 58 if (dumpLinkClass) { | |
| 59 if (hrefNode.classList.contains("webkit-html-resource-link")) | |
| 60 styleClass += "webkit-html-resource-link "; | |
| 61 if (hrefNode.classList.contains("webkit-html-external-link")) | |
| 62 styleClass += "webkit-html-external-link "; | |
| 63 } | |
| 64 | |
| 65 var href = hrefNode.href; | |
| 66 var segments = href.split("/"); | |
| 67 var output = []; | |
| 68 for (var i = segments.length - 1, minSegment = i - 3; i >= 0 && i >= min
Segment; --i) | |
| 69 output.unshift(segments[i]); | |
| 70 | |
| 71 InspectorTest.addResult(styleClass + output.join("/")); | |
| 72 } | |
| 73 | |
| 74 InspectorTest.selectNodeAndWaitForStyles("local", step1); | |
| 75 | |
| 76 function step1() | |
| 77 { | |
| 78 InspectorTest.addResult("Link for a URI from CSS document:"); | |
| 79 dumpHref(true); | |
| 80 InspectorTest.selectNodeAndWaitForStyles("iframed", step2); | |
| 81 } | |
| 82 | |
| 83 function step2() | |
| 84 { | |
| 85 InspectorTest.addResult("Link for a URI from iframe inline stylesheet:")
; | |
| 86 dumpHref(); | |
| 87 InspectorTest.completeTest(); | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 </script> | |
| 92 </head> | |
| 93 <body onload="runAfterIframeIsLoaded()"> | |
| 94 <p> | |
| 95 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/sh
ow_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> | |
| 96 </p> | |
| 97 <div id="local"></div> | |
| 98 <iframe src="resources/styles-url-linkify-iframe.html"></iframe> | |
| 99 | |
| 100 </body> | |
| 101 </html> | |
| OLD | NEW |