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

Commit

Permalink
fix(debugger): fix 'getControlFlowText()' broken in webdriver 2.45
Browse files Browse the repository at this point in the history
  • Loading branch information
hankduan committed Apr 14, 2015
1 parent e6e668c commit fa699b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 35 deletions.
2 changes: 1 addition & 1 deletion lib/debugger/modes/debuggerRepl.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ DebuggerRepl.prototype.printControlFlow_ = function(callback) {
command: 'evaluate',
arguments: {
frame: 0,
maxStringLength: 2000,
maxStringLength: 4000,
expression: 'protractor.promise.controlFlow().getControlFlowText()'
}
}, function(err, controlFlowResponse) {
Expand Down
44 changes: 10 additions & 34 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,40 +625,16 @@ Protractor.prototype.initDebugger_ = function(debuggerClientPath, opt_debugPort)
// Patch in a function to help us visualize what's going on in the control
// flow.
webdriver.promise.ControlFlow.prototype.getControlFlowText = function() {
var descriptions = [];

var getDescriptions = function(frameOrTask, descriptions) {
if (frameOrTask.getDescription) {
var stacktrace = frameOrTask.snapshot_.getStacktrace();
stacktrace = stacktrace ? stacktrace.join('\n').trim() : '';
descriptions.push({
description: frameOrTask.getDescription(),
stack: helper.filterStackTrace(stacktrace)
});
} else {
for (var i = 0; i < frameOrTask.children_.length; ++i) {
getDescriptions(frameOrTask.children_[i], descriptions);
}
}
};
if (this.history_.length) {
getDescriptions(this.history_[this.history_.length - 1], descriptions);
}
if (this.activeFrame_.getPendingTask()) {
getDescriptions(this.activeFrame_.getPendingTask(), descriptions);
}
getDescriptions(this.activeFrame_.getRoot(), descriptions);
var asString = '-- WebDriver control flow schedule \n';
for (var i = 0; i < descriptions.length; ++i) {
asString += ' |- ' + descriptions[i].description;
if (descriptions[i].stack) {
asString += '\n |---' + descriptions[i].stack.replace(/\n/g, '\n |---');
}
if (i != (descriptions.length - 1)) {
asString += '\n';
}
}
return asString;
var controlFlowText = this.getSchedule(/* opt_includeStackTraces */ true);
// This filters the entire control flow text, not just the stack trace, so
// unless we maintain a good (i.e. non-generic) set of keywords in
// STACK_SUBSTRINGS_TO_FILTER, we run the risk of filtering out non stack
// trace. The alternative though, which is to reimplement
// webdriver.promise.ControlFlow.prototype.getSchedule() here is much
// hackier, and involves messing with the control flow's internals / private
// variables.
return helper.filterStackTrace(controlFlowText);

};

if (opt_debugPort) {
Expand Down

0 comments on commit fa699b8

Please sign in to comment.