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) {
}
function fetchUA(request) {
testUA(request.headers.filter(function(header) {
var headers = request.headers.filter(function(header) {
return header.name === "User-Agent";
}).pop().value, /plop/);
});
casper.test.assert(headers.length > 0);
testUA(headers.pop().value, /plop/);
}
casper.test.begin('userAgent() tests', 2, function(test) {
casper.test.begin('userAgent() tests', 3, function(test) {
testUA(casper.options.pageSettings.userAgent, /CasperJS/);
casper.start();
casper.userAgent('plop').once('resource.requested', fetchUA);
......