[go: nahoru, domu]

Skip to content

Commit

Permalink
Allow the use of the PhantomJS remote debugger
Browse files Browse the repository at this point in the history
This commit adds the '--debugger <port>' option, which triggers
the PhantomJS remote debugger.  The initial output of the terminal
when running the debugger gives more information on how to use
it.
  • Loading branch information
DirectXMan12 committed Aug 6, 2015
1 parent 9ff86fb commit 07f514d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion tests/run_from_console.casper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ var casper_opts = {
}
};

var provide_emitter = function(file_paths) {
var provide_emitter = function(file_paths, debug_port) {
if (debug_port) {
casper_opts.child['remote-debugger-port'] = debug_port;
var debug_url = ('https://localhost:' + debug_port +
'/webkit/inspector/inspector.html?page=');
console.info('[remote-debugger] Navigate to ' + debug_url + '1 and ' +
'run `__run();` in the console to continue loading.' +
'\n[remote-debugger] Navigate to ' + debug_url + '2 to ' +
'view the actual page source.\n' +
'[remote-debugger] Use the `debugger;` statement to ' +
'trigger an initial breakpoint.');
}

var spooky = new Spooky(casper_opts, function(err) {
if (err) {
if (err.stack) console.warn(err.stack);
Expand Down
3 changes: 2 additions & 1 deletion tests/run_from_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ program
.option('--output-html', 'Instead of running the tests, just output the generated HTML source to STDOUT (should be used with .js tests)')
.option('-d, --debug', 'Show debug output (the "console" event) from the provider')
.option('-r, --relative', 'Use relative paths in the generated HTML file')
.option('--debugger <port>', 'Enable the remote debugger for CasperJS')
.parse(process.argv);

if (program.tests.length === 0) {
Expand Down Expand Up @@ -202,7 +203,7 @@ if (!program.outputHtml && !program.generateHtml) {
.write("\n");
//console.log("Running tests %s using provider %s", program.tests.join(', '), prov.name);

var provider = prov.provide_emitter(file_paths);
var provider = prov.provide_emitter(file_paths, program.debugger);
provider.on('test_ready', function(test_json) {
console.log('');

Expand Down

0 comments on commit 07f514d

Please sign in to comment.