better handling of clientscripts injection
Showing
1 changed file
with
5 additions
and
3 deletions
... | @@ -1407,18 +1407,20 @@ function createPage(casper) { | ... | @@ -1407,18 +1407,20 @@ function createPage(casper) { |
1407 | } | 1407 | } |
1408 | } | 1408 | } |
1409 | if (casper.options.clientScripts) { | 1409 | if (casper.options.clientScripts) { |
1410 | if (utils.isString(casper.options.clientScripts)) { | ||
1411 | casper.options.clientScripts = [casper.options.clientScripts]; | ||
1412 | } | ||
1410 | if (!utils.isArray(casper.options.clientScripts)) { | 1413 | if (!utils.isArray(casper.options.clientScripts)) { |
1411 | throw new CasperError("The clientScripts option must be an array"); | 1414 | throw new CasperError("The clientScripts option must be an array"); |
1412 | } else { | 1415 | } |
1413 | casper.options.clientScripts.forEach(function _forEach(script) { | 1416 | casper.options.clientScripts.forEach(function _forEach(script) { |
1414 | if (casper.page.injectJs(script)) { | 1417 | if (casper.page.injectJs(script)) { |
1415 | casper.log(f('Automatically injected %s client side', script), "debug"); | 1418 | casper.log(f('Automatically injected %s client side', script), "debug"); |
1416 | } else { | 1419 | } else { |
1417 | casper.log(f('Failed injecting %s client side', script), "warning"); | 1420 | casper.warn('Failed injecting %s client side', script); |
1418 | } | 1421 | } |
1419 | }); | 1422 | }); |
1420 | } | 1423 | } |
1421 | } | ||
1422 | // Client-side utils injection | 1424 | // Client-side utils injection |
1423 | casper.injectClientUtils(); | 1425 | casper.injectClientUtils(); |
1424 | // history | 1426 | // history | ... | ... |
-
Please register or sign in to post a comment