| <html> | |
| <head> | |
| <script src="../../http/tests/inspector/resources/protocol-test.js"></script> | |
| <script> | |
| // Put this here instead of on <body onload> to prevent an extra Debugger.scriptParsed event. | |
| window.onload = runTest; | |
| function test() | |
| { | |
| // This test setting a breakpoint on line:column in the <script> below. | |
| // We set a breakpoint before evaluating `var b = ...`, and verify that | |
| // by running some expressions at that call frame. | |
| InspectorProtocol.sendCommand("Debugger.enable", {}); | |
| InspectorProtocol.sendCommand("Debugger.setBreakpointsActive", {active: true}); | |
| InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject) | |
| { | |
| if (/setBreakpoint-column\.html$/.test(messageObject.params.url) && messageObject.params.startLine > 10) { | |
| ProtocolTest.log("Found <script>"); | |
| var scriptIdentifier = messageObject.params.scriptId; | |
| var lineNumber = messageObject.params.startLine + 2; | |
| var columnNumber = 10; | |
| var location = {scriptId: scriptIdentifier, lineNumber: lineNumber, columnNumber: columnNumber}; | |
| InspectorProtocol.sendCommand("Debugger.setBreakpoint", {location: location}, function() { | |
| ProtocolTest.log("Running testFunction"); | |
| InspectorProtocol.sendCommand("Runtime.evaluate", {expression: "testFunction()"}); | |
| }); | |
| } | |
| } | |
| InspectorProtocol.eventHandler["Debugger.paused"] = function(messageObject) | |
| { | |
| ProtocolTest.log("Hit Breakpoint!"); | |
| var callFrameIdentifier = messageObject.params.callFrames[0].callFrameId; | |
| InspectorProtocol.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, expression: "a"}, function(messageObject) { | |
| ProtocolTest.log("Evaluted value of `a` (expecting number 1) was: " + JSON.stringify(messageObject.result.result)); | |
| InspectorProtocol.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, expression: "b"}, function(messageObject) { | |
| ProtocolTest.log("Evaluted value of `b` (expecting undefined) was: " + JSON.stringify(messageObject.result.result)); | |
| InspectorProtocol.sendCommand("Debugger.disable"); | |
| ProtocolTest.completeTest(); | |
| }); | |
| }); | |
| } | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <p>Debugger.setBreakpoint on line:column in <script></p> | |
| <script>// Line 0 | |
| function testFunction() {// Line 1 | |
| var a = 1;var b = a + 1;// Line 2 | |
| }// Line 3 | |
| </script> | |
| </body> | |
| </html> |