fixed ua tests were triggering unneeded events
Showing
1 changed file
with
13 additions
and
4 deletions
... | @@ -4,12 +4,21 @@ function testUA(ua, match) { | ... | @@ -4,12 +4,21 @@ function testUA(ua, match) { |
4 | ); | 4 | ); |
5 | } | 5 | } |
6 | 6 | ||
7 | testUA(casper.options.pageSettings.userAgent, /CasperJS/); | 7 | function fetchUA(request) { |
8 | |||
9 | casper.start().userAgent('plop').on('resource.requested', function(request) { | ||
10 | testUA(request.headers.filter(function(header) { | 8 | testUA(request.headers.filter(function(header) { |
11 | return header.name === "User-Agent"; | 9 | return header.name === "User-Agent"; |
12 | }).pop().value, /plop/); | 10 | }).pop().value, /plop/); |
13 | }).start('tests/site/index.html').run(function() { | 11 | } |
12 | |||
13 | testUA(casper.options.pageSettings.userAgent, /CasperJS/); | ||
14 | |||
15 | casper.start(); | ||
16 | |||
17 | casper.userAgent('plop').on('resource.requested', fetchUA); | ||
18 | |||
19 | casper.thenOpen('tests/site/index.html'); | ||
20 | |||
21 | casper.run(function() { | ||
22 | this.removeListener('resource.requested', fetchUA); | ||
14 | this.test.done(); | 23 | this.test.done(); |
15 | }); | 24 | }); | ... | ... |
-
Please register or sign in to post a comment