Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector-enabled / sources / debugger / script-formatter-console.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 f1()
10 {
11     console.error("Test message.");
12 }
13
14 function onload()
15 {
16     if (window.testRunner) {
17         testRunner.waitUntilDone();
18         testRunner.showWebInspector();
19     }
20     runTest();
21 }
22
23 var test = function()
24 {
25     var panel = WebInspector.inspectorView.showPanel("sources");
26     var sourceFrame;
27     var scriptFormatter = InspectorTest.scriptFormatter();
28
29     InspectorTest.runDebuggerTestSuite([
30         function testConsoleMessagesForFormattedScripts(next)
31         {
32             InspectorTest.showScriptSource("script-formatter-console.html", didShowScriptSource);
33
34             function didShowScriptSource(frame)
35             {
36                 sourceFrame = frame;
37                 InspectorTest.evaluateInPage("f1()", didEvaluate);
38             }
39
40             function didEvaluate()
41             {
42                 dumpConsoleMessageURLs();
43                 InspectorTest.addResult("Pre-format row message list:");
44                 InspectorTest.addResult(JSON.stringify(Object.keys(sourceFrame._rowMessageBuckets)));
45                 InspectorTest.addSniffer(WebInspector.ScriptFormatterEditorAction.prototype, "_updateButton", uiSourceCodeScriptFormatted);
46                 scriptFormatter._toggleFormatScriptSource();
47             }
48
49             function uiSourceCodeScriptFormatted()
50             {
51                 dumpConsoleMessageURLs();
52                 InspectorTest.addResult("Post-format row message list:");
53                 var formattedSourceFrame = panel.visibleView;
54                 InspectorTest.addResult(JSON.stringify(Object.keys(formattedSourceFrame._rowMessageBuckets)));
55                 next();
56             }
57         }
58     ]);
59
60     function dumpConsoleMessageURLs()
61     {
62         WebInspector.inspectorView.panel("console");
63         var messages = WebInspector.ConsolePanel._view()._visibleViewMessages;
64         for (var i = 0; i < messages.length; ++i) {
65             var element = messages[i].toMessageElement();
66             var anchor = element.querySelector(".console-message-url");
67             InspectorTest.addResult(anchor.textContent);
68         }
69     }
70 }
71
72 </script>
73
74 </head>
75
76 <body onload="onload()">
77 <p>Tests that the script formatting changes console line numbers.
78 </p>
79
80 </body>
81 </html>