Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / sources / debugger / set-breakpoint.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
6 <script>
7 function oneLineTestFunction() { return 0; }
8 </script>
9
10 <script>
11 function oneLineTestFunction2() { return 0; }</script>
12
13 <script>
14
15 function testFunction()
16 {
17     var x = Math.sqrt(10);
18     return x;
19 }
20
21 var test = function()
22 {
23     var currentSourceFrame;
24     InspectorTest.setQuiet(true);
25     InspectorTest.runDebuggerTestSuite([
26         function testSetBreakpoint(next)
27         {
28             InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
29
30             function didShowScriptSource(sourceFrame)
31             {
32                 currentSourceFrame = sourceFrame;
33                 InspectorTest.addResult("Script source was shown.");
34                 setBreakpointAndWaitUntilPaused(currentSourceFrame, 16, didPause);
35                 InspectorTest.runTestFunction();
36             }
37
38             function didPause(callFrames)
39             {
40                 InspectorTest.addResult("Script execution paused.");
41                 InspectorTest.captureStackTrace(callFrames);
42                 InspectorTest.dumpBreakpointSidebarPane();
43                 InspectorTest.addSniffer(currentSourceFrame, "_removeBreakpointDecoration", breakpointRemoved);
44                 InspectorTest.removeBreakpoint(currentSourceFrame, 16);
45             }
46
47             function breakpointRemoved()
48             {
49                 InspectorTest.resumeExecution(didResume);
50             }
51
52             function didResume()
53             {
54                 InspectorTest.dumpBreakpointSidebarPane()
55                 InspectorTest.addResult("Script execution resumed.");
56                 next();
57             }
58         },
59
60         function testSetBreakpointOnTheLastLine(next)
61         {
62             InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
63
64             function didShowScriptSource(sourceFrame)
65             {
66                 currentSourceFrame = sourceFrame;
67                 setBreakpointAndWaitUntilPaused(currentSourceFrame, 6, didPause);
68                 InspectorTest.evaluateInPage("setTimeout(oneLineTestFunction, 0)");
69             }
70
71             function didPause(callFrames)
72             {
73                 InspectorTest.captureStackTrace(callFrames);
74                 InspectorTest.removeBreakpoint(currentSourceFrame, 6);
75                 InspectorTest.resumeExecution(next);
76             }
77         },
78
79         function testSetBreakpointOnTheLastLine2(next)
80         {
81             InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
82
83             function didShowScriptSource(sourceFrame)
84             {
85                 currentSourceFrame = sourceFrame;
86                 InspectorTest.setBreakpoint(currentSourceFrame, 10, "", true);
87                 InspectorTest.waitUntilPaused(didPause);
88                 InspectorTest.evaluateInPage("setTimeout(oneLineTestFunction2, 0)");
89             }
90
91             function didPause(callFrames)
92             {
93                 InspectorTest.captureStackTrace(callFrames);
94                 InspectorTest.removeBreakpoint(currentSourceFrame, 10);
95                 InspectorTest.resumeExecution(next);
96             }
97         },
98
99         function testSetBreakpointOnTheSameLine(next)
100         {
101             DebuggerAgent.setBreakpointByUrl(1, "foo.js", undefined, 2, "", didSetBreakpoint);
102
103             function didSetBreakpoint(error, breakpointId)
104             {
105                 InspectorTest.assertTrue(!error);
106                 InspectorTest.assertTrue(!!breakpointId);
107                 DebuggerAgent.setBreakpointByUrl(1, "foo.js", undefined, 2, "", didSetBreakpointAgain);
108             }
109
110             function didSetBreakpointAgain(error, breakpointId)
111             {
112                 InspectorTest.assertTrue(!!error);
113                 InspectorTest.assertTrue(!breakpointId);
114                 next();
115             }
116         }
117     ]);
118
119     function setBreakpointAndWaitUntilPaused(sourceFrame, lineNumber, pausedCallback)
120     {
121         var expectedBreakpointId;
122         InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.prototype, "_didSetBreakpointInDebugger", didSetBreakpointInDebugger);
123         InspectorTest.setBreakpoint(sourceFrame, lineNumber, "", true);
124
125         function didSetBreakpointInDebugger(callback, breakpointId)
126         {
127             expectedBreakpointId = breakpointId;
128             InspectorTest.waitUntilPaused(didPause);
129         }
130
131         function didPause(callFrames, reason, breakpointIds)
132         {
133             InspectorTest.assertEquals(breakpointIds.length, 1);
134             InspectorTest.assertEquals(breakpointIds[0], expectedBreakpointId);
135             InspectorTest.assertEquals(reason, "other");
136
137             pausedCallback(callFrames);
138         }
139     }
140 }
141
142 </script>
143 </head>
144
145 <body onload="runTest()">
146 <p>
147 Tests setting breakpoints.
148 </p>
149
150 </body>
151 </html>