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);
17 var panel = WebInspector.inspectorView.panel("sources");
18 var scriptFormatter = InspectorTest.scriptFormatter();
24 function waitForScripts()
26 InspectorTest.showScriptSource("linkifier.html", debuggerTest);
29 function debuggerTest()
31 var scripts = WebInspector.debuggerModel.scripts;
32 for (var scriptId in scripts) {
33 var scriptCandidate = scripts[scriptId];
34 if (scriptCandidate.sourceURL === WebInspector.resourceTreeModel.inspectedPageURL() && scriptCandidate.lineOffset === 4) {
35 script = scriptCandidate;
40 uiSourceCode = WebInspector.workspace.uiSourceCodeForOriginURL(WebInspector.resourceTreeModel.inspectedPageURL());
41 var linkifyMe = "at triggerError (http://localhost/show/:22:11)";
42 var fragment = WebInspector.linkifyStringAsFragment(linkifyMe);
43 var anchor = fragment.querySelector('a');
44 InspectorTest.addResult("The string \"" + linkifyMe + " \" linkifies to url: " + anchor.href);
45 InspectorTest.addResult("The lineNumber is " + anchor.lineNumber + " with type " + (typeof anchor.lineNumber));
46 InspectorTest.addResult("The columnNumber is " + anchor.columnNumber + " with type " + (typeof anchor.columnNumber));
48 linkifier = new WebInspector.Linkifier();
49 var count1 = liveLocationsCount();
50 link = linkifier.linkifyLocation(WebInspector.targetManager.activeTarget(), WebInspector.resourceTreeModel.inspectedPageURL(), 8, 0, "dummy-class");
51 var count2 = liveLocationsCount();
53 InspectorTest.addResult("listeners added on raw source code: " + (count2 - count1));
54 InspectorTest.addResult("original location: " + link.textContent);
55 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorAction.prototype, "_updateButton", uiSourceCodeScriptFormatted);
56 scriptFormatter._toggleFormatScriptSource();
59 function uiSourceCodeScriptFormatted()
61 InspectorTest.addResult("pretty printed location: " + link.textContent);
62 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibleView.uiSourceCode());
63 InspectorTest.addResult("reverted location: " + link.textContent);
65 var count1 = liveLocationsCount();
67 var count2 = liveLocationsCount();
69 InspectorTest.addResult("listeners removed from raw source code: " + (count1 - count2));
71 InspectorTest.completeDebuggerTest();
74 function liveLocationsCount()
76 return script._locations.size();
83 <body onload="runTest()">
85 Tests that Linkifier works correctly.