Merge pull request #388 from p/agent-test
Check that user-agent header exists before retrieving it
Showing
1 changed file
with
5 additions
and
3 deletions
... | @@ -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); | ... | ... |
-
Please register or sign in to post a comment