Merge pull request #409 from nabriski/callback
refs #408 - added support for PhantomJS onCallback (window.callPhantom)
Showing
3 changed files
with
40 additions
and
0 deletions
... | @@ -2180,6 +2180,11 @@ function createPage(casper) { | ... | @@ -2180,6 +2180,11 @@ function createPage(casper) { |
2180 | casper.log(msg, logLevel, "remote"); | 2180 | casper.log(msg, logLevel, "remote"); |
2181 | casper.emit('remote.message', msg); | 2181 | casper.emit('remote.message', msg); |
2182 | }; | 2182 | }; |
2183 | |||
2184 | page.onCallback = function onCallback(data){ | ||
2185 | casper.emit('remote.callback',data); | ||
2186 | }; | ||
2187 | |||
2183 | page.onError = function onError(msg, trace) { | 2188 | page.onError = function onError(msg, trace) { |
2184 | casper.emit('page.error', msg, trace); | 2189 | casper.emit('page.error', msg, trace); |
2185 | }; | 2190 | }; | ... | ... |
tests/site/callback.html
0 → 100644
tests/suites/casper/callback.js
0 → 100644
1 | /*global casper*/ | ||
2 | /*jshint strict:false*/ | ||
3 | casper.test.begin('callback events', 1, { | ||
4 | ok: false, | ||
5 | |||
6 | tearDown: function(test) { | ||
7 | casper.removeAllListeners('remote.callback'); | ||
8 | }, | ||
9 | |||
10 | test: function(test) { | ||
11 | var self = this; | ||
12 | |||
13 | casper.once('remote.callback', function(data) { | ||
14 | self.ok = (data.hello === 'world'); | ||
15 | }); | ||
16 | |||
17 | casper.start('tests/site/callback.html', function() { | ||
18 | test.assert(self.ok, 'callback event has been intercepted'); | ||
19 | }); | ||
20 | |||
21 | casper.run(function() { | ||
22 | test.done(); | ||
23 | }); | ||
24 | } | ||
25 | }); |
-
Please register or sign in to post a comment