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

Commit fd59c78

Browse files
committed
fix(elementexplorer): Set script breakpoints with cross-platform safe
paths. Fixes #4011
1 parent 42846ec commit fd59c78

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/debugger/debuggerCommons.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var baseDebugger = require('_debugger');
2+
var path = require('path');
23

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

3536
/**
3637
* Set a breakpoint for evaluating REPL statements.
38+
* This sets a breakpoint in Protractor's breakpointhook.js, so that we'll
39+
* break after executing a command from the REPL.
3740
*/
3841
exports.setEvaluateBreakpoint = function(client, cb) {
3942
client.setBreakpoint({
4043
type: 'scriptRegExp',
41-
target: 'built/breakpointhook\.js', //jshint ignore:line
44+
target: prepareDebuggerPath('built', 'breakpointhook.js'),
4245
line: 2
4346
}, function(err, response) {
4447
if (err) {
@@ -50,11 +53,18 @@ exports.setEvaluateBreakpoint = function(client, cb) {
5053

5154
/**
5255
* Set a breakpoint for moving forward by one webdriver command.
56+
* This sets a breakpoint in selenium-webdriver/lib/http.js, and is
57+
* extremely sensitive to the selenium version. It works for
58+
* selenium-webdriver 3.0.1
59+
* This breaks on the following line in http.js:
60+
* let request = buildRequest(this.customCommands_, this.w3c, command);
61+
* And will need to break at a similar point in future selenium-webdriver
62+
* versions.
5363
*/
5464
exports.setWebDriverCommandBreakpoint = function(client, cb) {
5565
client.setBreakpoint({
5666
type: 'scriptRegExp',
57-
target: 'lib/http\.js', //jshint ignore:line
67+
target: prepareDebuggerPath('lib', 'http.js'),
5868
line: 433
5969
}, function(err, response) {
6070
if (err) {
@@ -64,6 +74,15 @@ exports.setWebDriverCommandBreakpoint = function(client, cb) {
6474
});
6575
};
6676

77+
/**
78+
* Create a cross-platform friendly path for setting scriptRegExp breakpoints.
79+
*/
80+
function prepareDebuggerPath(...parts) {
81+
return path.join(...parts)
82+
.replace('\\', '\\\\')
83+
.replace('.', '\\.');
84+
}
85+
6786
/**
6887
* Trim excess symbols from the repl command so that it is consistent with
6988
* the user input.

0 commit comments

Comments
 (0)