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

Commit

Permalink
fix(elementexplorer): Set script breakpoints with cross-platform safe
Browse files Browse the repository at this point in the history
paths.

Fixes #4011
  • Loading branch information
heathkit committed May 9, 2017
1 parent 42846ec commit fd59c78
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/debugger/debuggerCommons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var baseDebugger = require('_debugger');
var path = require('path');

/**
* Create a debugger client and attach to a running protractor process.
Expand Down Expand Up @@ -34,11 +35,13 @@ exports.attachDebugger = function(pid, opt_port) {

/**
* Set a breakpoint for evaluating REPL statements.
* This sets a breakpoint in Protractor's breakpointhook.js, so that we'll
* break after executing a command from the REPL.
*/
exports.setEvaluateBreakpoint = function(client, cb) {
client.setBreakpoint({
type: 'scriptRegExp',
target: 'built/breakpointhook\.js', //jshint ignore:line
target: prepareDebuggerPath('built', 'breakpointhook.js'),
line: 2
}, function(err, response) {
if (err) {
Expand All @@ -50,11 +53,18 @@ exports.setEvaluateBreakpoint = function(client, cb) {

/**
* Set a breakpoint for moving forward by one webdriver command.
* This sets a breakpoint in selenium-webdriver/lib/http.js, and is
* extremely sensitive to the selenium version. It works for
* selenium-webdriver 3.0.1
* This breaks on the following line in http.js:
* let request = buildRequest(this.customCommands_, this.w3c, command);
* And will need to break at a similar point in future selenium-webdriver
* versions.
*/
exports.setWebDriverCommandBreakpoint = function(client, cb) {
client.setBreakpoint({
type: 'scriptRegExp',
target: 'lib/http\.js', //jshint ignore:line
target: prepareDebuggerPath('lib', 'http.js'),
line: 433
}, function(err, response) {
if (err) {
Expand All @@ -64,6 +74,15 @@ exports.setWebDriverCommandBreakpoint = function(client, cb) {
});
};

/**
* Create a cross-platform friendly path for setting scriptRegExp breakpoints.
*/
function prepareDebuggerPath(...parts) {
return path.join(...parts)
.replace('\\', '\\\\')
.replace('.', '\\.');
}

/**
* Trim excess symbols from the repl command so that it is consistent with
* the user input.
Expand Down

0 comments on commit fd59c78

Please sign in to comment.