Deployed the page to Github Pages.

This commit is contained in:
Batuhan Berk Başoğlu 2024-11-03 21:30:09 -05:00
parent 1d79754e93
commit 2c89899458
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
62797 changed files with 6551425 additions and 15279 deletions

View 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;

View 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;