| <html> |
| <head> |
| <script src="../../http/tests/inspector/resources/protocol-test.js"></script> |
| <script src="resources/assert.js"></script> |
| <script> |
| function test() |
| { |
| InspectorProtocol.sendCommand("Debugger.enable", {}); |
| InspectorProtocol.sendCommand("Debugger.setBreakpointsActive", {active: true}); |
| InspectorProtocol.sendCommand("Debugger.setPauseOnExceptions", {state: "all"}, InspectorProtocol.checkForError); |
| InspectorProtocol.sendCommand("Debugger.setPauseOnAssertions", {enabled: true}, InspectorProtocol.checkForError); |
| |
| var step = null; |
| var steps = [ |
| { |
| message: "Should not pause on passing assert.", |
| evaluate: "assertTrue()", |
| pause: false, |
| }, |
| { |
| message: "Should pause on failing assert.", |
| evaluate: "assertFalse()", |
| pause: true, |
| }, |
| { |
| message: "Should not pause on passing assert.", |
| evaluate: "assertCondition(window)", |
| pause: false, |
| }, |
| { |
| message: "Should pause on failing assert.", |
| evaluate: "assertCondition(window === null)", |
| pause: true, |
| }, |
| { |
| message: "Should not pause on passing assert.", |
| evaluate: "assertConditionWithMessage(window, 'Should not happen')", |
| pause: false, |
| }, |
| { |
| message: "Should pause on failing assert and include a message.", |
| evaluate: "assertConditionWithMessage(window === null, 'ASSERT message')", |
| pause: true, |
| }, |
| ]; |
| |
| InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject) |
| { |
| if (step.pause) |
| ProtocolTest.log("PASS: Paused!"); |
| else |
| ProtocolTest.log("FAIL: Paused when unexpected"); |
| |
| InspectorProtocol.sendCommand("Debugger.resume", {}, runNextStep); |
| } |
| |
| function runNextStep() { |
| step = steps.shift(); |
| if (!step) { |
| ProtocolTest.completeTest(); |
| return; |
| } |
| |
| // Evalute the command inside a setTimeout so that we can hit exceptions and break. |
| // Otherwise, evaluating through RuntimeAgent will not trigger a pause. |
| // Likewise, if no pause is expected wait for a bit before continuing. |
| ProtocolTest.log(step.message); |
| InspectorProtocol.sendCommand("Runtime.evaluate", {expression: "setTimeout(function(){" + step.evaluate + "}, 0)"}, function(responseObject) { |
| InspectorProtocol.checkForError(responseObject); |
| if (!step.pause) |
| setTimeout(runNextStep, 20); |
| }); |
| } |
| |
| runNextStep(); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Test that a failing console.assert will pause in the debugger with an optional message.</p> |
| </body> |
| </html> |