Commit 619a6203 619a62039b35011726d7942a5ab791448e472409 by Nicolas Perriault

Merge pull request #388 from p/agent-test

Check that user-agent header exists before retrieving it
2 parents 8772328e bf7e9837
...@@ -7,12 +7,14 @@ function testUA(ua, match) { ...@@ -7,12 +7,14 @@ function testUA(ua, match) {
7 } 7 }
8 8
9 function fetchUA(request) { 9 function fetchUA(request) {
10 testUA(request.headers.filter(function(header) { 10 var headers = request.headers.filter(function(header) {
11 return header.name === "User-Agent"; 11 return header.name === "User-Agent";
12 }).pop().value, /plop/); 12 });
13 casper.test.assert(headers.length > 0);
14 testUA(headers.pop().value, /plop/);
13 } 15 }
14 16
15 casper.test.begin('userAgent() tests', 2, function(test) { 17 casper.test.begin('userAgent() tests', 3, function(test) {
16 testUA(casper.options.pageSettings.userAgent, /CasperJS/); 18 testUA(casper.options.pageSettings.userAgent, /CasperJS/);
17 casper.start(); 19 casper.start();
18 casper.userAgent('plop').once('resource.requested', fetchUA); 20 casper.userAgent('plop').once('resource.requested', fetchUA);
......