fixed remaining missing require() calls
Showing
5 changed files
with
33 additions
and
16 deletions
... | @@ -1137,10 +1137,23 @@ function createPage(casper) { | ... | @@ -1137,10 +1137,23 @@ function createPage(casper) { |
1137 | } | 1137 | } |
1138 | } | 1138 | } |
1139 | // Client-side utils injection | 1139 | // Client-side utils injection |
1140 | if (!casper.page.injectJs(fs.pathJoin(phantom.casperPath, 'lib', 'clientutils.js'))) { | 1140 | if (!casper.page.injectJs(fs.pathJoin(phantom.casperPath, 'modules', 'clientutils.js'))) { |
1141 | casper.log("Failed to inject Casper client-side utilities!", "warning"); | 1141 | casper.log("Failed to inject Casper client-side utilities!", "warning"); |
1142 | } else { | 1142 | } else { |
1143 | var injected = casper.evaluate(function() { | ||
1144 | var __utils__; | ||
1145 | try { | ||
1146 | __utils__ = new CasperUtils(); | ||
1147 | return true; | ||
1148 | } catch (e) { | ||
1149 | return false; | ||
1150 | } | ||
1151 | }); | ||
1152 | if (true === injected) { | ||
1143 | casper.log("Successfully injected Casper client-side utilities", "debug"); | 1153 | casper.log("Successfully injected Casper client-side utilities", "debug"); |
1154 | } else { | ||
1155 | casper.log("Failed to instantiate Casper client-side utilities!", "warning"); | ||
1156 | } | ||
1144 | } | 1157 | } |
1145 | // history | 1158 | // history |
1146 | casper.history.push(casper.getCurrentUrl()); | 1159 | casper.history.push(casper.getCurrentUrl()); | ... | ... |
... | @@ -338,10 +338,11 @@ | ... | @@ -338,10 +338,11 @@ |
338 | }; | 338 | }; |
339 | 339 | ||
340 | /** | 340 | /** |
341 | * Logs a message. | 341 | * Logs a message. Will format the message a way CasperJS will be able |
342 | * to log phantomjs side. | ||
342 | * | 343 | * |
343 | * @param String message | 344 | * @param String message The message to log |
344 | * @param String level | 345 | * @param String level The log level |
345 | */ | 346 | */ |
346 | this.log = function(message, level) { | 347 | this.log = function(message, level) { |
347 | console.log("[casper:" + (level || "debug") + "] " + message); | 348 | console.log("[casper:" + (level || "debug") + "] " + message); |
... | @@ -362,9 +363,9 @@ | ... | @@ -362,9 +363,9 @@ |
362 | field = fields[0]; | 363 | field = fields[0]; |
363 | } | 364 | } |
364 | if (!field instanceof HTMLElement) { | 365 | if (!field instanceof HTMLElement) { |
365 | this.log("invalid field type; only HTMLElement and NodeList are supported", "error"); | 366 | this.log("Invalid field type; only HTMLElement and NodeList are supported", "error"); |
366 | } | 367 | } |
367 | this.log('set "' + field.getAttribute('name') + '" field value to ' + value, "debug"); | 368 | this.log('Set "' + field.getAttribute('name') + '" field value to ' + value, "debug"); |
368 | try { | 369 | try { |
369 | field.focus(); | 370 | field.focus(); |
370 | } catch (e) { | 371 | } catch (e) { |
... | @@ -409,7 +410,7 @@ | ... | @@ -409,7 +410,7 @@ |
409 | case "file": | 410 | case "file": |
410 | throw { | 411 | throw { |
411 | name: "FileUploadError", | 412 | name: "FileUploadError", |
412 | message: "file field must be filled using page.uploadFile", | 413 | message: "File field must be filled using page.uploadFile", |
413 | path: value | 414 | path: value |
414 | }; | 415 | }; |
415 | case "radio": | 416 | case "radio": |
... | @@ -418,11 +419,11 @@ | ... | @@ -418,11 +419,11 @@ |
418 | e.checked = (e.value === value); | 419 | e.checked = (e.value === value); |
419 | }); | 420 | }); |
420 | } else { | 421 | } else { |
421 | out = 'provided radio elements are empty'; | 422 | out = 'Urovided radio elements are empty'; |
422 | } | 423 | } |
423 | break; | 424 | break; |
424 | default: | 425 | default: |
425 | out = "unsupported input field type: " + type; | 426 | out = "Unsupported input field type: " + type; |
426 | break; | 427 | break; |
427 | } | 428 | } |
428 | break; | 429 | break; |
... | @@ -431,7 +432,7 @@ | ... | @@ -431,7 +432,7 @@ |
431 | field.value = value; | 432 | field.value = value; |
432 | break; | 433 | break; |
433 | default: | 434 | default: |
434 | out = 'unsupported field type: ' + nodeName; | 435 | out = 'Unsupported field type: ' + nodeName; |
435 | break; | 436 | break; |
436 | } | 437 | } |
437 | try { | 438 | try { |
... | @@ -442,4 +443,4 @@ | ... | @@ -442,4 +443,4 @@ |
442 | return out; | 443 | return out; |
443 | }; | 444 | }; |
444 | }; | 445 | }; |
445 | })(exports || window || {}); | 446 | })(typeof exports === "object" ? exports : window); | ... | ... |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | exports.create = create; | 29 | var utils = require('utils'); |
30 | 30 | ||
31 | exports.create = function(fn) { | 31 | exports.create = function(fn) { |
32 | return new FunctionArgsInjector(fn); | 32 | return new FunctionArgsInjector(fn); |
... | @@ -38,7 +38,7 @@ exports.create = function(fn) { | ... | @@ -38,7 +38,7 @@ exports.create = function(fn) { |
38 | * FIXME: use new Function() instead of eval() | 38 | * FIXME: use new Function() instead of eval() |
39 | */ | 39 | */ |
40 | var FunctionArgsInjector = function(fn) { | 40 | var FunctionArgsInjector = function(fn) { |
41 | if (!isType(fn, "function")) { | 41 | if (!utils.isType(fn, "function")) { |
42 | throw new Error("FunctionArgsInjector() can only process functions"); | 42 | throw new Error("FunctionArgsInjector() can only process functions"); |
43 | } | 43 | } |
44 | this.fn = fn; | 44 | this.fn = fn; |
... | @@ -61,7 +61,7 @@ var FunctionArgsInjector = function(fn) { | ... | @@ -61,7 +61,7 @@ var FunctionArgsInjector = function(fn) { |
61 | 61 | ||
62 | this.process = function(values) { | 62 | this.process = function(values) { |
63 | var fnObj = this.extract(this.fn); | 63 | var fnObj = this.extract(this.fn); |
64 | if (!isType(fnObj, "object")) { | 64 | if (!utils.isType(fnObj, "object")) { |
65 | throw new Error("Unable to process function " + this.fn.toString()); | 65 | throw new Error("Unable to process function " + this.fn.toString()); |
66 | } | 66 | } |
67 | var inject = this.getArgsInjectionString(fnObj.args, values); | 67 | var inject = this.getArgsInjectionString(fnObj.args, values); | ... | ... |
... | @@ -26,6 +26,8 @@ | ... | @@ -26,6 +26,8 @@ |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | var utils = require('utils'); | ||
30 | |||
29 | exports.create = function() { | 31 | exports.create = function() { |
30 | return new XUnitExporter(); | 32 | return new XUnitExporter(); |
31 | }; | 33 | }; |
... | @@ -39,7 +41,7 @@ XUnitExporter = function() { | ... | @@ -39,7 +41,7 @@ XUnitExporter = function() { |
39 | var node = document.createElement(name); | 41 | var node = document.createElement(name); |
40 | for (var attrName in attributes) { | 42 | for (var attrName in attributes) { |
41 | var value = attributes[attrName]; | 43 | var value = attributes[attrName]; |
42 | if (attributes.hasOwnProperty(attrName) && isType(attrName, "string")) { | 44 | if (attributes.hasOwnProperty(attrName) && utils.isType(attrName, "string")) { |
43 | node.setAttribute(attrName, value); | 45 | node.setAttribute(attrName, value); |
44 | } | 46 | } |
45 | } | 47 | } | ... | ... |
... | @@ -4,6 +4,7 @@ if (!phantom.casperLoaded) { | ... | @@ -4,6 +4,7 @@ if (!phantom.casperLoaded) { |
4 | } | 4 | } |
5 | 5 | ||
6 | var fs = require('fs'); | 6 | var fs = require('fs'); |
7 | var utils = require('utils'); | ||
7 | 8 | ||
8 | phantom.injectJs(fs.pathJoin(phantom.casperPath, 'lib', 'vendors', 'esprima.js')); | 9 | phantom.injectJs(fs.pathJoin(phantom.casperPath, 'lib', 'vendors', 'esprima.js')); |
9 | 10 | ||
... | @@ -15,7 +16,7 @@ var casper = new phantom.Casper({ | ... | @@ -15,7 +16,7 @@ var casper = new phantom.Casper({ |
15 | // Overriding Casper.open to prefix all test urls | 16 | // Overriding Casper.open to prefix all test urls |
16 | phantom.Casper.extend({ | 17 | phantom.Casper.extend({ |
17 | open: function(location, options) { | 18 | open: function(location, options) { |
18 | options = isType(options, "object") ? options : {}; | 19 | options = utils.isType(options, "object") ? options : {}; |
19 | this.requestUrl = location; | 20 | this.requestUrl = location; |
20 | var url = 'file://' + phantom.casperPath + '/' + location; | 21 | var url = 'file://' + phantom.casperPath + '/' + location; |
21 | this.page.open(url); | 22 | this.page.open(url); | ... | ... |
-
Please register or sign in to post a comment