OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | |
4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | |
5 <script> | |
6 | |
7 function nonFormattedFunction() { var i = 2 + 2; var a = 4; return a + i; } | |
8 | |
9 function dummyScript() | |
10 { | |
11 console.log("dummy string"); | |
12 } | |
13 | |
14 function onload() | |
15 { | |
16 if (window.testRunner) { | |
17 testRunner.waitUntilDone(); | |
18 testRunner.showWebInspector(); | |
19 } | |
20 runTest(); | |
21 } | |
22 | |
23 function test() | |
24 { | |
25 InspectorTest.startDebuggerTest(waitForScripts); | |
26 var panel = WebInspector.inspectorView.panel("sources"); | |
27 var scriptFormatter = InspectorTest.scriptFormatter(); | |
28 var linkifier; | |
29 var link; | |
30 var script; | |
31 var uiSourceCode; | |
32 | |
33 function waitForScripts() | |
34 { | |
35 InspectorTest.showScriptSource("linkifier.html", debuggerTest); | |
36 } | |
37 | |
38 function debuggerTest() | |
39 { | |
40 var scripts = WebInspector.debuggerModel.scripts; | |
41 for (var scriptId in scripts) { | |
42 var scriptCandidate = scripts[scriptId]; | |
43 if (scriptCandidate.sourceURL === WebInspector.resourceTreeModel.ins
pectedPageURL() && scriptCandidate.lineOffset === 4) { | |
44 script = scriptCandidate; | |
45 break; | |
46 } | |
47 } | |
48 | |
49 uiSourceCode = WebInspector.workspace.uiSourceCodeForOriginURL(WebInspec
tor.resourceTreeModel.inspectedPageURL()); | |
50 var linkifyMe = "at triggerError (http://localhost/show/:22:11)"; | |
51 var fragment = WebInspector.linkifyStringAsFragment(linkifyMe); | |
52 var anchor = fragment.querySelector('a'); | |
53 InspectorTest.addResult("The string \"" + linkifyMe + " \" linkifies to
url: " + anchor.href); | |
54 InspectorTest.addResult("The lineNumber is " + anchor.lineNumber + " wit
h type " + (typeof anchor.lineNumber)); | |
55 InspectorTest.addResult("The columnNumber is " + anchor.columnNumber + "
with type " + (typeof anchor.columnNumber)); | |
56 | |
57 linkifier = new WebInspector.Linkifier(); | |
58 var count1 = liveLocationsCount(); | |
59 link = linkifier.linkifyLocation(WebInspector.targetManager.activeTarget
(), WebInspector.resourceTreeModel.inspectedPageURL(), 8, 0, "dummy-class"); | |
60 var count2 = liveLocationsCount(); | |
61 | |
62 InspectorTest.addResult("listeners added on raw source code: " + (count2
- count1)); | |
63 InspectorTest.addResult("original location: " + link.textContent); | |
64 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorAction.protot
ype, "_updateButton", uiSourceCodeScriptFormatted); | |
65 scriptFormatter._toggleFormatScriptSource(); | |
66 } | |
67 | |
68 function uiSourceCodeScriptFormatted() | |
69 { | |
70 InspectorTest.addResult("pretty printed location: " + link.textContent); | |
71 scriptFormatter._discardFormattedUISourceCodeScript(panel.visibleView.ui
SourceCode()); | |
72 InspectorTest.addResult("reverted location: " + link.textContent); | |
73 | |
74 var count1 = liveLocationsCount(); | |
75 linkifier.reset(); | |
76 var count2 = liveLocationsCount(); | |
77 | |
78 InspectorTest.addResult("listeners removed from raw source code: " + (co
unt1 - count2)); | |
79 | |
80 InspectorTest.completeDebuggerTest(); | |
81 } | |
82 | |
83 function liveLocationsCount() | |
84 { | |
85 return script._locations.size(); | |
86 } | |
87 } | |
88 | |
89 </script> | |
90 </head> | |
91 | |
92 <body onload="onload()"> | |
93 <p> | |
94 Tests that Linkifier works correctly. | |
95 <p> | |
96 | |
97 </body> | |
98 </html> | |
OLD | NEW |