From 71839af61cff1d8e15a8ccdf78f74b800600a927 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Sun, 29 Jan 2012 13:41:31 -0800 Subject: [PATCH] continueToLocation --- lib/session2.js | 55 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/lib/session2.js b/lib/session2.js index a3fa5d72..e9ebfe2c 100644 --- a/lib/session2.js +++ b/lib/session2.js @@ -20,6 +20,7 @@ function Session(debugPort) { this.browser = nilBrowser this.debugPort = debugPort this.breakpointsActive = true + this.tempBreakpointId = 0 } inherits(Session, EventEmitter) @@ -47,10 +48,46 @@ Session.prototype.setScriptSource = function (sourceID, newContent, preview, seq } Session.prototype.setPauseOnExceptions = function (state, seq) { + //TODO not fully working + switch (state) { + case 'all': + this.client.setExceptionBreak('all', true, function (err, body) { + console.log(body) + }) + break; + case 'uncaught': + this.client.setExceptionBreak('uncaught', true, function (err, body) { + console.log(body) + }) + break; + case 'none': + this.client.setExceptionBreak('all', false, function (err, body) { + console.log(body) + }) + break; + } this.browser.sendResponse(seq, true) } -Session.prototype.continueToLocation = function (location, id) {} +Session.prototype.continueToLocation = function (location, seq) { + var self = this + if (this.tempBreakpointId !== 0) { + this.client.clearBreakpoint(this.tempBreakpointId, nop) + } + this.client.setBreakpoint( + location.scriptId, + location.lineNumber, + location.columnNumber, + true, + null, + function (err, body) { + if (!err) { + self.tempBreakpointId = body.breakpoint + } + self.resume() + } + ) +} Session.prototype.stepOut = function () { this.client.resume('out', 1, nop) @@ -136,10 +173,6 @@ Session.prototype.getInspectorState = function (seq) { }) } -Session.prototype.populateScriptObjects = function (seq) { - this.browser.sendResponse(seq, true) -} - Session.prototype.disableDebugger = nop Session.prototype.callFunctionOn = function ( @@ -309,8 +342,6 @@ Session.prototype.getBacktraceFlow = function () { }) } -Session.prototype.evaluateFlow = nop - Session.prototype.browserConnectedFlow = function () { var self = this async.waterfall( @@ -367,6 +398,16 @@ Session.prototype.parsedScriptsFlow = function (body) { Session.prototype.breakEventFlow = function (msg) { if (this.breakpointsActive) { + var breakpoints = msg.body.breakpoints || [] + if (breakpoints.indexOf(this.tempBreakpointId) > -1) { + var self = this + this.client.clearBreakpoint( + this.tempBreakpointId, + function (err, body) { + self.tempBreakpointId = 0 + } + ) + } this.getBacktraceFlow() } else {