Commit 2ce1b83c 2ce1b83cb0df2125111412d123979862e802706f by Nicolas Perriault

fixed remaining missing require() calls

1 parent c959bbfe
......@@ -1137,10 +1137,23 @@ function createPage(casper) {
}
}
// Client-side utils injection
if (!casper.page.injectJs(fs.pathJoin(phantom.casperPath, 'lib', 'clientutils.js'))) {
if (!casper.page.injectJs(fs.pathJoin(phantom.casperPath, 'modules', 'clientutils.js'))) {
casper.log("Failed to inject Casper client-side utilities!", "warning");
} else {
casper.log("Successfully injected Casper client-side utilities", "debug");
var injected = casper.evaluate(function() {
var __utils__;
try {
__utils__ = new CasperUtils();
return true;
} catch (e) {
return false;
}
});
if (true === injected) {
casper.log("Successfully injected Casper client-side utilities", "debug");
} else {
casper.log("Failed to instantiate Casper client-side utilities!", "warning");
}
}
// history
casper.history.push(casper.getCurrentUrl());
......
......@@ -338,10 +338,11 @@
};
/**
* Logs a message.
* Logs a message. Will format the message a way CasperJS will be able
* to log phantomjs side.
*
* @param String message
* @param String level
* @param String message The message to log
* @param String level The log level
*/
this.log = function(message, level) {
console.log("[casper:" + (level || "debug") + "] " + message);
......@@ -362,9 +363,9 @@
field = fields[0];
}
if (!field instanceof HTMLElement) {
this.log("invalid field type; only HTMLElement and NodeList are supported", "error");
this.log("Invalid field type; only HTMLElement and NodeList are supported", "error");
}
this.log('set "' + field.getAttribute('name') + '" field value to ' + value, "debug");
this.log('Set "' + field.getAttribute('name') + '" field value to ' + value, "debug");
try {
field.focus();
} catch (e) {
......@@ -409,7 +410,7 @@
case "file":
throw {
name: "FileUploadError",
message: "file field must be filled using page.uploadFile",
message: "File field must be filled using page.uploadFile",
path: value
};
case "radio":
......@@ -418,11 +419,11 @@
e.checked = (e.value === value);
});
} else {
out = 'provided radio elements are empty';
out = 'Urovided radio elements are empty';
}
break;
default:
out = "unsupported input field type: " + type;
out = "Unsupported input field type: " + type;
break;
}
break;
......@@ -431,7 +432,7 @@
field.value = value;
break;
default:
out = 'unsupported field type: ' + nodeName;
out = 'Unsupported field type: ' + nodeName;
break;
}
try {
......@@ -442,4 +443,4 @@
return out;
};
};
})(exports || window || {});
})(typeof exports === "object" ? exports : window);
......
......@@ -26,7 +26,7 @@
*
*/
exports.create = create;
var utils = require('utils');
exports.create = function(fn) {
return new FunctionArgsInjector(fn);
......@@ -38,7 +38,7 @@ exports.create = function(fn) {
* FIXME: use new Function() instead of eval()
*/
var FunctionArgsInjector = function(fn) {
if (!isType(fn, "function")) {
if (!utils.isType(fn, "function")) {
throw new Error("FunctionArgsInjector() can only process functions");
}
this.fn = fn;
......@@ -61,7 +61,7 @@ var FunctionArgsInjector = function(fn) {
this.process = function(values) {
var fnObj = this.extract(this.fn);
if (!isType(fnObj, "object")) {
if (!utils.isType(fnObj, "object")) {
throw new Error("Unable to process function " + this.fn.toString());
}
var inject = this.getArgsInjectionString(fnObj.args, values);
......
......@@ -26,6 +26,8 @@
*
*/
var utils = require('utils');
exports.create = function() {
return new XUnitExporter();
};
......@@ -39,7 +41,7 @@ XUnitExporter = function() {
var node = document.createElement(name);
for (var attrName in attributes) {
var value = attributes[attrName];
if (attributes.hasOwnProperty(attrName) && isType(attrName, "string")) {
if (attributes.hasOwnProperty(attrName) && utils.isType(attrName, "string")) {
node.setAttribute(attrName, value);
}
}
......
......@@ -4,6 +4,7 @@ if (!phantom.casperLoaded) {
}
var fs = require('fs');
var utils = require('utils');
phantom.injectJs(fs.pathJoin(phantom.casperPath, 'lib', 'vendors', 'esprima.js'));
......@@ -15,7 +16,7 @@ var casper = new phantom.Casper({
// Overriding Casper.open to prefix all test urls
phantom.Casper.extend({
open: function(location, options) {
options = isType(options, "object") ? options : {};
options = utils.isType(options, "object") ? options : {};
this.requestUrl = location;
var url = 'file://' + phantom.casperPath + '/' + location;
this.page.open(url);
......