| <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 sets a breakpoint on line:column in the <script> below. |
| // We set a breakpoint before evaluating 'sum += ...', and verify that |
| // call frame functionNames are what we expect. |
| |
| InspectorProtocol.sendCommand("Debugger.enable", {}); |
| InspectorProtocol.sendCommand("Debugger.setBreakpointsActive", {active: true}); |
| |
| InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject) |
| { |
| if (/call-frame-function-name\.html$/.test(messageObject.params.url) && messageObject.params.startLine > 10) { |
| ProtocolTest.log("Found <script>"); |
| var scriptIdentifier = messageObject.params.scriptId; |
| var lineNumber = messageObject.params.startLine + 6; |
| var columnNumber = 12; |
| 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 functionNames = [ ]; |
| var i; |
| for (i = 0; i < 3; i++) |
| functionNames[i] = messageObject.params.callFrames[i].functionName; |
| |
| function assertFunctionName(index, actual, expected) { |
| if (actual == expected) |
| ProtocolTest.log('PASS: frame[' + index + '] "' + actual + '"'); |
| else |
| ProtocolTest.log('FAIL: frame[' + index + '] expect "' + expected + '", actual "' + actual + '"'); |
| } |
| |
| // frame 0 should be the anonymous inner function. |
| assertFunctionName(0, functionNames[0], ""); |
| |
| // frame 1 should be "forEach" (an internal/host function). |
| assertFunctionName(1, functionNames[1], "forEach"); |
| |
| // frame 2 should be "testFunction". |
| assertFunctionName(2, functionNames[2], "testFunction"); |
| |
| ProtocolTest.completeTest(); |
| } |
| } |
| </script> |
| </head> |
| <body> |
| <p>Debugger.setBreakpoint on line:column in <script></p> |
| <script>// Line 0 |
| function testFunction() { // Line 1 |
| try { // Line 2 |
| var array = [2, 5, 7]; // Line 3 |
| var sum = 0; // Line 4 |
| array.forEach(function(value) { // Line 5 |
| sum += array[value]; // Line 6 |
| }); |
| } catch (e) { |
| console.log("Exception: " + e); |
| } |
| } |
| </script> |
| </body> |
| </html> |