Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector-enabled / 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>// It is important that script starts on line 5 (zero-based 4)
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     var scriptFormatter;
26     var linkifier;
27     var link;
28     var script;
29     var uiSourceCode;
30
31     InspectorTest.scriptFormatter().then(startDebuggerTest);
32
33     function startDebuggerTest(sf)
34     {
35         scriptFormatter = sf;
36         InspectorTest.startDebuggerTest(waitForScripts);
37     }
38
39     function waitForScripts()
40     {
41         InspectorTest.showScriptSource("linkifier.html", debuggerTest);
42     }
43
44     function debuggerTest()
45     {
46         var scripts = WebInspector.debuggerModel.scripts;
47         for (var scriptId in scripts) {
48             var scriptCandidate = scripts[scriptId];
49             if (scriptCandidate.sourceURL === WebInspector.resourceTreeModel.inspectedPageURL() && scriptCandidate.lineOffset === 4) {
50                 script = scriptCandidate;
51                 break;
52             }
53         }
54         
55         uiSourceCode = WebInspector.workspace.uiSourceCodeForOriginURL(WebInspector.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));
62
63         linkifier = new WebInspector.Linkifier();
64         var count1 = liveLocationsCount();
65         link = linkifier.linkifyScriptLocation(WebInspector.targetManager.mainTarget(), null, WebInspector.resourceTreeModel.inspectedPageURL(), 8, 0, "dummy-class");
66         var count2 = liveLocationsCount();
67
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();
72     }
73
74     function uiSourceCodeScriptFormatted()
75     {
76         InspectorTest.addResult("pretty printed location: " + link.textContent);
77         scriptFormatter._discardFormattedUISourceCodeScript(WebInspector.panels.sources.visibleView.uiSourceCode());
78         InspectorTest.addResult("reverted location: " + link.textContent);
79
80         var count1 = liveLocationsCount();
81         linkifier.reset();
82         var count2 = liveLocationsCount();
83
84         InspectorTest.addResult("listeners removed from raw source code: " + (count1 - count2));
85
86         InspectorTest.completeDebuggerTest();
87     }
88
89     function liveLocationsCount()
90     {
91         return WebInspector.debuggerWorkspaceBinding._ensureInfoForScript(script)._locations.size;
92     }
93 }
94
95 </script>
96 </head>
97
98 <body onload="onload()">
99 <p>
100 Tests that Linkifier works correctly.
101 <p>
102
103 </body>
104 </html>