refs #408 - added support for PhantomJS onCallback (window.callPhantom)
Showing
3 changed files
with
40 additions
and
0 deletions
... | @@ -2094,6 +2094,11 @@ function createPage(casper) { | ... | @@ -2094,6 +2094,11 @@ function createPage(casper) { |
2094 | casper.log(msg, logLevel, "remote"); | 2094 | casper.log(msg, logLevel, "remote"); |
2095 | casper.emit('remote.message', msg); | 2095 | casper.emit('remote.message', msg); |
2096 | }; | 2096 | }; |
2097 | |||
2098 | page.onCallback = function onCallback(data){ | ||
2099 | casper.emit('remote.callback',data); | ||
2100 | }; | ||
2101 | |||
2097 | page.onError = function onError(msg, trace) { | 2102 | page.onError = function onError(msg, trace) { |
2098 | casper.emit('page.error', msg, trace); | 2103 | casper.emit('page.error', msg, trace); |
2099 | }; | 2104 | }; | ... | ... |
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