blob: 70689ef159d5df8b15ec8f4df7cb056759690a26 [file] [log] [blame]
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script>
function oneLineTestFunction() { return 0; }
</script>
<script>
function oneLineTestFunction2() { return 0; }</script>
<script>
function testFunction()
{
var x = Math.sqrt(10);
return x;
}
var test = function()
{
var currentSourceFrame;
InspectorTest.setQuiet(true);
InspectorTest.runDebuggerTestSuite([
function testSetBreakpoint(next)
{
InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
function didShowScriptSource(sourceFrame)
{
currentSourceFrame = sourceFrame;
InspectorTest.addResult("Script source was shown.");
InspectorTest.setBreakpoint(currentSourceFrame, 16, "", true);
InspectorTest.runTestFunctionAndWaitUntilPaused(didPause);
}
function didPause(callFrames)
{
InspectorTest.addResult("Script execution paused.");
InspectorTest.captureStackTrace(callFrames);
dumpBreakpointSidebarPane();
InspectorTest.addSniffer(currentSourceFrame, "_removeBreakpointDecoration", breakpointRemoved);
InspectorTest.removeBreakpoint(currentSourceFrame, 16);
}
function breakpointRemoved()
{
InspectorTest.resumeExecution(didResume);
}
function didResume()
{
dumpBreakpointSidebarPane()
InspectorTest.addResult("Script execution resumed.");
next();
}
},
function testSetBreakpointOnTheLastLine(next)
{
InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
function didShowScriptSource(sourceFrame)
{
currentSourceFrame = sourceFrame;
InspectorTest.setBreakpoint(currentSourceFrame, 6, "", true);
InspectorTest.waitUntilPaused(didPause);
InspectorTest.evaluateInPage("setTimeout(oneLineTestFunction, 0)");
}
function didPause(callFrames)
{
InspectorTest.captureStackTrace(callFrames);
InspectorTest.removeBreakpoint(currentSourceFrame, 6);
InspectorTest.resumeExecution(next);
}
},
function testSetBreakpointOnTheLastLine2(next)
{
InspectorTest.showScriptSource("set-breakpoint.html", didShowScriptSource);
function didShowScriptSource(sourceFrame)
{
currentSourceFrame = sourceFrame;
InspectorTest.setBreakpoint(currentSourceFrame, 10, "", true);
InspectorTest.waitUntilPaused(didPause);
InspectorTest.evaluateInPage("setTimeout(oneLineTestFunction2, 0)");
}
function didPause(callFrames)
{
InspectorTest.captureStackTrace(callFrames);
InspectorTest.removeBreakpoint(currentSourceFrame, 10);
InspectorTest.resumeExecution(next);
}
},
function testSetBreakpointOnTheSameLine(next)
{
DebuggerAgent.setBreakpointByUrl(1, "foo.js", undefined, 2, {}, didSetBreakpoint);
function didSetBreakpoint(error, breakpointId)
{
InspectorTest.assertTrue(!error);
InspectorTest.assertTrue(!!breakpointId);
DebuggerAgent.setBreakpointByUrl(1, "foo.js", undefined, 2, {}, didSetBreakpointAgain);
}
function didSetBreakpointAgain(error, breakpointId)
{
InspectorTest.assertTrue(!!error);
InspectorTest.assertTrue(!breakpointId);
next();
}
}
]);
function dumpBreakpointSidebarPane()
{
var paneElement = WebInspector.panels.scripts.sidebarPanes.jsBreakpoints.listElement
InspectorTest.addResult("");
InspectorTest.addResult("Dump breakpoint sidebar pane:");
InspectorTest.addResult(InspectorTest.textContentWithLineBreaks(paneElement));
}
}
</script>
</head>
<body onload="runTest()">
<p>
Tests setting breakpoints.
</p>
</body>
</html>