closes #97 - De-anonymize all functions
Showing
9 changed files
with
60 additions
and
60 deletions
This diff is collapsed.
Click to expand it.
... | @@ -37,24 +37,24 @@ var utils = require('utils'); | ... | @@ -37,24 +37,24 @@ var utils = require('utils'); |
37 | * @param array phantomArgs phantom.args value | 37 | * @param array phantomArgs phantom.args value |
38 | * @return Object | 38 | * @return Object |
39 | */ | 39 | */ |
40 | exports.parse = function(phantomArgs) { | 40 | exports.parse = function parse(phantomArgs) { |
41 | var extract = { | 41 | var extract = { |
42 | args: [], | 42 | args: [], |
43 | options: {}, | 43 | options: {}, |
44 | drop: function(what) { | 44 | drop: function drop(what) { |
45 | if (utils.isNumber(what)) { | 45 | if (utils.isNumber(what)) { |
46 | // deleting an arg by its position | 46 | // deleting an arg by its position |
47 | this.args = this.args.filter(function(arg, index) { | 47 | this.args = this.args.filter(function _filter(arg, index) { |
48 | return index !== what; | 48 | return index !== what; |
49 | }); | 49 | }); |
50 | } else if (utils.isString(what)) { | 50 | } else if (utils.isString(what)) { |
51 | // deleting an arg by its value | 51 | // deleting an arg by its value |
52 | this.args = this.args.filter(function(arg) { | 52 | this.args = this.args.filter(function _filter(arg) { |
53 | return arg !== what; | 53 | return arg !== what; |
54 | }); | 54 | }); |
55 | // deleting an option by its name (key) | 55 | // deleting an option by its name (key) |
56 | var self = this; | 56 | var self = this; |
57 | Object.keys(this.options).forEach(function(option) { | 57 | Object.keys(this.options).forEach(function _forEach(option) { |
58 | if (option === what) { | 58 | if (option === what) { |
59 | delete self.options[what]; | 59 | delete self.options[what]; |
60 | } | 60 | } |
... | @@ -63,7 +63,7 @@ exports.parse = function(phantomArgs) { | ... | @@ -63,7 +63,7 @@ exports.parse = function(phantomArgs) { |
63 | throw new CasperError("cannot drop argument of type " + typeof what); | 63 | throw new CasperError("cannot drop argument of type " + typeof what); |
64 | } | 64 | } |
65 | }, | 65 | }, |
66 | has: function(what) { | 66 | has: function has(what) { |
67 | if (utils.isNumber(what)) { | 67 | if (utils.isNumber(what)) { |
68 | return what in this.args; | 68 | return what in this.args; |
69 | } else if (utils.isString(what)) { | 69 | } else if (utils.isString(what)) { |
... | @@ -72,7 +72,7 @@ exports.parse = function(phantomArgs) { | ... | @@ -72,7 +72,7 @@ exports.parse = function(phantomArgs) { |
72 | throw new CasperError("Unsupported cli arg tester " + typeof what); | 72 | throw new CasperError("Unsupported cli arg tester " + typeof what); |
73 | } | 73 | } |
74 | }, | 74 | }, |
75 | get: function(what) { | 75 | get: function get(what) { |
76 | if (utils.isNumber(what)) { | 76 | if (utils.isNumber(what)) { |
77 | return this.args[what]; | 77 | return this.args[what]; |
78 | } else if (utils.isString(what)) { | 78 | } else if (utils.isString(what)) { |
... | @@ -82,7 +82,7 @@ exports.parse = function(phantomArgs) { | ... | @@ -82,7 +82,7 @@ exports.parse = function(phantomArgs) { |
82 | } | 82 | } |
83 | } | 83 | } |
84 | }; | 84 | }; |
85 | phantomArgs.forEach(function(arg) { | 85 | phantomArgs.forEach(function _forEach(arg) { |
86 | if (arg.indexOf('--') === 0) { | 86 | if (arg.indexOf('--') === 0) { |
87 | // named option | 87 | // named option |
88 | var optionMatch = arg.match(/^--(.*)=(.*)/i); | 88 | var optionMatch = arg.match(/^--(.*)=(.*)/i); | ... | ... |
... | @@ -28,14 +28,14 @@ | ... | @@ -28,14 +28,14 @@ |
28 | * | 28 | * |
29 | */ | 29 | */ |
30 | (function(exports) { | 30 | (function(exports) { |
31 | exports.create = function() { | 31 | exports.create = function create() { |
32 | return new ClientUtils(); | 32 | return new ClientUtils(); |
33 | }; | 33 | }; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Casper client-side helpers. | 36 | * Casper client-side helpers. |
37 | */ | 37 | */ |
38 | ClientUtils = function() { | 38 | ClientUtils = function ClientUtils() { |
39 | var BASE64_ENCODE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | 39 | var BASE64_ENCODE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
40 | var BASE64_DECODE_CHARS = new Array( | 40 | var BASE64_DECODE_CHARS = new Array( |
41 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, | 41 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
... | @@ -54,7 +54,7 @@ | ... | @@ -54,7 +54,7 @@ |
54 | * @param String selector A CSS3 selector to the element to click | 54 | * @param String selector A CSS3 selector to the element to click |
55 | * @return Boolean | 55 | * @return Boolean |
56 | */ | 56 | */ |
57 | this.click = function(selector) { | 57 | this.click = function click(selector) { |
58 | var elem = this.findOne(selector); | 58 | var elem = this.findOne(selector); |
59 | if (!elem) { | 59 | if (!elem) { |
60 | this.log("click(): Couldn't find any element matching '" + selector + "' selector", "error"); | 60 | this.log("click(): Couldn't find any element matching '" + selector + "' selector", "error"); |
... | @@ -73,7 +73,7 @@ | ... | @@ -73,7 +73,7 @@ |
73 | * @param String str The base64 encoded contents | 73 | * @param String str The base64 encoded contents |
74 | * @return string | 74 | * @return string |
75 | */ | 75 | */ |
76 | this.decode = function(str) { | 76 | this.decode = function decode(str) { |
77 | var c1, c2, c3, c4, i = 0, len = str.length, out = ""; | 77 | var c1, c2, c3, c4, i = 0, len = str.length, out = ""; |
78 | while (i < len) { | 78 | while (i < len) { |
79 | do { | 79 | do { |
... | @@ -121,7 +121,7 @@ | ... | @@ -121,7 +121,7 @@ |
121 | * @param String str The string content to encode | 121 | * @param String str The string content to encode |
122 | * @return string | 122 | * @return string |
123 | */ | 123 | */ |
124 | this.encode = function(str) { | 124 | this.encode = function encode(str) { |
125 | var out = "", i = 0, len = str.length, c1, c2, c3; | 125 | var out = "", i = 0, len = str.length, c1, c2, c3; |
126 | while (i < len) { | 126 | while (i < len) { |
127 | c1 = str.charCodeAt(i++) & 0xff; | 127 | c1 = str.charCodeAt(i++) & 0xff; |
... | @@ -154,7 +154,7 @@ | ... | @@ -154,7 +154,7 @@ |
154 | * @param String selector CSS3 selector | 154 | * @param String selector CSS3 selector |
155 | * @return Boolean | 155 | * @return Boolean |
156 | */ | 156 | */ |
157 | this.exists = function(selector) { | 157 | this.exists = function exists(selector) { |
158 | try { | 158 | try { |
159 | return document.querySelectorAll(selector).length > 0; | 159 | return document.querySelectorAll(selector).length > 0; |
160 | } catch (e) { | 160 | } catch (e) { |
... | @@ -169,10 +169,10 @@ | ... | @@ -169,10 +169,10 @@ |
169 | * @param String selector A CSS3 selector | 169 | * @param String selector A CSS3 selector |
170 | * @return String | 170 | * @return String |
171 | */ | 171 | */ |
172 | this.fetchText = function(selector) { | 172 | this.fetchText = function fetchText(selector) { |
173 | var text = '', elements = this.findAll(selector); | 173 | var text = '', elements = this.findAll(selector); |
174 | if (elements && elements.length) { | 174 | if (elements && elements.length) { |
175 | Array.prototype.forEach.call(elements, function(element) { | 175 | Array.prototype.forEach.call(elements, function _forEach(element) { |
176 | text += element.innerText; | 176 | text += element.innerText; |
177 | }); | 177 | }); |
178 | } | 178 | } |
... | @@ -186,7 +186,7 @@ | ... | @@ -186,7 +186,7 @@ |
186 | * @param Object vals Field values | 186 | * @param Object vals Field values |
187 | * @return Object An object containing setting result for each field, including file uploads | 187 | * @return Object An object containing setting result for each field, including file uploads |
188 | */ | 188 | */ |
189 | this.fill = function(form, vals) { | 189 | this.fill = function fill(form, vals) { |
190 | var out = { | 190 | var out = { |
191 | errors: [], | 191 | errors: [], |
192 | fields: [], | 192 | fields: [], |
... | @@ -240,7 +240,7 @@ | ... | @@ -240,7 +240,7 @@ |
240 | * @param String selector CSS3 selector | 240 | * @param String selector CSS3 selector |
241 | * @return NodeList|undefined | 241 | * @return NodeList|undefined |
242 | */ | 242 | */ |
243 | this.findAll = function(selector) { | 243 | this.findAll = function findAll(selector) { |
244 | try { | 244 | try { |
245 | return document.querySelectorAll(selector); | 245 | return document.querySelectorAll(selector); |
246 | } catch (e) { | 246 | } catch (e) { |
... | @@ -254,7 +254,7 @@ | ... | @@ -254,7 +254,7 @@ |
254 | * @param String selector CSS3 selector | 254 | * @param String selector CSS3 selector |
255 | * @return HTMLElement|undefined | 255 | * @return HTMLElement|undefined |
256 | */ | 256 | */ |
257 | this.findOne = function(selector) { | 257 | this.findOne = function findOne(selector) { |
258 | try { | 258 | try { |
259 | return document.querySelector(selector); | 259 | return document.querySelector(selector); |
260 | } catch (e) { | 260 | } catch (e) { |
... | @@ -271,7 +271,7 @@ | ... | @@ -271,7 +271,7 @@ |
271 | * @param Object data The request data, optional | 271 | * @param Object data The request data, optional |
272 | * @return String Base64 contents string | 272 | * @return String Base64 contents string |
273 | */ | 273 | */ |
274 | this.getBase64 = function(url, method, data) { | 274 | this.getBase64 = function getBase64(url, method, data) { |
275 | return this.encode(this.getBinary(url, method, data)); | 275 | return this.encode(this.getBinary(url, method, data)); |
276 | }; | 276 | }; |
277 | 277 | ||
... | @@ -284,7 +284,7 @@ | ... | @@ -284,7 +284,7 @@ |
284 | * @param Object data | 284 | * @param Object data |
285 | * @return string | 285 | * @return string |
286 | */ | 286 | */ |
287 | this.getBinary = function(url, method, data) { | 287 | this.getBinary = function getBinary(url, method, data) { |
288 | try { | 288 | try { |
289 | var xhr = new XMLHttpRequest(), dataString = ""; | 289 | var xhr = new XMLHttpRequest(), dataString = ""; |
290 | if (typeof method !== "string" || ["GET", "POST"].indexOf(method.toUpperCase()) === -1) { | 290 | if (typeof method !== "string" || ["GET", "POST"].indexOf(method.toUpperCase()) === -1) { |
... | @@ -326,7 +326,7 @@ | ... | @@ -326,7 +326,7 @@ |
326 | * @param String selector | 326 | * @param String selector |
327 | * @return Object or null | 327 | * @return Object or null |
328 | */ | 328 | */ |
329 | this.getElementBounds = function(selector) { | 329 | this.getElementBounds = function getElementBounds(selector) { |
330 | try { | 330 | try { |
331 | var clipRect = document.querySelector(selector).getBoundingClientRect(); | 331 | var clipRect = document.querySelector(selector).getBoundingClientRect(); |
332 | return { | 332 | return { |
... | @@ -347,7 +347,7 @@ | ... | @@ -347,7 +347,7 @@ |
347 | * @param String message The message to log | 347 | * @param String message The message to log |
348 | * @param String level The log level | 348 | * @param String level The log level |
349 | */ | 349 | */ |
350 | this.log = function(message, level) { | 350 | this.log = function log(message, level) { |
351 | console.log("[casper:" + (level || "debug") + "] " + message); | 351 | console.log("[casper:" + (level || "debug") + "] " + message); |
352 | }; | 352 | }; |
353 | 353 | ||
... | @@ -358,7 +358,7 @@ | ... | @@ -358,7 +358,7 @@ |
358 | * @param HTMLElement|NodeList field One or more element defining a field | 358 | * @param HTMLElement|NodeList field One or more element defining a field |
359 | * @param mixed value The field value to set | 359 | * @param mixed value The field value to set |
360 | */ | 360 | */ |
361 | this.setField = function(field, value) { | 361 | this.setField = function setField(field, value) { |
362 | var fields, out; | 362 | var fields, out; |
363 | value = value || ""; | 363 | value = value || ""; |
364 | if (field instanceof NodeList) { | 364 | if (field instanceof NodeList) { |
... | @@ -403,7 +403,7 @@ | ... | @@ -403,7 +403,7 @@ |
403 | if (!Array.isArray(values)) { | 403 | if (!Array.isArray(values)) { |
404 | values = [values]; | 404 | values = [values]; |
405 | } | 405 | } |
406 | Array.prototype.forEach.call(fields, function(f) { | 406 | Array.prototype.forEach.call(fields, function _forEach(f) { |
407 | f.checked = values.indexOf(f.value) !== -1 ? true : false; | 407 | f.checked = values.indexOf(f.value) !== -1 ? true : false; |
408 | }); | 408 | }); |
409 | } else { | 409 | } else { |
... | @@ -418,7 +418,7 @@ | ... | @@ -418,7 +418,7 @@ |
418 | }; | 418 | }; |
419 | case "radio": | 419 | case "radio": |
420 | if (fields) { | 420 | if (fields) { |
421 | Array.prototype.forEach.call(fields, function(e) { | 421 | Array.prototype.forEach.call(fields, function _forEach(e) { |
422 | e.checked = (e.value === value); | 422 | e.checked = (e.value === value); |
423 | }); | 423 | }); |
424 | } else { | 424 | } else { |
... | @@ -452,7 +452,7 @@ | ... | @@ -452,7 +452,7 @@ |
452 | * @param String selector CSS3 selector | 452 | * @param String selector CSS3 selector |
453 | * @return Boolean | 453 | * @return Boolean |
454 | */ | 454 | */ |
455 | this.visible = function(selector) { | 455 | this.visible = function visible(selector) { |
456 | try { | 456 | try { |
457 | var el = document.querySelector(selector); | 457 | var el = document.querySelector(selector); |
458 | return el && el.style.visibility !== 'hidden' && el.offsetHeight > 0 && el.offsetWidth > 0; | 458 | return el && el.style.visibility !== 'hidden' && el.offsetHeight > 0 && el.offsetWidth > 0; | ... | ... |
... | @@ -41,7 +41,7 @@ exports.create = function create() { | ... | @@ -41,7 +41,7 @@ exports.create = function create() { |
41 | * | 41 | * |
42 | * (c) Fabien Potencier, Symfony project, MIT license | 42 | * (c) Fabien Potencier, Symfony project, MIT license |
43 | */ | 43 | */ |
44 | var Colorizer = function() { | 44 | var Colorizer = function Colorizer() { |
45 | var options = { bold: 1, underscore: 4, blink: 5, reverse: 7, conceal: 8 }; | 45 | var options = { bold: 1, underscore: 4, blink: 5, reverse: 7, conceal: 8 }; |
46 | var foreground = { black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37 }; | 46 | var foreground = { black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37 }; |
47 | var background = { black: 40, red: 41, green: 42, yellow: 43, blue: 44, magenta: 45, cyan: 46, white: 47 }; | 47 | var background = { black: 40, red: 41, green: 42, yellow: 43, blue: 44, magenta: 45, cyan: 46, white: 47 }; | ... | ... |
... | @@ -30,7 +30,7 @@ | ... | @@ -30,7 +30,7 @@ |
30 | 30 | ||
31 | var utils = require('utils'); | 31 | var utils = require('utils'); |
32 | 32 | ||
33 | exports.create = function(fn) { | 33 | exports.create = function create(fn) { |
34 | return new FunctionArgsInjector(fn); | 34 | return new FunctionArgsInjector(fn); |
35 | }; | 35 | }; |
36 | 36 | ||
... | @@ -39,18 +39,18 @@ exports.create = function(fn) { | ... | @@ -39,18 +39,18 @@ exports.create = function(fn) { |
39 | * | 39 | * |
40 | * FIXME: use new Function() instead of eval() | 40 | * FIXME: use new Function() instead of eval() |
41 | */ | 41 | */ |
42 | var FunctionArgsInjector = function(fn) { | 42 | var FunctionArgsInjector = function FunctionArgsInjector(fn) { |
43 | if (!utils.isFunction(fn)) { | 43 | if (!utils.isFunction(fn)) { |
44 | throw new CasperError("FunctionArgsInjector() can only process functions"); | 44 | throw new CasperError("FunctionArgsInjector() can only process functions"); |
45 | } | 45 | } |
46 | this.fn = fn; | 46 | this.fn = fn; |
47 | 47 | ||
48 | this.extract = function(fn) { | 48 | this.extract = function extract(fn) { |
49 | var match = /^function\s?(\w+)?\s?\((.*)\)\s?\{([\s\S]*)\}/i.exec(fn.toString().trim()); | 49 | var match = /^function\s?(\w+)?\s?\((.*)\)\s?\{([\s\S]*)\}/i.exec(fn.toString().trim()); |
50 | if (match && match.length > 1) { | 50 | if (match && match.length > 1) { |
51 | var args = match[2].split(',').map(function(arg) { | 51 | var args = match[2].split(',').map(function _map(arg) { |
52 | return arg.replace(new RegExp(/\/\*+.*\*\//ig), "").trim(); | 52 | return arg.replace(new RegExp(/\/\*+.*\*\//ig), "").trim(); |
53 | }).filter(function(arg) { | 53 | }).filter(function _filter(arg) { |
54 | return arg; | 54 | return arg; |
55 | }) || []; | 55 | }) || []; |
56 | return { | 56 | return { |
... | @@ -61,7 +61,7 @@ var FunctionArgsInjector = function(fn) { | ... | @@ -61,7 +61,7 @@ var FunctionArgsInjector = function(fn) { |
61 | } | 61 | } |
62 | }; | 62 | }; |
63 | 63 | ||
64 | this.process = function(values) { | 64 | this.process = function process(values) { |
65 | var fnObj = this.extract(this.fn); | 65 | var fnObj = this.extract(this.fn); |
66 | if (!utils.isObject(fnObj)) { | 66 | if (!utils.isObject(fnObj)) { |
67 | throw new CasperError("Unable to process function " + this.fn.toString()); | 67 | throw new CasperError("Unable to process function " + this.fn.toString()); |
... | @@ -70,13 +70,13 @@ var FunctionArgsInjector = function(fn) { | ... | @@ -70,13 +70,13 @@ var FunctionArgsInjector = function(fn) { |
70 | return 'function ' + (fnObj.name || '') + '(){' + inject + fnObj.body + '}'; | 70 | return 'function ' + (fnObj.name || '') + '(){' + inject + fnObj.body + '}'; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | this.getArgsInjectionString = function(args, values) { | 73 | this.getArgsInjectionString = function getArgsInjectionString(args, values) { |
74 | values = typeof values === "object" ? values : {}; | 74 | values = typeof values === "object" ? values : {}; |
75 | var jsonValues = escape(encodeURIComponent(JSON.stringify(values))); | 75 | var jsonValues = escape(encodeURIComponent(JSON.stringify(values))); |
76 | var inject = [ | 76 | var inject = [ |
77 | 'var __casper_params__ = JSON.parse(decodeURIComponent(unescape(\'' + jsonValues + '\')));' | 77 | 'var __casper_params__ = JSON.parse(decodeURIComponent(unescape(\'' + jsonValues + '\')));' |
78 | ]; | 78 | ]; |
79 | args.forEach(function(arg) { | 79 | args.forEach(function _forEach(arg) { |
80 | if (arg in values) { | 80 | if (arg in values) { |
81 | inject.push('var ' + arg + '=__casper_params__["' + arg + '"];'); | 81 | inject.push('var ' + arg + '=__casper_params__["' + arg + '"];'); |
82 | } | 82 | } | ... | ... |
... | @@ -30,11 +30,11 @@ | ... | @@ -30,11 +30,11 @@ |
30 | 30 | ||
31 | var utils = require('utils'); | 31 | var utils = require('utils'); |
32 | 32 | ||
33 | exports.create = function(casper) { | 33 | exports.create = function create(casper) { |
34 | return new Mouse(casper); | 34 | return new Mouse(casper); |
35 | }; | 35 | }; |
36 | 36 | ||
37 | var Mouse = function(casper) { | 37 | var Mouse = function Mouse(casper) { |
38 | if (!utils.isCasperObject(casper)) { | 38 | if (!utils.isCasperObject(casper)) { |
39 | throw new CasperError('Mouse() needs a Casper instance'); | 39 | throw new CasperError('Mouse() needs a Casper instance'); |
40 | } | 40 | } | ... | ... |
... | @@ -33,7 +33,7 @@ var events = require('events'); | ... | @@ -33,7 +33,7 @@ var events = require('events'); |
33 | var utils = require('utils'); | 33 | var utils = require('utils'); |
34 | var f = utils.format; | 34 | var f = utils.format; |
35 | 35 | ||
36 | exports.create = function(casper, options) { | 36 | exports.create = function create(casper, options) { |
37 | return new Tester(casper, options); | 37 | return new Tester(casper, options); |
38 | }; | 38 | }; |
39 | 39 | ||
... | @@ -41,7 +41,7 @@ exports.create = function(casper, options) { | ... | @@ -41,7 +41,7 @@ exports.create = function(casper, options) { |
41 | * Casper tester: makes assertions, stores test results and display then. | 41 | * Casper tester: makes assertions, stores test results and display then. |
42 | * | 42 | * |
43 | */ | 43 | */ |
44 | var Tester = function(casper, options) { | 44 | var Tester = function Tester(casper, options) { |
45 | if (!utils.isCasperObject(casper)) { | 45 | if (!utils.isCasperObject(casper)) { |
46 | throw new CasperError("Tester needs a Casper instance"); | 46 | throw new CasperError("Tester needs a Casper instance"); |
47 | } | 47 | } |
... | @@ -64,16 +64,16 @@ var Tester = function(casper, options) { | ... | @@ -64,16 +64,16 @@ var Tester = function(casper, options) { |
64 | }; | 64 | }; |
65 | 65 | ||
66 | // events | 66 | // events |
67 | casper.on('step.error', function(e) { | 67 | casper.on('step.error', function onStepError(e) { |
68 | casper.test.fail(e); | 68 | casper.test.fail(e); |
69 | casper.test.done(); | 69 | casper.test.done(); |
70 | }); | 70 | }); |
71 | 71 | ||
72 | this.on('success', function(success) { | 72 | this.on('success', function onSuccess(success) { |
73 | this.exporter.addSuccess(fs.absolute(success.file), success.message); | 73 | this.exporter.addSuccess(fs.absolute(success.file), success.message); |
74 | }); | 74 | }); |
75 | 75 | ||
76 | this.on('fail', function(failure) { | 76 | this.on('fail', function onFail(failure) { |
77 | this.exporter.addFailure(fs.absolute(failure.file), failure.message, failure.details || "test failed", failure.type || "unknown"); | 77 | this.exporter.addFailure(fs.absolute(failure.file), failure.message, failure.details || "test failed", failure.type || "unknown"); |
78 | this.testResults.failures.push(failure); | 78 | this.testResults.failures.push(failure); |
79 | }); | 79 | }); |
... | @@ -274,7 +274,7 @@ var Tester = function(casper, options) { | ... | @@ -274,7 +274,7 @@ var Tester = function(casper, options) { |
274 | * @param String message Test description | 274 | * @param String message Test description |
275 | */ | 275 | */ |
276 | this.assertTextExists = function assertTextExists(text, message) { | 276 | this.assertTextExists = function assertTextExists(text, message) { |
277 | return this.assert((casper.evaluate(function() { | 277 | return this.assert((casper.evaluate(function _evaluate() { |
278 | return document.body.innerText; | 278 | return document.body.innerText; |
279 | }).indexOf(text) != -1), message); | 279 | }).indexOf(text) != -1), message); |
280 | }; | 280 | }; |
... | @@ -367,7 +367,7 @@ var Tester = function(casper, options) { | ... | @@ -367,7 +367,7 @@ var Tester = function(casper, options) { |
367 | new Function('casper', phantom.getScriptCode(file))(casper); | 367 | new Function('casper', phantom.getScriptCode(file))(casper); |
368 | } catch (e) { | 368 | } catch (e) { |
369 | var self = this; | 369 | var self = this; |
370 | phantom.processScriptError(e, file, function(error) { | 370 | phantom.processScriptError(e, file, function onTestScriptError(error) { |
371 | // do not abort the whole suite, just fail fast displaying the | 371 | // do not abort the whole suite, just fail fast displaying the |
372 | // caught error and process next suite | 372 | // caught error and process next suite |
373 | self.fail(e); | 373 | self.fail(e); |
... | @@ -395,17 +395,17 @@ var Tester = function(casper, options) { | ... | @@ -395,17 +395,17 @@ var Tester = function(casper, options) { |
395 | if (!fs.isDirectory(dir)) { | 395 | if (!fs.isDirectory(dir)) { |
396 | return []; | 396 | return []; |
397 | } | 397 | } |
398 | var entries = fs.list(dir).filter(function(entry) { | 398 | var entries = fs.list(dir).filter(function _filter(entry) { |
399 | return entry !== '.' && entry !== '..'; | 399 | return entry !== '.' && entry !== '..'; |
400 | }).map(function(entry) { | 400 | }).map(function _map(entry) { |
401 | return fs.absolute(fs.pathJoin(dir, entry)); | 401 | return fs.absolute(fs.pathJoin(dir, entry)); |
402 | }); | 402 | }); |
403 | entries.forEach(function(entry) { | 403 | entries.forEach(function _forEach(entry) { |
404 | if (fs.isDirectory(entry)) { | 404 | if (fs.isDirectory(entry)) { |
405 | entries = entries.concat(self.findTestFiles(entry)); | 405 | entries = entries.concat(self.findTestFiles(entry)); |
406 | } | 406 | } |
407 | }); | 407 | }); |
408 | return entries.filter(function(entry) { | 408 | return entries.filter(function _filter(entry) { |
409 | return utils.isJsFile(fs.absolute(fs.pathJoin(dir, entry))); | 409 | return utils.isJsFile(fs.absolute(fs.pathJoin(dir, entry))); |
410 | }).sort(); | 410 | }).sort(); |
411 | }; | 411 | }; |
... | @@ -452,7 +452,7 @@ var Tester = function(casper, options) { | ... | @@ -452,7 +452,7 @@ var Tester = function(casper, options) { |
452 | return; | 452 | return; |
453 | } | 453 | } |
454 | casper.echo(f("\nDetails for the %d failed test%s:\n", failures.length, failures.length > 1 ? "s" : ""), "PARAMETER"); | 454 | casper.echo(f("\nDetails for the %d failed test%s:\n", failures.length, failures.length > 1 ? "s" : ""), "PARAMETER"); |
455 | failures.forEach(function(failure) { | 455 | failures.forEach(function _forEach(failure) { |
456 | var message, line; | 456 | var message, line; |
457 | if (utils.isType(failure.message, "object") && failure.message.stack) { | 457 | if (utils.isType(failure.message, "object") && failure.message.stack) { |
458 | line = failure.message.line ? failure.message.line : 0; | 458 | line = failure.message.line ? failure.message.line : 0; |
... | @@ -516,7 +516,7 @@ var Tester = function(casper, options) { | ... | @@ -516,7 +516,7 @@ var Tester = function(casper, options) { |
516 | if (arguments.length === 0) { | 516 | if (arguments.length === 0) { |
517 | throw new CasperError("runSuites() needs at least one path argument"); | 517 | throw new CasperError("runSuites() needs at least one path argument"); |
518 | } | 518 | } |
519 | Array.prototype.forEach.call(arguments, function(path) { | 519 | Array.prototype.forEach.call(arguments, function _forEach(path) { |
520 | if (!fs.exists(path)) { | 520 | if (!fs.exists(path)) { |
521 | self.bar(f("Path %s doesn't exist", path), "RED_BAR"); | 521 | self.bar(f("Path %s doesn't exist", path), "RED_BAR"); |
522 | } | 522 | } |
... | @@ -531,7 +531,7 @@ var Tester = function(casper, options) { | ... | @@ -531,7 +531,7 @@ var Tester = function(casper, options) { |
531 | casper.exit(1); | 531 | casper.exit(1); |
532 | } | 532 | } |
533 | var current = 0; | 533 | var current = 0; |
534 | var interval = setInterval(function(self) { | 534 | var interval = setInterval(function _check(self) { |
535 | if (self.running) { | 535 | if (self.running) { |
536 | return; | 536 | return; |
537 | } | 537 | } | ... | ... |
... | @@ -104,7 +104,7 @@ function format(f) { | ... | @@ -104,7 +104,7 @@ function format(f) { |
104 | i = 1; | 104 | i = 1; |
105 | var args = arguments; | 105 | var args = arguments; |
106 | var len = args.length; | 106 | var len = args.length; |
107 | var str = String(f).replace(/%[sdj%]/g, function(x) { | 107 | var str = String(f).replace(/%[sdj%]/g, function _replace(x) { |
108 | if (i >= len) return x; | 108 | if (i >= len) return x; |
109 | switch (x) { | 109 | switch (x) { |
110 | case '%s': | 110 | case '%s': |
... | @@ -352,7 +352,7 @@ exports.node = node; | ... | @@ -352,7 +352,7 @@ exports.node = node; |
352 | */ | 352 | */ |
353 | function serialize(value) { | 353 | function serialize(value) { |
354 | if (isArray(value)) { | 354 | if (isArray(value)) { |
355 | value = value.map(function(prop) { | 355 | value = value.map(function _map(prop) { |
356 | return isFunction(prop) ? prop.toString().replace(/\s{2,}/, '') : prop; | 356 | return isFunction(prop) ? prop.toString().replace(/\s{2,}/, '') : prop; |
357 | }); | 357 | }); |
358 | } | 358 | } | ... | ... |
... | @@ -31,7 +31,7 @@ | ... | @@ -31,7 +31,7 @@ |
31 | var utils = require('utils'); | 31 | var utils = require('utils'); |
32 | var fs = require('fs'); | 32 | var fs = require('fs'); |
33 | 33 | ||
34 | exports.create = function() { | 34 | exports.create = function create() { |
35 | return new XUnitExporter(); | 35 | return new XUnitExporter(); |
36 | }; | 36 | }; |
37 | 37 | ||
... | @@ -39,9 +39,9 @@ exports.create = function() { | ... | @@ -39,9 +39,9 @@ exports.create = function() { |
39 | * JUnit XML (xUnit) exporter for test results. | 39 | * JUnit XML (xUnit) exporter for test results. |
40 | * | 40 | * |
41 | */ | 41 | */ |
42 | XUnitExporter = function() { | 42 | XUnitExporter = function XUnitExporter() { |
43 | this._xml = utils.node('testsuite'); | 43 | this._xml = utils.node('testsuite'); |
44 | this._xml.toString = function() { | 44 | this._xml.toString = function toString() { |
45 | return this.outerHTML; // ouch | 45 | return this.outerHTML; // ouch |
46 | }; | 46 | }; |
47 | }; | 47 | }; |
... | @@ -53,7 +53,7 @@ exports.XUnitExporter = XUnitExporter; | ... | @@ -53,7 +53,7 @@ exports.XUnitExporter = XUnitExporter; |
53 | * @param String classname | 53 | * @param String classname |
54 | * @param String name | 54 | * @param String name |
55 | */ | 55 | */ |
56 | XUnitExporter.prototype.addSuccess = function(classname, name) { | 56 | XUnitExporter.prototype.addSuccess = function addSuccess(classname, name) { |
57 | this._xml.appendChild(utils.node('testcase', { | 57 | this._xml.appendChild(utils.node('testcase', { |
58 | classname: generateClassName(classname), | 58 | classname: generateClassName(classname), |
59 | name: name | 59 | name: name |
... | @@ -68,7 +68,7 @@ XUnitExporter.prototype.addSuccess = function(classname, name) { | ... | @@ -68,7 +68,7 @@ XUnitExporter.prototype.addSuccess = function(classname, name) { |
68 | * @param String message | 68 | * @param String message |
69 | * @param String type | 69 | * @param String type |
70 | */ | 70 | */ |
71 | XUnitExporter.prototype.addFailure = function(classname, name, message, type) { | 71 | XUnitExporter.prototype.addFailure = function addFailure(classname, name, message, type) { |
72 | var fnode = utils.node('testcase', { | 72 | var fnode = utils.node('testcase', { |
73 | classname: generateClassName(classname), | 73 | classname: generateClassName(classname), |
74 | name: name | 74 | name: name |
... | @@ -110,6 +110,6 @@ function generateClassName(classname) { | ... | @@ -110,6 +110,6 @@ function generateClassName(classname) { |
110 | * | 110 | * |
111 | * @return HTMLElement | 111 | * @return HTMLElement |
112 | */ | 112 | */ |
113 | XUnitExporter.prototype.getXML = function() { | 113 | XUnitExporter.prototype.getXML = function getXML() { |
114 | return this._xml; | 114 | return this._xml; |
115 | }; | 115 | }; | ... | ... |
-
Please register or sign in to post a comment