Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / linkifier.html
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 test()
15 {
16     InspectorTest.startDebuggerTest(waitForScripts);
17     var panel = WebInspector.inspectorView.panel("sources");
18     var scriptFormatter = InspectorTest.scriptFormatter();
19     var linkifier;
20     var link;
21     var script;
22     var uiSourceCode;
23
24     function waitForScripts()
25     {
26         InspectorTest.showScriptSource("linkifier.html", debuggerTest);
27     }
28
29     function debuggerTest()
30     {
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;
36                 break;
37             }
38         }
39         
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));
47
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();
52
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();
57     }
58
59     function uiSourceCodeScriptFormatted()
60     {
61         InspectorTest.addResult("pretty printed location: " + link.textContent);
62         scriptFormatter._discardFormattedUISourceCodeScript(panel.visibleView.uiSourceCode());
63         InspectorTest.addResult("reverted location: " + link.textContent);
64
65         var count1 = liveLocationsCount();
66         linkifier.reset();
67         var count2 = liveLocationsCount();
68
69         InspectorTest.addResult("listeners removed from raw source code: " + (count1 - count2));
70
71         InspectorTest.completeDebuggerTest();
72     }
73
74     function liveLocationsCount()
75     {
76         return script._locations.size();
77     }
78 }
79
80 </script>
81 </head>
82
83 <body onload="runTest()">
84 <p>
85 Tests that Linkifier works correctly.
86 <p>
87
88 </body>
89 </html>