Chromium Code Reviews| Index: test/debugger/test-api.js |
| diff --git a/test/debugger/test-api.js b/test/debugger/test-api.js |
| index 3a24c66dac57b177661cbb564aacbe7ecd728a06..5687e554f87408f5b4ce908ad9ecca1181d4fa27 100644 |
| --- a/test/debugger/test-api.js |
| +++ b/test/debugger/test-api.js |
| @@ -45,6 +45,12 @@ class DebugWrapper { |
| StepFrame: 3, |
| }; |
| + // The different types of scripts matching enum ScriptType in objects.h. |
| + this.ScriptType = { Native: 0, |
| + Extension: 1, |
| + Normal: 2, |
| + Wasm: 3}; |
| + |
| // A copy of the scope types from runtime-debug.cc. |
| // NOTE: these constants should be backward-compatible, so |
| // add new ones to the end of this list. |
| @@ -78,6 +84,9 @@ class DebugWrapper { |
| // Store the current script id so we can skip corresponding break events. |
| this.thisScriptId = %FunctionGetScriptId(receive); |
| + // Stores all set breakpoints. |
| + this.breakpoints = new Set(); |
| + |
| // Register as the active wrapper. |
| assertTrue(activeWrapper === undefined); |
| activeWrapper = this; |
| @@ -136,25 +145,7 @@ class DebugWrapper { |
| const offset = %FunctionGetScriptSourcePosition(func); |
| const loc = |
| %ScriptLocationFromLine2(scriptid, opt_line, opt_column, offset); |
| - |
| - const params = { location : |
| - { scriptId : scriptid.toString(), |
| - lineNumber : loc.line, |
| - columnNumber : loc.column, |
| - }}; |
| - if (!!opt_condition) { |
| - params.condition = opt_condition; |
| - } |
| - |
| - const {msgid, msg} = this.createMessage("Debugger.setBreakpoint", params); |
| - this.sendMessage(msg); |
| - |
| - const reply = this.takeReplyChecked(msgid); |
| - assertTrue(reply.result !== undefined); |
| - const breakid = reply.result.breakpointId; |
| - assertTrue(breakid !== undefined); |
| - |
| - return breakid; |
| + return this.setBreakPointAtLocation(scriptid, loc, opt_condition); |
| } |
| setScriptBreakPoint(type, scriptid, opt_line, opt_column, opt_condition) { |
| @@ -166,32 +157,22 @@ class DebugWrapper { |
| setScriptBreakPointById(scriptid, opt_line, opt_column, opt_condition) { |
| const loc = %ScriptLocationFromLine2(scriptid, opt_line, opt_column, 0); |
| - |
| - const params = { location : |
| - { scriptId : scriptid.toString(), |
| - lineNumber : loc.line, |
| - columnNumber : loc.column, |
| - }}; |
| - if (!!opt_condition) { |
| - params.condition = opt_condition; |
| - } |
| - |
| - const {msgid, msg} = this.createMessage("Debugger.setBreakpoint", params); |
| - this.sendMessage(msg); |
| - |
| - const reply = this.takeReplyChecked(msgid); |
| - assertTrue(reply.result !== undefined); |
| - const breakid = reply.result.breakpointId; |
| - assertTrue(breakid !== undefined); |
| - |
| - return breakid; |
| + return this.setBreakPointAtLocation(scriptid, loc, opt_condition); |
| } |
| clearBreakPoint(breakid) { |
| + assertTrue(this.breakpoints.has(breakid)); |
| const {msgid, msg} = this.createMessage( |
| "Debugger.removeBreakpoint", { breakpointId : breakid }); |
| this.sendMessage(msg); |
| this.takeReplyChecked(msgid); |
| + this.breakpoints.delete(breakid); |
| + } |
| + |
| + clearAllBreakPoints() { |
| + for (let breakid of this.breakpoints) { |
| + this.clearBreakPoint(breakid); |
| + } |
|
Yang
2016/11/16 14:31:59
do we want to clear the set afterwards?
jgruber
2016/11/16 15:18:21
Sounds like a good idea.
Good catch :)
|
| } |
| showBreakPoints(f, opt_position_alignment) { |
| @@ -269,11 +250,32 @@ class DebugWrapper { |
| } |
| } |
| + // Returns the script source. If the parameter is a function the return value |
| + // is the script source for the script in which the function is defined. If the |
|
Yang
2016/11/16 14:31:59
80-char limit
jgruber
2016/11/16 15:18:21
Done.
|
| + // parameter is a string the return value is the script for which the script |
| + // name has that string value. |
| + scriptSource(func_or_script_name) { |
| + return this.findScript(func_or_script_name).source; |
| + }; |
| + |
| sourcePosition(f) { |
| if (!%IsFunction(f)) throw new Error("Not passed a Function"); |
| return %FunctionGetScriptSourcePosition(f); |
| }; |
| + // Returns the character position in a script based on a line number and an |
| + // optional position within that line. |
| + findScriptSourcePosition(script, opt_line, opt_column) { |
| + var location = %ScriptLocationFromLine(script, opt_line, opt_column, 0); |
| + return location ? location.position : null; |
| + }; |
| + |
| + findFunctionSourceLocation(func, opt_line, opt_column) { |
| + var script = %FunctionGetScript(func); |
| + var script_offset = %FunctionGetScriptSourcePosition(func); |
| + return %ScriptLocationFromLine(script, opt_line, opt_column, script_offset); |
| + } |
| + |
| setBreakPointsActive(enabled) { |
| const {msgid, msg} = this.createMessage( |
| "Debugger.setBreakpointsActive", { active : enabled }); |
| @@ -330,6 +332,28 @@ class DebugWrapper { |
| return reply; |
| } |
| + setBreakPointAtLocation(scriptid, loc, opt_condition) { |
| + const params = { location : |
| + { scriptId : scriptid.toString(), |
| + lineNumber : loc.line, |
| + columnNumber : loc.column, |
| + }, |
| + condition : opt_condition, |
| + }; |
| + |
| + const {msgid, msg} = this.createMessage("Debugger.setBreakpoint", params); |
| + this.sendMessage(msg); |
| + |
| + const reply = this.takeReplyChecked(msgid); |
| + assertTrue(reply.result !== undefined); |
| + const breakid = reply.result.breakpointId; |
| + assertTrue(breakid !== undefined); |
| + |
| + this.breakpoints.add(breakid); |
| + |
| + return breakid; |
| + } |
| + |
| execStatePrepareStep(action) { |
| switch(action) { |
| case this.StepAction.StepOut: this.stepOut(); break; |