| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="../../http/tests/inspector/debugger-test.js"></script> |
| <script> |
| |
| function dummyScript() |
| { |
| console.log("dummy string"); |
| } |
| |
| function test() |
| { |
| InspectorTest.startDebuggerTest(waitForScripts); |
| |
| var linkifier; |
| var link; |
| var script; |
| var uiSourceCode; |
| |
| function waitForScripts() |
| { |
| InspectorTest.showScriptSource("linkifier.html", debuggerTest); |
| } |
| |
| function debuggerTest() |
| { |
| var scripts = WebInspector.debuggerModel.scripts; |
| for (var scriptId in scripts) { |
| var scriptCandidate = scripts[scriptId]; |
| if (scriptCandidate.sourceURL === WebInspector.inspectedPageURL && scriptCandidate.lineOffset === 4) { |
| script = scriptCandidate; |
| break; |
| } |
| } |
| |
| uiSourceCode = WebInspector.workspace.uiSourceCodeForOriginURL(WebInspector.inspectedPageURL); |
| var linkifyMe = "at triggerError (http://localhost/show/:22:11)"; |
| var fragment = WebInspector.linkifyStringAsFragment(linkifyMe); |
| var anchor = fragment.querySelector('a'); |
| InspectorTest.addResult("The string \"" + linkifyMe + " \" linkifies to url: " + anchor.href); |
| InspectorTest.addResult("The lineNumber is " + anchor.lineNumber + " with type " + (typeof anchor.lineNumber)); |
| |
| linkifier = new WebInspector.Linkifier(); |
| var count1 = liveLocationsCount(); |
| link = linkifier.linkifyLocation(WebInspector.inspectedPageURL, 8, 0, "dummy-class"); |
| var count2 = liveLocationsCount(); |
| |
| InspectorTest.addResult("listeners added on raw source code: " + (count2 - count1)); |
| InspectorTest.addResult("original location: " + link.textContent); |
| |
| InspectorTest.addSniffer(linkifier._formatter, "formatLiveAnchor", linkUpdated); |
| uiSourceCode.setFormatted(true); |
| } |
| |
| function linkUpdated() |
| { |
| InspectorTest.addResult("pretty printed location: " + link.textContent); |
| InspectorTest.addSniffer(linkifier._formatter, "formatLiveAnchor", linkReverted); |
| uiSourceCode.setFormatted(false); |
| } |
| |
| function linkReverted() |
| { |
| InspectorTest.addResult("reverted location: " + link.textContent); |
| |
| var count1 = liveLocationsCount(); |
| linkifier.reset(); |
| var count2 = liveLocationsCount(); |
| |
| InspectorTest.addResult("listeners removed from raw source code: " + (count1 - count2)); |
| |
| InspectorTest.completeDebuggerTest(); |
| } |
| |
| function liveLocationsCount() |
| { |
| return script._locations.size(); |
| } |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| Tests that Linkifier works correctly. |
| <p> |
| |
| </body> |
| </html> |