Commit db27f288 db27f28865bffe846835bcd75626728f8ba5538c by Nicolas Perriault

fixed ua tests were triggering unneeded events

1 parent 02d6f057
...@@ -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 });
......