Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
157
node_modules/protractor/built/debugger/clients/explorer.js
generated
vendored
Normal file
157
node_modules/protractor/built/debugger/clients/explorer.js
generated
vendored
Normal file
|
@ -0,0 +1,157 @@
|
|||
var repl = require('repl');
|
||||
var debuggerCommons = require('../debuggerCommons');
|
||||
var CommandRepl = require('../modes/commandRepl');
|
||||
|
||||
/**
|
||||
* BETA BETA BETA
|
||||
* Custom explorer to test protractor commands.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var WdRepl = function() {
|
||||
this.client;
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiate a server to handle IO.
|
||||
* @param {number} port The port to start the server.
|
||||
* @private
|
||||
*/
|
||||
WdRepl.prototype.initServer_ = function(port) {
|
||||
var net = require('net');
|
||||
var self = this;
|
||||
var cmdRepl = new CommandRepl(this.client);
|
||||
|
||||
var received = '';
|
||||
net.createServer(function(sock) {
|
||||
sock.on('data', function(data) {
|
||||
received += data.toString();
|
||||
var eolIndex = received.indexOf('\r\n');
|
||||
if (eolIndex === 0) {
|
||||
return;
|
||||
}
|
||||
var input = received.substring(0, eolIndex);
|
||||
received = received.substring(eolIndex + 2);
|
||||
if (data[0] === 0x1D) {
|
||||
// '^]': term command
|
||||
self.client.req({command: 'disconnect'}, function() {
|
||||
// Intentionally blank.
|
||||
});
|
||||
sock.end();
|
||||
// TODO(juliemr): Investigate why this is necessary. At this point, there
|
||||
// should be no active listeners so this process should just exit
|
||||
// by itself.
|
||||
process.exit(0);
|
||||
} else if (input[input.length - 1] === '\t') {
|
||||
// If the last character is the TAB key, this is an autocomplete
|
||||
// request. We use everything before the TAB as the init data to feed
|
||||
// into autocomplete.
|
||||
input = input.substring(0, input.length - 1);
|
||||
cmdRepl.complete(input, function(err, res) {
|
||||
if (err) {
|
||||
sock.write('ERROR: ' + err + '\r\n');
|
||||
} else {
|
||||
sock.write(JSON.stringify(res) + '\r\n');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Normal input
|
||||
input = input.trim();
|
||||
cmdRepl.stepEval(input, function(err, res) {
|
||||
if (err) {
|
||||
sock.write('ERROR: ' + err + '\r\n');
|
||||
return;
|
||||
}
|
||||
if (res === undefined) {
|
||||
res = '';
|
||||
}
|
||||
sock.write(res + '\r\n');
|
||||
});
|
||||
}
|
||||
});
|
||||
}).listen(port);
|
||||
|
||||
console.log('Server listening on 127.0.0.1:' + port);
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiate a repl to handle IO.
|
||||
* @private
|
||||
*/
|
||||
WdRepl.prototype.initRepl_ = function() {
|
||||
var self = this;
|
||||
var cmdRepl = new CommandRepl(this.client);
|
||||
|
||||
// Eval function for processing a single step in repl.
|
||||
var stepEval = function(cmd, context, filename, callback) {
|
||||
// The command that eval feeds is of the form '(CMD\n)', so we trim the
|
||||
// double quotes and new line.
|
||||
cmd = debuggerCommons.trimReplCmd(cmd);
|
||||
cmdRepl.stepEval(cmd, function(err, res) {
|
||||
// Result is a string representation of the evaluation.
|
||||
if (res !== undefined) {
|
||||
console.log(res);
|
||||
}
|
||||
callback(err, undefined);
|
||||
});
|
||||
};
|
||||
|
||||
var replServer = repl.start({
|
||||
prompt: cmdRepl.prompt,
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
eval: stepEval,
|
||||
useGlobal: false,
|
||||
ignoreUndefined: true,
|
||||
completer: cmdRepl.complete.bind(cmdRepl)
|
||||
});
|
||||
|
||||
replServer.on('exit', function() {
|
||||
console.log('Element Explorer Exiting...');
|
||||
self.client.req({command: 'disconnect'}, function() {
|
||||
// TODO(juliemr): Investigate why this is necessary. At this point, there
|
||||
// should be no active listeners so this process should just exit
|
||||
// by itself.
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiate a repl or a server.
|
||||
* @private
|
||||
*/
|
||||
WdRepl.prototype.initReplOrServer_ = function() {
|
||||
// Note instead of starting either repl or server, another approach is to
|
||||
// feed the server socket into the repl as the input/output streams. The
|
||||
// advantage is that the process becomes much more realistic because now we're
|
||||
// using the normal repl. However, it was not possible to test autocomplete
|
||||
// this way since we cannot immitate the TAB key over the wire.
|
||||
var debuggerServerPort = process.argv[4];
|
||||
if (debuggerServerPort) {
|
||||
this.initServer_(debuggerServerPort);
|
||||
} else {
|
||||
this.initRepl_();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initiate the debugger.
|
||||
* @public
|
||||
*/
|
||||
WdRepl.prototype.init = function() {
|
||||
var self = this;
|
||||
this.client = debuggerCommons.attachDebugger(process.argv[2], process.argv[3]);
|
||||
this.client.once('ready', function() {
|
||||
debuggerCommons.setEvaluateBreakpoint(self.client, function() {
|
||||
process.send('ready');
|
||||
self.client.reqContinue(function() {
|
||||
// Intentionally blank.
|
||||
});
|
||||
});
|
||||
self.initReplOrServer_();
|
||||
});
|
||||
};
|
||||
|
||||
var wdRepl = new WdRepl();
|
||||
wdRepl.init();
|
83
node_modules/protractor/built/debugger/clients/wddebugger.js
generated
vendored
Normal file
83
node_modules/protractor/built/debugger/clients/wddebugger.js
generated
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
var repl = require('repl');
|
||||
var debuggerCommons = require('../debuggerCommons');
|
||||
var DebuggerRepl = require('../modes/debuggerRepl');
|
||||
|
||||
/**
|
||||
* Custom protractor debugger which steps through one control flow task at a time.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var WdDebugger = function() {
|
||||
this.client;
|
||||
this.replServer;
|
||||
this.dbgRepl;
|
||||
};
|
||||
|
||||
/**
|
||||
* Eval function for processing a single step in repl.
|
||||
* @private
|
||||
* @param {string} cmd
|
||||
* @param {object} context
|
||||
* @param {string} filename
|
||||
* @param {function} callback
|
||||
*/
|
||||
WdDebugger.prototype.stepEval_ = function(cmd, context, filename, callback) {
|
||||
// The loop won't come back until 'callback' is called.
|
||||
// Note - node's debugger gets around this by adding custom objects
|
||||
// named 'c', 's', etc to the REPL context. They have getters which
|
||||
// perform the desired function, and the callback is stored for later use.
|
||||
// Think about whether this is a better pattern.
|
||||
|
||||
cmd = debuggerCommons.trimReplCmd(cmd);
|
||||
this.dbgRepl.stepEval(cmd, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiate all repl objects, and debuggerRepl as current and start repl.
|
||||
* @private
|
||||
*/
|
||||
WdDebugger.prototype.initRepl_ = function() {
|
||||
var self = this;
|
||||
this.dbgRepl = new DebuggerRepl(this.client);
|
||||
|
||||
// We want the prompt to show up only after the controlflow text prints.
|
||||
this.dbgRepl.printControlFlow_(function() {
|
||||
self.replServer = repl.start({
|
||||
prompt: self.dbgRepl.prompt,
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
eval: self.stepEval_.bind(self),
|
||||
useGlobal: false,
|
||||
ignoreUndefined: true,
|
||||
completer: self.dbgRepl.complete.bind(self.dbgRepl)
|
||||
});
|
||||
|
||||
self.replServer.on('exit', function() {
|
||||
console.log('Resuming code execution');
|
||||
self.client.req({command: 'disconnect'}, function() {
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Initiate the debugger.
|
||||
* @public
|
||||
*/
|
||||
WdDebugger.prototype.init = function() {
|
||||
var self = this;
|
||||
this.client = debuggerCommons.attachDebugger(process.argv[2], process.argv[3]);
|
||||
this.client.once('ready', function() {
|
||||
debuggerCommons.setWebDriverCommandBreakpoint(self.client, function() {
|
||||
process.send('ready');
|
||||
self.client.reqContinue(function() {
|
||||
// Intentionally blank.
|
||||
});
|
||||
});
|
||||
self.initRepl_();
|
||||
});
|
||||
};
|
||||
|
||||
var wdDebugger = new WdDebugger();
|
||||
wdDebugger.init();
|
113
node_modules/protractor/built/debugger/debuggerCommons.js
generated
vendored
Normal file
113
node_modules/protractor/built/debugger/debuggerCommons.js
generated
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
var baseDebugger;
|
||||
try {
|
||||
baseDebugger = require('_debugger');
|
||||
} catch (e) {
|
||||
if (e.code == 'MODULE_NOT_FOUND') {
|
||||
console.log('***********************************************************');
|
||||
console.log('* WARNING: _debugger module not available on Node.js 8 *');
|
||||
console.log('* and higher. *');
|
||||
console.log('* *');
|
||||
console.log('* Use \'debugger\' keyword instead: *');
|
||||
console.log('* https://goo.gl/MvWqFh *');
|
||||
console.log('***********************************************************');
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
var path = require('path');
|
||||
|
||||
/**
|
||||
* Create a debugger client and attach to a running protractor process.
|
||||
* @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();
|
||||
var port = opt_port || process.debugPort;
|
||||
|
||||
// Call this private function instead of sending SIGUSR1 because Windows.
|
||||
process._debugProcess(pid);
|
||||
|
||||
// Connect to debugger on port with retry 200ms apart.
|
||||
var connectWithRetry = function(attempts) {
|
||||
client.connect(port, 'localhost')
|
||||
.on('error', function(e) {
|
||||
if (attempts === 1) {
|
||||
throw e;
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
connectWithRetry(attempts - 1);
|
||||
}, 200);
|
||||
}
|
||||
});
|
||||
};
|
||||
connectWithRetry(10);
|
||||
|
||||
return client;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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: prepareDebuggerPath('built', 'breakpointhook.js'),
|
||||
line: 2
|
||||
}, function(err, response) {
|
||||
if (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
cb(response.breakpoint);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 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: prepareDebuggerPath('lib', 'http.js'),
|
||||
line: 433
|
||||
}, function(err, response) {
|
||||
if (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
cb(response.breakpoint);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @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);
|
||||
};
|
127
node_modules/protractor/built/debugger/modes/commandRepl.js
generated
vendored
Normal file
127
node_modules/protractor/built/debugger/modes/commandRepl.js
generated
vendored
Normal file
|
@ -0,0 +1,127 @@
|
|||
var REPL_INITIAL_SUGGESTIONS = [
|
||||
'element(by.id(\'\'))',
|
||||
'element(by.css(\'\'))',
|
||||
'element(by.name(\'\'))',
|
||||
'element(by.binding(\'\'))',
|
||||
'element(by.xpath(\'\'))',
|
||||
'element(by.tagName(\'\'))',
|
||||
'element(by.className(\'\'))'
|
||||
];
|
||||
|
||||
/**
|
||||
* Repl to interactively run commands in the context of the test.
|
||||
*
|
||||
* @param {Client} node debugger client.
|
||||
* @constructor
|
||||
*/
|
||||
var CommandRepl = function(client) {
|
||||
this.client = client;
|
||||
this.prompt = '> ';
|
||||
};
|
||||
|
||||
/**
|
||||
* Eval function for processing a single step in repl.
|
||||
* Call callback with the result when complete.
|
||||
*
|
||||
* @public
|
||||
* @param {string} expression
|
||||
* @param {function} callback
|
||||
*/
|
||||
CommandRepl.prototype.stepEval = function(expression, callback) {
|
||||
expression = expression.replace(/"/g, '\\\"');
|
||||
|
||||
var expr = 'browser.debugHelper.dbgCodeExecutor.execute("' + expression + '")';
|
||||
this.evaluate_(expr, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Autocomplete user entries.
|
||||
* Call callback with the suggestions.
|
||||
*
|
||||
* @public
|
||||
* @param {string} line Initial user entry
|
||||
* @param {function} callback
|
||||
*/
|
||||
CommandRepl.prototype.complete = function(line, callback) {
|
||||
if (line === '') {
|
||||
callback(null, [REPL_INITIAL_SUGGESTIONS, '']);
|
||||
} else {
|
||||
// TODO(juliemr): This is freezing the program!
|
||||
line = line.replace(/"/g, '\\\"');
|
||||
var expr = 'browser.debugHelper.dbgCodeExecutor.complete("' + line + '")';
|
||||
this.evaluate_(expr, function(err, res) {
|
||||
// Result is a JSON representation of the autocomplete response.
|
||||
var result = res === undefined ? undefined : JSON.parse(res);
|
||||
callback(err, result);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to evaluate an expression remotely, and callback with
|
||||
* the result. The expression can be a promise, in which case, the method
|
||||
* will wait for the result and callback with the resolved value.
|
||||
*
|
||||
* @private
|
||||
* @param {string} expression Expression to evaluate
|
||||
* @param {function} callback
|
||||
*/
|
||||
CommandRepl.prototype.evaluate_ = function(expression, callback) {
|
||||
var self = this;
|
||||
var onbreak_ = function() {
|
||||
self.client.req({
|
||||
command: 'evaluate',
|
||||
arguments: {
|
||||
frame: 0,
|
||||
maxStringLength: 1000,
|
||||
expression: 'browser.debugHelper.dbgCodeExecutor.resultReady()'
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
throw new Error('Error while checking if debugger expression result was ready.' +
|
||||
'Expression: ' + expression + ' Error: ' + err);
|
||||
}
|
||||
// If code finished executing, get result.
|
||||
if (res.value) {
|
||||
self.client.req({
|
||||
command: 'evaluate',
|
||||
arguments: {
|
||||
frame: 0,
|
||||
maxStringLength: -1,
|
||||
expression: 'browser.debugHelper.dbgCodeExecutor.getResult()'
|
||||
}
|
||||
}, function(err, res) {
|
||||
try {
|
||||
callback(err, res.value);
|
||||
} catch (e) {
|
||||
callback(e, undefined);
|
||||
}
|
||||
self.client.removeListener('break', onbreak_);
|
||||
});
|
||||
} else {
|
||||
// If we need more loops for the code to finish executing, continue
|
||||
// until the next execute step.
|
||||
self.client.reqContinue(function() {
|
||||
// Intentionally blank.
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.client.on('break', onbreak_);
|
||||
|
||||
this.client.req({
|
||||
command: 'evaluate',
|
||||
arguments: {
|
||||
frame: 0,
|
||||
maxStringLength: 1000,
|
||||
expression: expression
|
||||
}
|
||||
}, function() {
|
||||
self.client.reqContinue(function() {
|
||||
// Intentionally blank.
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = CommandRepl;
|
143
node_modules/protractor/built/debugger/modes/debuggerRepl.js
generated
vendored
Normal file
143
node_modules/protractor/built/debugger/modes/debuggerRepl.js
generated
vendored
Normal file
|
@ -0,0 +1,143 @@
|
|||
var util = require('util');
|
||||
|
||||
var DBG_INITIAL_SUGGESTIONS =
|
||||
['repl', 'c', 'frame', 'scopes', 'scripts', 'source', 'backtrace'];
|
||||
|
||||
/**
|
||||
* Repl to step through webdriver test code.
|
||||
*
|
||||
* @param {Client} node debugger client.
|
||||
* @constructor
|
||||
*/
|
||||
var DebuggerRepl = function(client) {
|
||||
this.client = client;
|
||||
this.prompt = '>>> ';
|
||||
};
|
||||
|
||||
/**
|
||||
* Eval function for processing a single step in repl.
|
||||
* Call callback with the result when complete.
|
||||
*
|
||||
* @public
|
||||
* @param {string} cmd
|
||||
* @param {function} callback
|
||||
*/
|
||||
DebuggerRepl.prototype.stepEval = function(cmd, callback) {
|
||||
switch (cmd) {
|
||||
case 'c':
|
||||
this.printNextStep_(callback);
|
||||
this.client.reqContinue(function() {
|
||||
// Intentionally blank.
|
||||
});
|
||||
break;
|
||||
case 'repl':
|
||||
console.log('Error: using repl from browser.pause() has been removed. ' +
|
||||
'Please use browser.enterRepl instead.');
|
||||
callback();
|
||||
break;
|
||||
case 'schedule':
|
||||
this.printControlFlow_(callback);
|
||||
break;
|
||||
case 'frame':
|
||||
this.client.req({command: 'frame'}, function(err, res) {
|
||||
console.log(util.inspect(res, {colors: true}));
|
||||
callback();
|
||||
});
|
||||
break;
|
||||
case 'scopes':
|
||||
this.client.req({command: 'scopes'}, function(err, res) {
|
||||
console.log(util.inspect(res, {depth: 4, colors: true}));
|
||||
callback();
|
||||
});
|
||||
break;
|
||||
case 'scripts':
|
||||
this.client.req({command: 'scripts'}, function(err, res) {
|
||||
console.log(util.inspect(res, {depth: 4, colors: true}));
|
||||
callback();
|
||||
});
|
||||
break;
|
||||
case 'source':
|
||||
this.client.req({command: 'source'}, function(err, res) {
|
||||
console.log(util.inspect(res, {depth: 4, colors: true}));
|
||||
callback();
|
||||
});
|
||||
break;
|
||||
case 'backtrace':
|
||||
this.client.req({command: 'backtrace'}, function(err, res) {
|
||||
console.log(util.inspect(res, {depth: 4, colors: true}));
|
||||
callback();
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.log('Unrecognized command.');
|
||||
callback();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Autocomplete user entries.
|
||||
* Call callback with the suggestions.
|
||||
*
|
||||
* @public
|
||||
* @param {string} line Initial user entry
|
||||
* @param {function} callback
|
||||
*/
|
||||
DebuggerRepl.prototype.complete = function(line, callback) {
|
||||
var suggestions = DBG_INITIAL_SUGGESTIONS.filter(function(suggestion) {
|
||||
return suggestion.indexOf(line) === 0;
|
||||
});
|
||||
console.log('suggestions');
|
||||
callback(null, [suggestions, line]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Print the next command and setup the next breakpoint.
|
||||
*
|
||||
* @private
|
||||
* @param {function} callback
|
||||
*/
|
||||
DebuggerRepl.prototype.printNextStep_ = function(callback) {
|
||||
var self = this;
|
||||
var onBreak_ = function() {
|
||||
self.client.req({
|
||||
command: 'evaluate',
|
||||
arguments: {
|
||||
frame: 0,
|
||||
maxStringLength: 1000,
|
||||
expression: 'command.getName()'
|
||||
}
|
||||
}, function(err, res) {
|
||||
// We ignore errors here because we'll get one from the initial break.
|
||||
if (res.value) {
|
||||
console.log('-- Next command: ' + res.value);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
};
|
||||
this.client.once('break', onBreak_);
|
||||
};
|
||||
|
||||
/**
|
||||
* Print the controlflow.
|
||||
*
|
||||
* @private
|
||||
* @param {function} callback
|
||||
*/
|
||||
DebuggerRepl.prototype.printControlFlow_ = function(callback) {
|
||||
this.client.req({
|
||||
command: 'evaluate',
|
||||
arguments: {
|
||||
frame: 0,
|
||||
maxStringLength: 4000,
|
||||
expression: 'protractor.promise.controlFlow().getSchedule()'
|
||||
}
|
||||
}, function(err, controlFlowResponse) {
|
||||
if (controlFlowResponse.value) {
|
||||
console.log(controlFlowResponse.value);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = DebuggerRepl;
|
Loading…
Add table
Add a link
Reference in a new issue