3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/debugger-test.js"></script>
7 function nonFormattedFunction() { var i = 2 + 2; var a = 4; return a + i; }
11 console.log("dummy string");
16 InspectorTest.startDebuggerTest(waitForScripts);
23 function waitForScripts()
25 InspectorTest.showScriptSource("linkifier.html", debuggerTest);
28 function debuggerTest()
30 var scripts = WebInspector.debuggerModel.scripts;
31 for (var scriptId in scripts) {
32 var scriptCandidate = scripts[scriptId];
33 if (scriptCandidate.sourceURL === WebInspector.inspectedPageURL && scriptCandidate.lineOffset === 4) {
34 script = scriptCandidate;
39 uiSourceCode = WebInspector.workspace.uiSourceCodeForOriginURL(WebInspector.inspectedPageURL);
40 var linkifyMe = "at triggerError (http://localhost/show/:22:11)";
41 var fragment = WebInspector.linkifyStringAsFragment(linkifyMe);
42 var anchor = fragment.querySelector('a');
43 InspectorTest.addResult("The string \"" + linkifyMe + " \" linkifies to url: " + anchor.href);
44 InspectorTest.addResult("The lineNumber is " + anchor.lineNumber + " with type " + (typeof anchor.lineNumber));
45 InspectorTest.addResult("The columnNumber is " + anchor.columnNumber + " with type " + (typeof anchor.columnNumber));
47 linkifier = new WebInspector.Linkifier();
48 var count1 = liveLocationsCount();
49 link = linkifier.linkifyLocation(WebInspector.inspectedPageURL, 8, 0, "dummy-class");
50 var count2 = liveLocationsCount();
52 InspectorTest.addResult("listeners added on raw source code: " + (count2 - count1));
53 InspectorTest.addResult("original location: " + link.textContent);
55 InspectorTest.addSniffer(linkifier._formatter, "formatLiveAnchor", linkUpdated);
56 uiSourceCode.setFormatted(true);
59 function linkUpdated()
61 InspectorTest.addResult("pretty printed location: " + link.textContent);
62 InspectorTest.addSniffer(linkifier._formatter, "formatLiveAnchor", linkReverted);
63 uiSourceCode.setFormatted(false);
66 function linkReverted()
68 InspectorTest.addResult("reverted location: " + link.textContent);
70 var count1 = liveLocationsCount();
72 var count2 = liveLocationsCount();
74 InspectorTest.addResult("listeners removed from raw source code: " + (count1 - count2));
76 InspectorTest.completeDebuggerTest();
79 function liveLocationsCount()
81 return script._locations.size();
88 <body onload="runTest()">
90 Tests that Linkifier works correctly.