blob: 764779694d0d7fde73468fc4e7a00ed5a6e27c09 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script src="resources/breakpoint-options-utilities.js"></script>
<script>
function triggerAssertions() {
console.assert(true, "Passing assertion");
console.assert(false, "Failing assertion");
TestPage.dispatchEventToFrontend("TestPage-assertions");
}
function test()
{
// Pause on all exceptions should not affect pausing on assertions.
WI.debuggerManager.allExceptionsBreakpoint.disabled = false;
let suite = InspectorTest.createAsyncSuite("Debugger.setPauseOnAssertions");
suite.addTestCase({
name: "Debugger.setPauseOnAssertions.Disabled",
description: "Do not pause on assertions when disabled.",
test(resolve, reject) {
InspectorTest.assert(WI.debuggerManager.assertionFailuresBreakpoint, "Should already have assertion failures breakpoint.");
InspectorTest.assert(WI.debuggerManager.assertionFailuresBreakpoint.disabled, "Assertion failures breakpoint should be disabled.");
let listener = WI.debuggerManager.singleFireEventListener(WI.DebuggerManager.Event.Paused, (event) => {
InspectorTest.fail("Should not have paused.");
reject();
});
InspectorTest.evaluateInPage("triggerAssertions()", () => {
InspectorTest.pass("Should not pause.");
WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
WI.debuggerManager.assertionFailuresBreakpoint.remove();
InspectorTest.assert(!WI.debuggerManager.assertionFailuresBreakpoint, "Should have destroyed assertion failures breakpoint.");
resolve();
});
}
});
suite.addTestCase({
name: "Debugger.setPauseOnAssertions.Enabled",
description: "Pause on assertions when enabled.",
test(resolve, reject) {
WI.debuggerManager.createAssertionFailuresBreakpoint();
InspectorTest.assert(WI.debuggerManager.assertionFailuresBreakpoint, "Should have created assertion failures breakpoint.");
InspectorTest.assert(!WI.debuggerManager.assertionFailuresBreakpoint.disabled, "Assertion failures breakpoint should be enabled.");
let didPause = false;
let listener = WI.debuggerManager.singleFireEventListener(WI.DebuggerManager.Event.Paused, (event) => {
InspectorTest.pass("Should paused.");
WI.debuggerManager.resume();
didPause = true;
});
InspectorTest.evaluateInPage("triggerAssertions()", () => {
if (!didPause)
InspectorTest.fail("Should have paused.");
WI.debuggerManager.assertionFailuresBreakpoint.remove();
InspectorTest.assert(!WI.debuggerManager.assertionFailuresBreakpoint, "Should have destroyed assertion failures breakpoint.");
resolve();
});
}
});
InspectorTest.BreakpointOptions.addTestCases(suite, {
createBreakpoint() {
WI.debuggerManager.createAssertionFailuresBreakpoint();
return WI.debuggerManager.assertionFailuresBreakpoint;
},
triggerBreakpoint() {
return Promise.all([
InspectorTest.awaitEvent("TestPage-assertions"),
InspectorTest.evaluateInPage(`triggerAssertions()`),
]);
},
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Debugger.setPauseOnAssertions</p>
</body>
</html>