Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
feat(pause): allow the user to specify a port to be used for debugging
Browse files Browse the repository at this point in the history
Using browser.pause(portNumber) will now start the debugger on the specified
port number.

Closes #956
  • Loading branch information
juliemr committed Jun 20, 2014
1 parent 6641c81 commit 8920028
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,10 @@ Protractor.prototype.debugger = function() {
* browser.pause() in your test to enter the protractor debugger from that
* point in the control flow.
* Does not require changes to the command line (no need to add 'debug').
*
* @param {=number} opt_debugPort Optional port to use for the debugging process
*/
Protractor.prototype.pause = function() {
Protractor.prototype.pause = function(opt_debugPort) {
// Patch in a function to help us visualize what's going on in the control
// flow.
webdriver.promise.ControlFlow.prototype.getControlFlowText = function() {
Expand Down Expand Up @@ -1171,6 +1173,10 @@ Protractor.prototype.pause = function() {
return asString;
};

if (opt_debugPort) {
process.debugPort = opt_debugPort;
}

// Call this private function instead of sending SIGUSR1 because Windows.
process._debugProcess(process.pid);
var flow = webdriver.promise.controlFlow();
Expand All @@ -1179,7 +1185,7 @@ Protractor.prototype.pause = function() {
console.log('Starting WebDriver debugger in a child process. Pause is ' +
'still beta, please report issues at github.com/angular/protractor');
var nodedebug = require('child_process').
fork(__dirname + '/wddebugger.js', ['localhost:5858']);
fork(__dirname + '/wddebugger.js', [process.debugPort]);
process.on('exit', function() {
nodedebug.kill('SIGTERM');
});
Expand Down
3 changes: 3 additions & 0 deletions lib/wddebugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ var client = new baseDebugger.Client();
var host = 'localhost';
var port = 5858;

if (process.argv[2]) {
port = process.argv[2];
}
var debuggerRepl;

var resumeReplCallback = null;
Expand Down

2 comments on commit 8920028

@lu4
Copy link

@lu4 lu4 commented on 8920028 Jun 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@asartalo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Sorry if this is a dumb question. How would one set this option?

Please sign in to comment.