Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / monitor-console-command.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 src="../../../http/tests/inspector/console-test.js"></script>
6
7 <script>
8 function simpleTestFunction()
9 {
10    return 0;
11 }
12 </script>
13
14 <script>
15 function simpleTestFunction2()
16 {
17    return simpleTestFunction3();
18 }
19
20 function simpleTestFunction3()
21 {
22    return 0;
23 }
24 </script>
25
26 <script>
27 var test = function()
28 {
29     var currentSourceFrame;
30     InspectorTest.setQuiet(true);
31     InspectorTest.runDebuggerTestSuite([
32         function testSimpleMonitor(next)
33         {
34             monitorAndRun(next, "simpleTestFunction", "simpleTestFunction();");
35         },
36
37         function testSimpleMonitorWith1Arg(next)
38         {
39             monitorAndRun(next, "simpleTestFunction", "simpleTestFunction(1);");
40         },
41
42         function testSimpleMonitorWithManyArgs(next)
43         {
44             monitorAndRun(next, "simpleTestFunction", "simpleTestFunction(1, 2, 3, 4 ,5);");
45         },
46
47         function testSimpleUnmonitor(next)
48         {
49             InspectorTest.evaluateInConsole("monitor(simpleTestFunction2)");
50             InspectorTest.evaluateInConsole("unmonitor(simpleTestFunction2)");
51             monitorAndRun(next, "simpleTestFunction3", "simpleTestFunction2();");
52         },
53
54         function testUnmonitorFuntionNotMonitored(next)
55         {
56             InspectorTest.evaluateInConsole("monitor(simpleTestFunction)", next);
57         }
58     ]);
59
60     function monitorAndRun(next, functionName, runCmd)
61     {
62         InspectorTest.evaluateInConsole("monitor(" + functionName + ")");
63         InspectorTest.addResult("Start monitoring function.");
64
65         InspectorTest.evaluateInConsole("setTimeout(function() { " + runCmd + " }, 0)");
66         InspectorTest.addResult("Set timer for test function.");
67         InspectorTest.waitUntilMessageReceived(didReceive);
68
69         function didReceive(message, isFromBackend)
70         {
71             if (!isFromBackend) {
72                 InspectorTest.waitUntilMessageReceived(didReceive);
73                 return;
74             }
75
76             InspectorTest.addResult("Console message received: " + message.message);
77             InspectorTest.evaluateInConsole("unmonitor(" + functionName + ")");
78             InspectorTest.addResult("Stop monitoring.");
79             next();
80         }
81     }
82 }
83
84 </script>
85 </head>
86
87 <body onload="runTest()">
88 <p>
89 Tests traceCalls(fn) console command.
90 </p>
91
92 </body>
93 </html>