This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental(debugger): make element explorer work with node 0.12.0
Node has changed its debugger significantly in 0.12.0, and these changes are necessary to get it to work now.
- Loading branch information
Showing
4 changed files
with
100 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
var baseDebugger = require('_debugger'); | ||
|
||
/** | ||
* Create a debugger client and attach to a running protractor process. | ||
* Set a break point at webdriver executor. | ||
* @param {number} pid Pid of the process to attach the debugger to. | ||
* @param {number=} opt_port Port to set up the debugger connection over. | ||
* @return {!baseDebugger.Client} The connected debugger client. | ||
*/ | ||
exports.attachDebugger = function(pid, opt_port) { | ||
var client = new baseDebugger.Client(); | ||
|
||
client.once('ready', function() { | ||
client.setBreakpoint({ | ||
type: 'scriptRegExp', | ||
target: '.*executors\.js', //jshint ignore:line | ||
line: 37 | ||
}, function() {}); | ||
}); | ||
|
||
process.debugPort = opt_port || 5858; | ||
// Call this private function instead of sending SIGUSR1 because Windows. | ||
process._debugProcess(pid); | ||
|
||
var host = 'localhost'; | ||
var connectWithRetry = function(attempts) { | ||
var socket = client.connect(process.debugPort, host); | ||
socket.on('connect', function() { | ||
client.reqContinue(function() { | ||
// Intentionally blank. | ||
}); | ||
}); | ||
socket.on('error', function(e) { | ||
if (attempts === 1) { | ||
throw e; | ||
} else { | ||
setTimeout(function() { | ||
connectWithRetry(attempts - 1); | ||
}, 200); | ||
} | ||
}); | ||
}; | ||
connectWithRetry(10); | ||
|
||
return client; | ||
}; | ||
|
||
/** | ||
* Trim excess symbols from the repl command so that it is consistent with | ||
* the user input. | ||
* @param {string} cmd Cmd provided by the repl server. | ||
* @return {string} The trimmed cmd. | ||
*/ | ||
exports.trimReplCmd = function(cmd) { | ||
// Given user input 'foobar', some versions of node provide '(foobar\n)', | ||
// while other versions of node provide 'foobar\n'. | ||
if (cmd.length >= 2 && cmd[0] === '(' && cmd[cmd.length - 1] === ')') { | ||
cmd = cmd.substring(1, cmd.length - 1); | ||
} | ||
return cmd.slice(0, cmd.length - 1); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters