Skip to content

Commit

Permalink
requestsMonitor: pass "recv" and "send" events to npm layer
Browse files Browse the repository at this point in the history
Resolves #559
  • Loading branch information
macbre committed Oct 2, 2015
1 parent 61a66b4 commit 090646e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/modules/requestsMonitor/requestsMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ exports.module = function(phantomas) {

phantomas.log('req: <%s>', entry.url);

phantomas.emitInternal('send', entry, res); // @desc request has been sent
phantomas.emit('send', entry, res); // @desc request has been sent
});

phantomas.on('onResourceReceived', function(res) {
Expand Down Expand Up @@ -320,11 +320,11 @@ exports.module = function(phantomas) {
}

if (entry.isBase64) {
phantomas.emitInternal('base64recv', entry, res); // @desc base64-encoded "response" has been received
phantomas.emit('base64recv', entry, res); // @desc base64-encoded "response" has been received
}
else {
phantomas.log('recv: HTTP %d <%s> [%s]', entry.status, entry.url, entry.contentType);
phantomas.emitInternal('recv' , entry, res); // @desc response has been received
phantomas.emit('recv' , entry, res); // @desc response has been received
}
break;
}
Expand Down
7 changes: 6 additions & 1 deletion examples/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ console.log('phantomas v%s loaded from %s', phantomas.version, phantomas.path);

run = phantomas('http://google.is', {
'analyze-css': true,
'assert-requests': 1
'assert-requests': 1,
engine: 'webkit2'
});

console.log('Running phantomas: pid %d', run.pid);
Expand Down Expand Up @@ -39,6 +40,10 @@ run.on('milestone', function(milestone) {
console.log('Milestone reached: %s', milestone);
});

run.on('recv', function(response) {
console.log('Response #%d: %s %s [HTTP %d]', response.id, response.method, response.url, response.status);
});

// including the custom once emitted by phantomas modules
run.on('domQuery', function(type, query) {
console.log('DOM query by %s - "%s"', type, query);
Expand Down

0 comments on commit 090646e

Please sign in to comment.