3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
7 function oneLineTestFunction() { return 0; }
11 function oneLineTestFunction2() { return 0; }</script>
15 function testFunction()
17 var x = Math.sqrt(10);
23 var currentSourceFrame;
24 InspectorTest.setQuiet(true);
25 InspectorTest.runDebuggerTestSuite([
26 function testSetBreakpoint(next)
28 InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
30 function didShowScriptSource(sourceFrame)
32 currentSourceFrame = sourceFrame;
33 InspectorTest.addResult("Script source was shown.");
34 setBreakpointAndWaitUntilPaused(currentSourceFrame, 16, didPause);
35 InspectorTest.runTestFunction();
38 function didPause(callFrames)
40 InspectorTest.addResult("Script execution paused.");
41 InspectorTest.captureStackTrace(callFrames);
42 InspectorTest.dumpBreakpointSidebarPane();
43 InspectorTest.addSniffer(currentSourceFrame, "_removeBreakpointDecoration", breakpointRemoved);
44 InspectorTest.removeBreakpoint(currentSourceFrame, 16);
47 function breakpointRemoved()
49 InspectorTest.resumeExecution(didResume);
54 InspectorTest.dumpBreakpointSidebarPane()
55 InspectorTest.addResult("Script execution resumed.");
60 function testSetBreakpointOnTheLastLine(next)
62 InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
64 function didShowScriptSource(sourceFrame)
66 currentSourceFrame = sourceFrame;
67 setBreakpointAndWaitUntilPaused(currentSourceFrame, 6, didPause);
68 InspectorTest.evaluateInPage("setTimeout(oneLineTestFunction, 0)");
71 function didPause(callFrames)
73 InspectorTest.captureStackTrace(callFrames);
74 InspectorTest.removeBreakpoint(currentSourceFrame, 6);
75 InspectorTest.resumeExecution(next);
79 function testSetBreakpointOnTheLastLine2(next)
81 InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
83 function didShowScriptSource(sourceFrame)
85 currentSourceFrame = sourceFrame;
86 InspectorTest.setBreakpoint(currentSourceFrame, 10, "", true);
87 InspectorTest.waitUntilPaused(didPause);
88 InspectorTest.evaluateInPage("setTimeout(oneLineTestFunction2, 0)");
91 function didPause(callFrames)
93 InspectorTest.captureStackTrace(callFrames);
94 InspectorTest.removeBreakpoint(currentSourceFrame, 10);
95 InspectorTest.resumeExecution(next);
99 function testSetBreakpointOnTheSameLine(next)
101 DebuggerAgent.setBreakpointByUrl(1, "foo.js", undefined, 2, "", didSetBreakpoint);
103 function didSetBreakpoint(error, breakpointId)
105 InspectorTest.assertTrue(!error);
106 InspectorTest.assertTrue(!!breakpointId);
107 DebuggerAgent.setBreakpointByUrl(1, "foo.js", undefined, 2, "", didSetBreakpointAgain);
110 function didSetBreakpointAgain(error, breakpointId)
112 InspectorTest.assertTrue(!!error);
113 InspectorTest.assertTrue(!breakpointId);
119 function setBreakpointAndWaitUntilPaused(sourceFrame, lineNumber, pausedCallback)
121 var expectedBreakpointId;
122 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.prototype, "_didSetBreakpointInDebugger", didSetBreakpointInDebugger);
123 InspectorTest.setBreakpoint(sourceFrame, lineNumber, "", true);
125 function didSetBreakpointInDebugger(callback, breakpointId)
127 expectedBreakpointId = breakpointId;
128 InspectorTest.waitUntilPaused(didPause);
131 function didPause(callFrames, reason, breakpointIds)
133 InspectorTest.assertEquals(breakpointIds.length, 1);
134 InspectorTest.assertEquals(breakpointIds[0], expectedBreakpointId);
135 InspectorTest.assertEquals(reason, "other");
137 pausedCallback(callFrames);
145 <body onload="runTest()">
147 Tests setting breakpoints.