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>
8 function simpleTestFunction()
15 function simpleTestFunction1() { return 0; } function simpleTestFunction2() { return 0; }
19 function simpleTestFunction3() { Math.random(); debugger; }
25 var currentSourceFrame;
26 InspectorTest.setQuiet(true);
27 InspectorTest.runDebuggerTestSuite([
28 function testSetSimpleBreakpoint(next)
30 setBreakpointAndRun(next, "simpleTestFunction", "simpleTestFunction();");
33 function testSetBreakpointOnFirstFunctionInLine(next)
35 setBreakpointAndRun(next, "simpleTestFunction1", "simpleTestFunction2(); simpleTestFunction1();");
38 function testSetBreakpointOnLastFunctionInLine(next)
40 setBreakpointAndRun(next, "simpleTestFunction2", "simpleTestFunction1(); simpleTestFunction2();");
43 function testRemoveBreakpoint(next)
45 InspectorTest.evaluateInConsole("debug(simpleTestFunction3); undebug(simpleTestFunction3);");
46 InspectorTest.evaluateInConsole("setTimeout(simpleTestFunction3, 0)");
47 InspectorTest.waitUntilPaused(didPause1);
49 function didPause1(callFrames, reason)
51 InspectorTest.addResult("Script execution paused.");
52 InspectorTest.addResult("Reason for pause: " + (reason == WebInspector.DebuggerModel.BreakReason.DebugCommand ? "debug command" : "debugger statement") + ".");
58 function setBreakpointAndRun(next, functionName, runCmd)
60 InspectorTest.evaluateInConsole("debug(" + functionName + ")");
62 InspectorTest.addResult("Breakpoint added.");
63 InspectorTest.evaluateInConsole("setTimeout(function() { " + runCmd + " }, 0)");
64 InspectorTest.addResult("Set timer for test function.");
65 InspectorTest.waitUntilPaused(didPause);
67 function didPause(callFrames, reason)
69 InspectorTest.addResult("Script execution paused.");
70 InspectorTest.captureStackTrace(callFrames);
71 InspectorTest.evaluateInConsole("undebug(" + functionName + ")");
72 InspectorTest.addResult("Breakpoint removed.");
73 InspectorTest.assertEquals(reason, WebInspector.DebuggerModel.BreakReason.DebugCommand);
74 InspectorTest.resumeExecution(didResume);
79 InspectorTest.addResult("Script execution resumed.");
88 <body onload="runTest()">
90 Tests debug(fn) console command.