Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / 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
18     var linkifier;
19     var link;
20     var script;
21     var uiSourceCode;
22
23     function waitForScripts()
24     {
25         InspectorTest.showScriptSource("linkifier.html", debuggerTest);
26     }
27
28     function debuggerTest()
29     {
30         var scripts = WebInspector.debuggerModel.scripts;
31         for (var scriptId in scripts) {
32             var scriptCandidate = scripts[scriptId];
33             if (scriptCandidate.sourceURL === WebInspector.inspectedPageURL && scriptCandidate.lineOffset === 4) {
34                 script = scriptCandidate;
35                 break;
36             }
37         }
38         
39         uiSourceCode = WebInspector.workspace.uiSourceCodeForOriginURL(WebInspector.inspectedPageURL);
40         var linkifyMe = "at triggerError (http://localhost/show/:22:11)";
41         var fragment = WebInspector.linkifyStringAsFragment(linkifyMe);
42         var anchor = fragment.querySelector('a');
43         InspectorTest.addResult("The string \"" + linkifyMe + " \" linkifies to url: " + anchor.href);
44         InspectorTest.addResult("The lineNumber is " + anchor.lineNumber + " with type " + (typeof anchor.lineNumber));
45         InspectorTest.addResult("The columnNumber is " + anchor.columnNumber + " with type " + (typeof anchor.columnNumber));
46
47         linkifier = new WebInspector.Linkifier();
48         var count1 = liveLocationsCount();
49         link = linkifier.linkifyLocation(WebInspector.inspectedPageURL, 8, 0, "dummy-class");
50         var count2 = liveLocationsCount();
51
52         InspectorTest.addResult("listeners added on raw source code: " + (count2 - count1));
53         InspectorTest.addResult("original location: " + link.textContent);
54
55         InspectorTest.addSniffer(linkifier._formatter, "formatLiveAnchor", linkUpdated);
56         uiSourceCode.setFormatted(true);
57     }
58
59     function linkUpdated()
60     {
61         InspectorTest.addResult("pretty printed location: " + link.textContent);
62         InspectorTest.addSniffer(linkifier._formatter, "formatLiveAnchor", linkReverted);
63         uiSourceCode.setFormatted(false);
64     }
65
66     function linkReverted()
67     {
68         InspectorTest.addResult("reverted location: " + link.textContent);
69
70         var count1 = liveLocationsCount();
71         linkifier.reset();
72         var count2 = liveLocationsCount();
73
74         InspectorTest.addResult("listeners removed from raw source code: " + (count1 - count2));
75
76         InspectorTest.completeDebuggerTest();
77     }
78
79     function liveLocationsCount()
80     {
81         return script._locations.size();
82     }
83 }
84
85 </script>
86 </head>
87
88 <body onload="runTest()">
89 <p>
90 Tests that Linkifier works correctly.
91 <p>
92
93 </body>
94 </html>