Commit ccf9afaa ccf9afaad969a6aa9b039f278df66a4d367e89e9 by Nicolas Perriault

better handling of clientscripts injection

1 parent 1cf3d9bc
...@@ -1407,17 +1407,19 @@ function createPage(casper) { ...@@ -1407,17 +1407,19 @@ 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 {
1413 casper.options.clientScripts.forEach(function _forEach(script) {
1414 if (casper.page.injectJs(script)) {
1415 casper.log(f('Automatically injected %s client side', script), "debug");
1416 } else {
1417 casper.log(f('Failed injecting %s client side', script), "warning");
1418 }
1419 });
1420 } 1415 }
1416 casper.options.clientScripts.forEach(function _forEach(script) {
1417 if (casper.page.injectJs(script)) {
1418 casper.log(f('Automatically injected %s client side', script), "debug");
1419 } else {
1420 casper.warn('Failed injecting %s client side', script);
1421 }
1422 });
1421 } 1423 }
1422 // Client-side utils injection 1424 // Client-side utils injection
1423 casper.injectClientUtils(); 1425 casper.injectClientUtils();
......