3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/debugger-test.js"></script>
5 <script>// It is important that script starts on line 5 (zero-based 4)
7 function nonFormattedFunction() { var i
= 2 + 2; var a
= 4; return a
+ i
; }
11 console
.log("dummy string");
16 if (window
.testRunner
) {
17 testRunner
.waitUntilDone();
18 testRunner
.showWebInspector();
31 InspectorTest
.scriptFormatter().then(startDebuggerTest
);
33 function startDebuggerTest(sf
)
36 InspectorTest
.startDebuggerTest(waitForScripts
);
39 function waitForScripts()
41 InspectorTest
.showScriptSource("linkifier.html", debuggerTest
);
44 function debuggerTest()
46 var scripts
= InspectorTest
.debuggerModel
.scripts
;
47 for (var scriptId
in scripts
) {
48 var scriptCandidate
= scripts
[scriptId
];
49 if (scriptCandidate
.sourceURL
=== InspectorTest
.resourceTreeModel
.inspectedPageURL() && scriptCandidate
.lineOffset
=== 4) {
50 script
= scriptCandidate
;
55 uiSourceCode
= WebInspector
.workspace
.uiSourceCodeForOriginURL(InspectorTest
.resourceTreeModel
.inspectedPageURL());
56 var linkifyMe
= "at triggerError (http://localhost/show/:22:11)";
57 var fragment
= WebInspector
.linkifyStringAsFragment(linkifyMe
);
58 var anchor
= fragment
.querySelector('a');
59 InspectorTest
.addResult("The string \"" + linkifyMe
+ " \" linkifies to url: " + anchor
.href
);
60 InspectorTest
.addResult("The lineNumber is " + anchor
.lineNumber
+ " with type " + (typeof anchor
.lineNumber
));
61 InspectorTest
.addResult("The columnNumber is " + anchor
.columnNumber
+ " with type " + (typeof anchor
.columnNumber
));
63 linkifier
= new WebInspector
.Linkifier();
64 var count1
= liveLocationsCount();
65 link
= linkifier
.linkifyScriptLocation(WebInspector
.targetManager
.mainTarget(), null, InspectorTest
.resourceTreeModel
.inspectedPageURL(), 8, 0, "dummy-class");
66 var count2
= liveLocationsCount();
68 InspectorTest
.addResult("listeners added on raw source code: " + (count2
- count1
));
69 InspectorTest
.addResult("original location: " + link
.textContent
);
70 InspectorTest
.addSniffer(WebInspector
.ScriptFormatterEditorAction
.prototype, "_updateButton", uiSourceCodeScriptFormatted
);
71 scriptFormatter
._toggleFormatScriptSource();
74 function uiSourceCodeScriptFormatted()
76 InspectorTest
.addResult("pretty printed location: " + link
.textContent
);
77 scriptFormatter
._discardFormattedUISourceCodeScript(WebInspector
.panels
.sources
.visibleView
.uiSourceCode());
78 InspectorTest
.addResult("reverted location: " + link
.textContent
);
80 var count1
= liveLocationsCount();
82 var count2
= liveLocationsCount();
84 InspectorTest
.addResult("listeners removed from raw source code: " + (count1
- count2
));
86 InspectorTest
.completeDebuggerTest();
89 function liveLocationsCount()
91 return WebInspector
.debuggerWorkspaceBinding
._ensureInfoForScript(script
)._locations
.size
;
98 <body onload=
"onload()">
100 Tests that Linkifier works correctly.