Socket
Socket
Sign inDemoInstall

casperjs

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casperjs - npm Package Compare versions

Comparing version 1.1.0-beta3 to 1.1.0-beta4

.eslintignore

161

bin/bootstrap.js

@@ -31,9 +31,8 @@ /*!

/*global process, console, phantom, slimer, require:true*/
/*jshint maxstatements:34, maxcomplexity:10*/
/*eslint max-statements:0, complexity:0*/
// node check
if ('process' in this && process.title === "node") {
if ('process' in this && this.process.title === "node") {
console.error('CasperJS cannot be executed within a nodejs environment');
process.exit(1);
this.process.exit(1);
}

@@ -47,23 +46,35 @@

// Common polyfills
if (typeof Function.prototype.bind !== "function") {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility
Function.prototype.bind = function (oThis) {
"use strict";
/* jshint -W055 */
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
// cujos bind shim instead of MDN shim, see #1396
var isFunction = function(o) {
return 'function' === typeof o;
};
var bind;
var slice = [].slice;
var proto = Function.prototype;
var featureMap = {
'function-bind': 'bind'
};
function has(feature) {
var prop = featureMap[feature];
return isFunction(proto[prop]);
}
// check for missing features
if (!has('function-bind')) {
// adapted from Mozilla Developer Network example at
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
bind = function bind(obj) {
var args = slice.call(arguments, 1),
self = this,
nop = function() {
},
bound = function() {
return self.apply(this instanceof nop ? this : (obj || {}), args.concat(slice.call(arguments)));
};
nop.prototype = this.prototype || {}; // Firefox cries sometimes if prototype is undefined
bound.prototype = new nop();
return bound;
};
proto.bind = bind;
}

@@ -80,9 +91,13 @@ // Custom base error

// casperjs env initialization
(function(global, phantom){
(function(global, phantom, system){
"use strict";
// phantom args
// NOTE: we can't use require('system').args here for some very obscure reason
// do not even attempt at using it as it creates infinite recursion
var phantomArgs = phantom.args;
var phantomArgs = system.args.slice(1);
if ("slimer" in global) {
phantom.casperEngine = "slimerjs";
} else {
phantom.casperEngine = "phantomjs";
}
if (phantom.casperLoaded) {

@@ -92,2 +107,6 @@ return;

function __exit(statusCode){
setTimeout(function() { phantom.exit(statusCode); }, 0);
}
function __die(message) {

@@ -97,3 +116,3 @@ if (message) {

}
phantom.exit(1);
__exit(1);
}

@@ -105,15 +124,21 @@

}
phantom.exit();
__exit();
}
(function(version) {
(function (version) {
// required version check
if (version.major !== 1) {
return __die('CasperJS needs PhantomJS v1.x');
} if (version.minor < 8) {
return __die('CasperJS needs at least PhantomJS v1.8 or later.');
if (phantom.casperEngine === 'phantomjs') {
if (version.major === 1) {
if (version.minor < 9) {
return __die('CasperJS needs at least PhantomJS v1.9 or later.');
}
if (version.minor === 9 && version.patch < 1) {
return __die('CasperJS needs at least PhantomJS v1.9.1 or later.');
}
} else if (version.major === 2) {
// No requirements yet known
} else {
return __die('CasperJS needs PhantomJS v1.9.x or v2.x');
}
}
if (version.minor === 8 && version.patch < 1) {
return __die('CasperJS needs at least PhantomJS v1.8.1 or later.');
}
})(phantom.version);

@@ -129,3 +154,3 @@

// exits on syntax error
if (msg.indexOf('SyntaxError: Parse error') === 0) {
if (msg.indexOf('SyntaxError: ') === 0) {
__die();

@@ -167,3 +192,3 @@ }

try {
phantom.casperPath = phantom.args.map(function _map(arg) {
phantom.casperPath = phantomArgs.map(function _map(arg) {
var match = arg.match(/^--casper-path=(.*)/);

@@ -185,2 +210,3 @@ if (match) {

function printHelp() {
/* global slimer */
var engine = phantom.casperEngine === 'slimerjs' ? slimer : phantom;

@@ -192,3 +218,3 @@ var version = [engine.version.major, engine.version.minor, engine.version.patch].join('.');

fs.read(fs.pathJoin(phantom.casperPath, 'bin', 'usage.txt'))
].join('\n'))
].join('\n'));
}

@@ -260,3 +286,10 @@

function nodeModulePath(path) {
return resolveFile(path, fs.pathJoin(getCurrentScriptRoot(), 'node_modules'));
var resolved, prevBaseDir;
var baseDir = getCurrentScriptRoot();
do {
resolved = resolveFile(path, fs.pathJoin(baseDir, 'node_modules'));
prevBaseDir = baseDir;
baseDir = fs.absolute(fs.pathJoin(prevBaseDir, '..'));
} while (!resolved && baseDir !== '/' && baseDir !== prevBaseDir);
return resolved;
}

@@ -287,3 +320,3 @@ function localModulePath(path) {

function initCasperCli(casperArgs) {
/* jshint maxcomplexity:99 */
/*eslint complexity:0*/
var baseTestsPath = fs.pathJoin(phantom.casperPath, 'tests');

@@ -300,3 +333,3 @@

if (!!casperArgs.options.version) {
return __terminate(phantom.casperVersion.toString())
return __terminate(phantom.casperVersion.toString());
} else if (casperArgs.get(0) === "test") {

@@ -368,20 +401,20 @@ phantom.casperScript = fs.absolute(fs.pathJoin(baseTestsPath, 'run.js'));

if ("slimer" in global) {
// for SlimerJS, use the standard API to declare directories
// where to search modules
// phantomjs2 has paths in require, but needs patchRequire anyway
if (!("paths" in global.require) ||
('phantomjs' === phantom.casperEngine && 1 < phantom.version.major)
) {
global.__require = require;
global.patchRequire = patchRequire; // must be called in every casperjs module as of 1.1
global.require = patchRequire(global.require);
} else {
// declare a dummy patchRequire function
global.patchRequire = function(req) {return req;};
require.paths.push(fs.pathJoin(phantom.casperPath, 'modules'));
require.paths.push(fs.workingDirectory);
}
// declare a dummy patchRequire function
require.globals.patchRequire = global.patchRequire = function(req) { return req;};
if (phantom.casperEngine === 'slimerjs') {
require.globals.patchRequire = global.patchRequire;
require.globals.CasperError = CasperError;
phantom.casperEngine = "slimerjs";
}
else {
// patch require
global.__require = require;
global.patchRequire = patchRequire; // must be called in every casperjs module as of 1.1
global.require = patchRequire(global.require);
phantom.casperEngine = "phantomjs";
}

@@ -395,7 +428,9 @@ // casper cli args

if ("slimer" in global && phantom.casperScriptBaseDir) {
// initCasperCli has set casperScriptBaseDir
// use it instead of fs.workingDirectory
require.paths.pop();
require.paths.push(phantom.casperScriptBaseDir);
if ("paths" in global.require) {
if ((phantom.casperScriptBaseDir || "").indexOf(fs.workingDirectory) === 0) {
require.paths.push(phantom.casperScriptBaseDir);
} else {
require.paths.push(fs.pathJoin(fs.workingDirectory, phantom.casperScriptBaseDir));
}
require.paths.push(fs.pathJoin(require.paths[require.paths.length-1], 'node_modules'));
}

@@ -410,2 +445,2 @@

}
})(this, phantom);
})(this, phantom, require('system'));

@@ -32,6 +32,12 @@ # Contribution Guide

$ casperjs selftest
$ casperjs selftest && casper selftest --engine=slimerjs
The result status bar **must be green** before sending your PR.
**Lint the code**
Run [ESLint](http://eslint.org) on the JavaScript files, by using the configuration available in `.eslintrc` and make sure there are no warnings nor errors.
$ eslint modules/casper.js
## Communicate

@@ -38,0 +44,0 @@

@@ -1,2 +0,2 @@

Copyright (c) 2011-2012 Nicolas Perriault
Copyright (c) 2011-2015 Nicolas Perriault

@@ -3,0 +3,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -38,3 +38,3 @@ /*!

/**
* Extracts, normalize ad organize PhantomJS CLI arguments in a dedicated
* Extracts, normalize and organize PhantomJS CLI arguments in a dedicated
* Object.

@@ -41,0 +41,0 @@ *

@@ -31,3 +31,3 @@ /*!

/*global console, escape, exports, NodeList, window*/
/*global escape, NodeList*/

@@ -45,3 +45,3 @@ (function(exports) {

exports.ClientUtils = function ClientUtils(options) {
/*jshint maxstatements:40*/
/*eslint max-statements:0, no-multi-spaces:0*/
// private members

@@ -101,3 +101,3 @@ var BASE64_ENCODE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

this.decode = function decode(str) {
/*jshint maxstatements:30, maxcomplexity:30 */
/*eslint max-statements:0, complexity:0 */
var c1, c2, c3, c4, i = 0, len = str.length, out = "";

@@ -170,7 +170,7 @@ while (i < len) {

}
if (style.display === "inline") {
if (style.display === "inline" || style.display === "inline-block") {
return true;
}
return elem.clientHeight > 0 && elem.clientWidth > 0;
}
};

@@ -185,3 +185,3 @@ /**

this.encode = function encode(str) {
/*jshint maxstatements:30 */
/*eslint max-statements:0 */
var out = "", i = 0, len = str.length, c1, c2, c3;

@@ -238,3 +238,3 @@ while (i < len) {

Array.prototype.forEach.call(elements, function _forEach(element) {
text += element.textContent || element.innerText;
text += element.textContent || element.innerText || element.value || '';
});

@@ -254,3 +254,3 @@ }

this.fill = function fill(form, vals, findType) {
/*jshint maxcomplexity:8*/
/*eslint complexity:0*/
var out = {

@@ -283,2 +283,8 @@ errors: [],

},
labels: function(labelText, formSelector, value) {
var label = this.findOne({type: "xpath", path: '//label[text()="' + labelText + '"]'}, form);
if(label && label.htmlFor) {
return this.findAll('#' + label.htmlFor, form);
}
},
names: function(elementName, formSelector) {

@@ -306,5 +312,11 @@ return this.findAll('[name="' + elementName + '"]', form);

if (err.name === "FileUploadError") {
var selector;
if(findType === "labels") {
selector = '#' + field[0].id;
} else {
selector = fieldSelector;
}
out.files.push({
type: findType,
selector: fieldSelector,
selector: selector,
path: err.path

@@ -388,3 +400,5 @@ });

try {
return this.sendAJAX(url, method, data, false);
return this.sendAJAX(url, method, data, false, {
overrideMimeType: "text/plain; charset=x-user-defined"
});
} catch (e) {

@@ -569,2 +583,11 @@ if (e.name === "NETWORK_ERR" && e.code === 101) {

}
if (input.type === 'select-multiple') {
return [].filter.call(input.options, function(option) {
return !!option.selected;
}).map(function(option) {
return option.value;
});
}
if (['checkbox', 'radio'].indexOf(type) === -1) {

@@ -752,3 +775,3 @@ return input.value;

this.scrollTo(0, this.getDocumentHeight());
},
};

@@ -773,3 +796,5 @@ /**

this.log("sendAJAX(): Using HTTP method: '" + method + "'", "debug");
xhr.overrideMimeType("text/plain; charset=x-user-defined");
if (settings && settings.overrideMimeType) {
xhr.overrideMimeType(settings.overrideMimeType);
}
if (method === "POST") {

@@ -799,3 +824,3 @@ if (typeof data === "object") {

this.setField = function setField(field, value) {
/*jshint maxcomplexity:99 */
/*eslint complexity:0*/
var logValue, fields, out;

@@ -817,3 +842,3 @@ value = logValue = (value || "");

// obfuscate password value
logValue = new Array(value.length + 1).join("*");
logValue = new Array((''+value).length + 1).join("*");
}

@@ -856,5 +881,9 @@

if (fields) {
Array.prototype.forEach.call(fields, function _forEach(e) {
e.checked = (e.value === value);
});
if (fields.length > 1) {
Array.prototype.forEach.call(fields, function _forEach(e) {
e.checked = (e.value === value);
});
} else {
field.checked = value ? true : false;
}
} else {

@@ -870,2 +899,29 @@ out = 'Provided radio elements are empty';

case "select":
if (field.multiple) {
[].forEach.call(field.options, function(option) {
option.selected = value.indexOf(option.value) !== -1;
});
// If the values can't be found, try search options text
if (field.value === "") {
[].forEach.call(field.options, function(option) {
option.selected = value.indexOf(option.text) !== -1;
});
}
} else {
// PhantomJS 1.x.x can't handle setting value to ''
if ('' === value) {
field.selectedIndex = -1;
} else {
field.value = value;
}
// If the value can't be found, try search options text
if (field.value !== value) {
[].some.call(field.options, function(option) {
option.selected = value === option.text;
return value === option.text;
});
}
}
break;
case "textarea":

@@ -905,2 +961,2 @@ field.value = value;

};
})(typeof exports === "object" ? exports : window);
})(typeof exports === "object" && !(exports instanceof Element) ? exports : window);

@@ -57,2 +57,3 @@ /*!

"use strict";
/*eslint no-multi-spaces:0*/
var options = { bold: 1, underscore: 4, blink: 5, reverse: 7, conceal: 8 };

@@ -84,3 +85,3 @@ var foreground = { black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37 };

this.colorize = function colorize(text, styleName, pad) {
if ((fs.isWindows() && !env['ANSICON']) || !(styleName in styles)) {
if ((fs.isWindows() && (!env['ANSICON'] && env['ConEmuANSI'] !== 'ON')) || !(styleName in styles)) {
return text;

@@ -99,3 +100,3 @@ }

this.format = function format(text, style, pad) {
if ((fs.isWindows() && !env['ANSICON']) || !utils.isObject(style)) {
if ((fs.isWindows() && (!env['ANSICON'] && env['ConEmuANSI'] !== 'ON')) || !utils.isObject(style)) {
return text;

@@ -102,0 +103,0 @@ }

@@ -132,3 +132,3 @@ /*!

// If we've already got an array, just append.
this._events[type].push(listener);
this._events[type]['fail' === type ? 'unshift' : 'push'](listener);

@@ -155,3 +155,3 @@ // Check for listener leak

// Adding the second element, need to change to array.
this._events[type] = [this._events[type], listener];
this._events[type] = 'fail' === type ? [listener, this._events[type]] : [this._events[type], listener];
}

@@ -162,2 +162,47 @@

EventEmitter.prototype.prependListener = function prependListener(type, listener) {
if ('function' !== typeof listener) {
throw new CasperError('addListener only takes instances of Function');
}
if (!this._events) this._events = {};
// To avoid recursion in the case that type == "newListeners"! Before
// adding it to the listeners, first emit "newListeners".
this.emit('newListener', type, listener);
if (!this._events[type]) {
// Optimize the case of one listener. Don't need the extra array object.
this._events[type] = listener;
} else if (isArray(this._events[type])) {
// If we've already got an array, just append.
this._events[type].unshift(listener);
// Check for listener leak
if (!this._events[type].warned) {
var m;
if (this._maxListeners !== undefined) {
m = this._maxListeners;
} else {
m = defaultMaxListeners;
}
if (m && m > 0 && this._events[type].length > m) {
this._events[type].warned = true;
console.error('(node) warning: possible EventEmitter memory ' +
'leak detected. %d listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.',
this._events[type].length);
console.trace();
}
}
} else {
// Adding the second element, need to change to array.
this._events[type] = [listener, this._events[type]];
}
return this;
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;

@@ -164,0 +209,0 @@

@@ -31,4 +31,2 @@ /*!

/*global patchRequire, require:true*/
var require = patchRequire(require);

@@ -70,3 +68,2 @@ var utils = require('utils');

"use strict";
/*jshint proto:true*/
if (!utils.isHTTPResource(response)) {

@@ -73,0 +70,0 @@ return;

@@ -100,2 +100,30 @@ /*!

this.rightclick = function rightclick() {
var array = [];
switch (arguments.length) {
case 0:
throw new CasperError('Mouse.rightclick(): Too few arguments');
case 1:
array = computeCenter(arguments[0]);
break;
case 2:
array = arguments;
break;
default:
throw new CasperError('Mouse.rightclick(): Too many arguments');
}
casper.page.evaluate(function (clientX, clientY) {
var element = document.elementFromPoint(clientX, clientY);
raiseEvent('contextmenu');
function raiseEvent(eventType) {
var event = document.createEvent('MouseEvent');
event.initMouseEvent(eventType, true, true, window, 1, clientX, clientY, clientX, clientY, false, false, false, false, 2, null);
element.dispatchEvent(event);
}
}, array[0], array[1]);
};
this.doubleclick = function doubleclick() {

@@ -102,0 +130,0 @@ processEvent('doubleclick', arguments);

@@ -31,4 +31,2 @@ /*!

/*global CasperError, exports, phantom, __utils__, patchRequire, require:true*/
var require = patchRequire(require);

@@ -88,3 +86,3 @@ var fs = require('fs');

"use strict";
/*jshint maxstatements:99*/
/*eslint max-statements:0*/
if (!utils.isCasperObject(casper)) {

@@ -229,3 +227,3 @@ throw new CasperError("Tester needs a Casper instance");

this.casper.options.onWaitTimeout = function test_onWaitTimeout(timeout, details) {
/*jshint maxcomplexity:10*/
/*eslint complexity:0*/
var message = f("Wait timeout occured (%dms)", timeout);

@@ -294,2 +292,51 @@ details = details || {};

/**
* Skip `nb` test on specific engine(s).
*
* A skip specifier is an object of the form:
* {
* name: 'casperjs' | 'phantomjs',
* version: {
* min: Object,
* max: Object
* },
* message: String
* }
*
* Minimal and maximal versions to be skipped are determined using
* utils.matchEngine.
*
* @param Integer nb Number of tests to skip
* @param Mixed skipSpec a single skip specifier object or
* an Array of skip specifier objects
* @return Object
*/
Tester.prototype.skipIfEngine = function skipIfEngine(nb, skipSpec) {
skipSpec = utils.matchEngine(skipSpec);
if (skipSpec) {
var message = skipSpec.name;
var version = skipSpec.version;
var skipMessage = skipSpec.message;
if (version) {
var min = version.min;
var max = version.max;
if (min && min === max) {
message += ' ' + min;
} else {
if (min) {
message += ' from ' + min;
}
if (max) {
message += ' to ' + max;
}
}
}
if (skipMessage) {
message += ' ' + skipMessage;
}
return this.skip(nb, message);
}
return false;
};
/**
* Asserts that a condition strictly resolves to true. Also returns an

@@ -457,3 +504,2 @@ * "assertion object" containing useful informations about the test case

function baseFieldAssert(inputName, expected, actual, message) {
/*jshint validthis:true */
"use strict";

@@ -675,3 +721,3 @@

return this.assert(!this.casper.visible(selector), message, {
type: "assertVisible",
type: "assertNotVisible",
standard: "Selector is not visible",

@@ -697,3 +743,3 @@ values: {

"use strict";
var context = {
var error, thrown = false, context = {
type: "assertRaises",

@@ -704,10 +750,11 @@ standard: "Function raises an error"

fn.apply(null, args);
this.assert(false, message, context);
} catch (error) {
this.assert(true, message, utils.mergeObjects(context, {
values: {
error: error
}
}));
} catch (err) {
thrown = true;
error = err;
}
this.assert(thrown, message, utils.mergeObjects(context, {
values: {
error: error
}
}));
};

@@ -787,3 +834,3 @@

"use strict";
/*jshint eqeqeq:false*/
/*eslint eqeqeq:0*/
return this.assert(utils.isTruthy(subject), message, {

@@ -807,3 +854,3 @@ type: "assertTruthy",

"use strict";
/*jshint eqeqeq:false*/
/*eslint eqeqeq:0*/
return this.assert(utils.isFalsy(subject), message, {

@@ -1075,3 +1122,3 @@ type: "assertFalsy",

config.test(this, this.casper);
if (this.options.concise)
if (!this.options.concise) {
this.casper.echo([

@@ -1084,2 +1131,3 @@ this.colorize('PASS', 'INFO'),

].join(' '));
}
}.bind(this);

@@ -1147,3 +1195,3 @@

"use strict";
/*jshint maxstatements:20, maxcomplexity:20*/
/*eslint max-statements:0, complexity:0*/
var planned, config = this.currentSuite && this.currentSuite.config || {};

@@ -1289,3 +1337,3 @@

return entries.filter(function _filter(entry) {
return utils.isJsFile(fs.absolute(fs.pathJoin(dir, entry)));
return utils.isJsFile(entry);
}).sort();

@@ -1355,6 +1403,6 @@ };

var r = /^\s*(.*)@(.*):(\d+)\s*$/gm;
var r = /\r?\n\s*(.*?)(at |@)([^:]*?):(\d+):?(\d*)/g;
var m;
while ((m = r.exec(error.stack))) {
var sourceURL = m[2];
var sourceURL = m[3];
if (sourceURL.indexOf('->') !== -1) {

@@ -1364,3 +1412,3 @@ sourceURL = sourceURL.split('->')[1].trim();

if (sourceURL === testFile) {
return { sourceURL: sourceURL, line: m[3]}
return { sourceURL: sourceURL, line: m[4], column: m[5]};
}

@@ -1507,3 +1555,3 @@ }

"use strict";
/*jshint maxstatements:25*/
/*eslint max-statements:0*/
save = save || this.options.save;

@@ -1552,3 +1600,3 @@ var exitStatus = 0,

/**
* Runs al suites contained in the paths passed as arguments.
* Runs all suites contained in the paths passed as arguments.
*

@@ -1640,3 +1688,3 @@ */

try {
fs.write(filepath, exporter.getXML(), 'w');
fs.write(filepath, exporter.getSerializedXML(), 'w');
this.casper.echo(f('Result log stored in %s', filepath), 'INFO', 80);

@@ -1979,9 +2027,10 @@ } catch (e) {

/**
* Adds a warning record.
* Adds a warning message.
* NOTE: quite contrary to addError, addSuccess, and addSkip
* this adds a String value, NOT an Object
*
* @param Object warning
* @param String warning
*/
TestCaseResult.prototype.addWarning = function addWarning(warning) {
"use strict";
warning.suite = this.name;
this.warnings.push(warning);

@@ -1988,0 +2037,0 @@ };

@@ -31,3 +31,2 @@ /*!

/*global CasperError, console, exports, phantom, patchRequire, require:true*/

@@ -84,3 +83,3 @@ var require = patchRequire(require);

"use strict";
/*jshint eqnull:true, eqeqeq:false */
/*eslint eqeqeq:0 */
if (typeof input == 'undefined' || input == null) {

@@ -433,3 +432,3 @@ return false;

"use strict";
/*jshint eqeqeq:false*/
/*eslint eqeqeq:0*/
return !subject;

@@ -471,3 +470,8 @@ }

var ext = fileExt(file);
return isString(ext, "string") && ['js', 'coffee'].indexOf(ext) !== -1;
var valid = Object.keys(require.extensions).map(function(val) {
return val.replace(/^\./, '');
}).filter(function(ext) {
return ext !== 'json';
});
return isString(ext, "string") && valid.indexOf(ext) !== -1;
}

@@ -544,3 +548,3 @@ exports.isJsFile = isJsFile;

"use strict";
/*jshint eqeqeq:false*/
/*eslint eqeqeq:0*/
return !!subject;

@@ -642,3 +646,3 @@ }

*/
function mergeObjectsInSlimerjs(origin, add, opts) {
function mergeObjectsInGecko(origin, add, opts) {
"use strict";

@@ -657,3 +661,14 @@

} else {
origin[p] = add[p];
// if a property is only a getter, we could have a Javascript error
// in strict mode "TypeError: setting a property that has only a getter"
// when setting the value to the new object (gecko 25+).
// To avoid it, let's define the property on the new object, do not set
// directly the value
var prop = Object.getOwnPropertyDescriptor(add, p);
if (prop.get && !prop.set) {
Object.defineProperty(origin, p, prop);
}
else {
origin[p] = add[p];
}
}

@@ -682,3 +697,3 @@ }

// let's use an other algorithm
return mergeObjectsInSlimerjs(origin, add);
return mergeObjectsInGecko(origin, add, options);
}

@@ -804,2 +819,17 @@

/**
* Convert a version object to a string.
*
* @param Mixed version a version string or object
*/
function versionToString(version) {
if (isObject(version)) {
try {
return [version.major, version.minor, version.patch].join('.');
} catch (e) {}
}
return version;
}
exports.versionToString = versionToString;
/**
* Compare two version numbers represented as strings.

@@ -814,10 +844,2 @@ *

var i, cmp, len, re = /(\.0)+[^\.]*$/;
function versionToString(version) {
if (isObject(version)) {
try {
return [version.major, version.minor, version.patch].join('.');
} catch (e) {}
}
return version;
}
a = versionToString(a);

@@ -863,1 +885,53 @@ b = versionToString(b);

exports.ltVersion = ltVersion;
/**
* Checks if the engine matches a specifier.
*
* A match specifier is an object of the form:
* {
* name: 'casperjs' | 'phantomjs',
* version: {
* min: Object,
* max: Object
* },
* message: String
* }
*
* Minimal and maximal versions to be matched are determined using
* utils.cmpVersion.
*
* @param Mixed matchSpec a single match specifier object or
* an Array of match specifier objects
* @return Boolean
*/
function matchEngine(matchSpec) {
if (Array !== matchSpec.constructor) {
matchSpec = [matchSpec];
}
var idx;
var len = matchSpec.length;
var engineName = phantom.casperEngine;
var engineVersion = phantom.version;
for (idx = 0; idx < len; ++idx) {
var match = matchSpec[idx];
var version = match.version;
var min = version && version.min;
var max = version && version.max;
if ('*' === min) {
min = null;
}
if ('*' === max) {
max = null;
}
if (match.name === engineName &&
(!min || gteVersion(engineVersion, min)) &&
(!max || !ltVersion(max, engineVersion))
) {
return match;
}
}
return false;
}
exports.matchEngine = matchEngine;

@@ -85,6 +85,2 @@ /*!

this._xml = utils.node('testsuites');
this._xml.toString = function toString() {
var serializer = new XMLSerializer();
return '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(this);
};
}

@@ -125,3 +121,3 @@ exports.XUnitExporter = XUnitExporter;

var testCase = utils.node('testcase', {
name: failure.message || failure.standard,
name: failure.name || failure.message || failure.standard,
classname: generateClassName(failure.file),

@@ -163,2 +159,13 @@ time: utils.ms2seconds(~~failure.time)

/**
* Retrieves generated Xunit XML
*
* @return string
*/
XUnitExporter.prototype.getSerializedXML = function getSerializedXML(xml) {
"use strict";
var serializer = new XMLSerializer();
return '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(this.getXML());
};
/**
* Sets test results.

@@ -165,0 +172,0 @@ *

{
"name": "casperjs",
"description": "A navigation scripting & testing utility for PhantomJS and SlimerJS",
"version": "1.1.0-beta3",
"version": "1.1.0-beta4",
"keywords": [

@@ -18,5 +18,2 @@ "phantomjs",

},
"dependencies": {
"phantomjs": ">=1.8.2"
},
"bugs": {

@@ -23,0 +20,0 @@ "url": "https://github.com/n1k0/casperjs/issues"

@@ -14,7 +14,8 @@ # CasperJS

>
>- ![Build Status](https://travis-ci.org/n1k0/casperjs.png?branch=master) `master` branch
>- [![Build Status](https://travis-ci.org/n1k0/casperjs.png?branch=master)](https://travis-ci.org/n1k0/casperjs) `master` branch
>- 1.0 tests unfortunately have to be run manually using the `casperjs selftest` command
CasperJS is a navigation scripting & testing utility for [PhantomJS](http://www.phantomjs.org/)
and [SlimerJS](http://slimerjs.org/). It eases the process of defining a full navigation
and [SlimerJS](http://slimerjs.org/) (still experimental).
It eases the process of defining a full navigation
scenario and provides useful high-level functions, methods & syntaxic sugar for doing common

@@ -68,7 +69,12 @@ tasks such as:

Need help with getting CasperJS up and running? Got a time-consuming problem you want to get solved quickly?
**Help request**. If you're stuck using CasperJS and don't understand how to achieve something, please [ask on the mailing-list](https://groups.google.com/forum/#!forum/casperjs) first. If the discussion reveals that you have found a real issue that might need a change within CasperJS, file an issue.
Get <a href="http://codersclan.net/?repo_id=32">CasperJS support on CodersClan.</a>
**Filing issues**. It takes a lot of time to review, validate, and de-duplicate filed issues. This time could be spent better on actually improving on CasperJS. Filing an issue might be a helpful contribution, but we expect you to read our [CONTRIBUTING.md](https://github.com/n1k0/casperjs/blob/master/CONTRIBUTING.md) guidelines first.
<a href="http://codersclan.net/?repo_id=32"><img src="http://www.codersclan.net/gs_button/?repo_id=32" width="200"></a>
**Professional Support**. Need help with getting CasperJS up and running? Got a time-consuming problem you want to get solved quickly?
Try to find someone to address your specific problem and [post a reward at bountysource](https://www.bountysource.com).
If you need to have a known issue resolved and don't have the time or skills to do it on your own, you could [post a reward for any open issue directly](https://www.bountysource.com/teams/casperjs/issues).
## Contributing

@@ -75,0 +81,0 @@

@@ -1,3 +0,3 @@

/*jshint strict:false*/
/*global CasperError, console, phantom, require*/
/*eslint strict:0*/
/*global CasperError, console*/

@@ -4,0 +4,0 @@ /**

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, casper, console, phantom, require*/

@@ -3,0 +3,0 @@ /**

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('dubious test', 2, function(test) {

@@ -3,0 +3,0 @@ test.assert(true);

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('true', 1, function(test) {

@@ -3,0 +3,0 @@ test.assert(false);

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError casper console phantom require*/

@@ -3,0 +3,0 @@ casper.start('about:blank', function() {

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('true', 1, function(test) {

@@ -3,0 +3,0 @@ test.assert(true);

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('skipped test', 2, function(test) {

@@ -3,0 +3,0 @@ test.skip(1);

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('step throws', 1, function(test) {

@@ -3,0 +3,0 @@ casper.start();

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/

@@ -4,0 +3,0 @@ casper.options.waitTimeout = 500;

@@ -1,2 +0,1 @@

/*global phantom, casper, patchRequire, require:true*/

@@ -11,2 +10,12 @@ var require = patchRequire(require);

var contentTypes = {
html: {type: 'text/html', binMode: false},
js: {type: 'application/javascript', binMode: false},
json: {type: 'application/json', binMode: false},
txt: {type: 'text/plain', binMode: false},
png: {type: 'image/png', binMode: true},
_default: {type: 'application/octet-stream', binMode: true}
};
var extensionRE = /\.([a-zA-Z]*)$/;
function info(message) {

@@ -18,4 +27,4 @@ "use strict";

service = server.listen(testServerPort, function(request, response) {
/*jshint maxstatements:20*/
"use strict";
/*eslint max-statements:0*/
var requestPath = request.url;

@@ -32,10 +41,14 @@ if (requestPath.indexOf('?') !== -1) {

var headers = {};
var binMode = false;
if (/js$/.test(pageFile)) {
headers['Content-Type'] = "application/javascript";
}
else if (/png$/.test(pageFile)) {
binMode = true;
}
var binMode;
var extension = extensionRE.exec(pageFile);
extension = extension && extension[1];
var contentType = contentTypes[extension] ||
contentTypes._default;
headers['Content-Type'] = contentType.type;
binMode = contentType.binMode;
response.writeHead(200, headers);
if (binMode) {

@@ -42,0 +55,0 @@ response.write(fs.read(pageFile, 'b'));

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
function testUA(ua, match) {

@@ -4,0 +3,0 @@ casper.test.assertMatch(

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('alert events', 1, {

@@ -26,1 +25,20 @@ ok: false,

});
casper.test.begin("Casper.waitForAlert() waits for an alert", 1, function(test) {
casper.start().then(function() {
this.evaluate(function() {
setTimeout(function() {
alert("plop");
}, 500);
});
});
casper.waitForAlert(function(response) {
test.assertEquals(response.data, "plop",
"Casper.waitForAlert() can wait for an alert to be triggered");
});
casper.run(function() {
test.done();
});
});

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false, maxstatements:99*/
/*eslint strict:0, max-statements:0*/

@@ -4,0 +3,0 @@ casper.test.begin('HTTP authentication tests', 8, function(test) {

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('Casper.bypass() can bypass a step', 1, function(test) {

@@ -4,0 +3,0 @@ casper.start();

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('callback events', 1, {

@@ -4,0 +3,0 @@ ok: false,

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('Casper.callUtils()', 2, function(test) {

@@ -4,0 +3,0 @@ casper.start("tests/site/index.html", function(){

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var fs = require('fs');

@@ -4,0 +3,0 @@

/*global casper*/
/*jshint strict:false, maxstatements: 99*/
/*eslint strict:0, max-statements: [1, 99]*/
var utils = require('utils');

@@ -24,8 +24,9 @@

var results = this.getGlobal('results');
if (phantom.casperEngine === 'slimerjs') {
// "javascript:" link in Gecko are executed asynchronously, so we don't have result at this time
test.skip(1)
// "javascript:" link in Gecko are executed asynchronously, so we don't have result at this time
if (!test.skipIfEngine(1, {
name: 'slimerjs',
message: 'Casper.click() on javascript'
})) {
test.assert(results.test1, 'Casper.click() has clicked an `href="javascript:` link');
}
else
test.assert(results.test1, 'Casper.click() has clicked an `href="javascript:` link');
test.assert(results.test2, 'Casper.click() has clicked an `href="#"` link');

@@ -54,9 +55,10 @@ test.assert(results.test3, 'Casper.click() has clicked an `onclick=".*; return false"` link');

var results = this.getGlobal('results');
if (phantom.casperEngine === 'slimerjs') {
// "javascript:" link in Gecko are executed asynchronously, so we don't have result at this time
test.skip(1)
}
else
// "javascript:" link in Gecko are executed asynchronously, so we don't have result at this time
if (!test.skipIfEngine(1, {
name: 'slimerjs',
message: 'Casper.click() on javascript'
})) {
test.assert(results.test1,
'Casper.clickLabel() has clicked an `href="javascript:` link');
}
test.assert(results.test2,

@@ -106,6 +108,6 @@ 'Casper.clickLabel() has clicked an `href="#"` link');

casper.start().then(function() {
this.page.content = '<form><input type="text" name="foo"></form>'
this.click('form input[name=foo]')
this.page.content = '<form><input type="text" name="foo"></form>';
this.click('form input[name=foo]');
this.page.sendEvent('keypress', 'bar');
test.assertEquals(this.getFormValues('form')['foo'], 'bar',
test.assertEquals(this.getFormValues('form').foo, 'bar',
'Casper.click() sets the focus on clicked element');

@@ -117,3 +119,3 @@ }).run(function() {

casper.test.begin('mouse events on click', 2, function(test) {
casper.test.begin('mouse events on click', 3, function(test) {
casper.start('tests/site/click.html', function() {

@@ -127,2 +129,4 @@ this.click('#test5');

'Casper.click() triggers mouseup event');
test.assert(results.test5.indexOf('click') !== -1,
'Casper.click() triggers click event');
}).run(function() {

@@ -132,1 +136,27 @@ test.done();

});
casper.test.begin('mouse events on right click', 1, function(test) {
casper.start('tests/site/click.html', function() {
this.mouse.rightclick('#test5');
}).then(function() {
var results = this.getGlobal('results');
test.assert(results.test5.indexOf('contextmenu') !== -1,
'Casper.rightclick() triggers contextmenu event');
}).run(function() {
test.done();
});
});
casper.test.begin('mouse events on right click with x,y co-ordinates', 1, function(test) {
casper.start('tests/site/click.html', function() {
this.mouse.rightclick(200, 100);
}).then(function() {
var results = this.getGlobal('results');
test.assertEquals(results.testrightclick, [200, 100],
'Mouse.move() has moved to the specified position');
}).run(function() {
test.done();
});
});

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('can confirm dialog', 2, {

@@ -30,3 +29,3 @@ received: undefined,

casper.test.begin('can cancel dialog', {
casper.test.begin('can cancel dialog', 1, {
received: undefined,

@@ -33,0 +32,0 @@

@@ -1,21 +0,33 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var fs = require("fs");
casper.test.begin("Casper.getPageContent() text/html content", 1, function(test) {
casper.start("tests/site/test.html", function() {
test.assertMatch(this.getPageContent(), /<title>CasperJS test target/,
"Casper.getPageContent() retrieves text/html content");
}).run(function() {
test.done();
});
casper.start("tests/site/test.html");
casper.waitForUrl("tests/site/test.html", function() {
test.assertMatch(this.getPageContent(), /<title>CasperJS test target/,
"Casper.getPageContent() retrieves text/html content");
});
casper.run(function() {
test.done();
});
});
casper.test.begin("Casper.getPageContent() non text/html content", 1, function(test) {
casper.start("tests/site/dummy.js", function() {
test.assertEquals(this.getPageContent(), "document.write('foo');",
"Casper.getPageContent() retrieves non text/html content");
}).run(function() {
test.done();
});
casper.test.begin("Casper.getPageContent() non text/html content", 2, function(test) {
// NOTE due to a bug in slimerjs we can only use text/* and
// application/json content here
// https://github.com/laurentj/slimerjs/issues/405
casper.start("tests/site/dummy.json");
casper.waitForUrl("tests/site/dummy.json", function() {
test.assertEquals(this.getPageContent(), '{"dummy":"json"}\n',
"Casper.getPageContent() retrieves application/json content");
});
casper.thenOpen("tests/site/dummy.txt");
casper.waitForUrl("tests/site/dummy.txt", function() {
test.assertEquals(this.getPageContent(), 'some dummy text\n',
"Casper.getPageContent() retrieves text/plain content");
});
casper.run(function() {
test.done();
});
});

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('getHTML() tests', 2, function(test) {

@@ -4,0 +3,0 @@ casper.start('tests/site/index.html', function() {

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var x = require('casper').selectXPath;

@@ -4,0 +3,0 @@

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var fs = require('fs');

@@ -4,0 +3,0 @@

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false, maxparams:99*/
/*eslint strict:0, max-params:0*/
casper.test.begin('mapping argument context', 1, function(test) {

@@ -81,3 +80,3 @@ casper.start();

casper.start().thenEvaluate(function(a, b) {
window.a = a
window.a = a;
window.b = b;

@@ -114,1 +113,20 @@ }, "foo", "bar");

});
// https://github.com/n1k0/casperjs/issues/841
casper.test.begin("evaluate() with js disabled, throws error", 1, function(test) {
casper.options.pageSettings.javascriptEnabled = false;
casper.start().then(function() {
function getListResult() {
return this.evaluate(function() {
return [{a: 1}, {b: 2}];
});
}
test.assertThrows(getListResult, undefined,
"Casper.evaluate() raises an error if JavaScript is disabled in the page");
});
casper.run(function() {
test.done();
casper.options.pageSettings.javascriptEnabled = true;
});
});

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('events', 2, function(test) {

@@ -30,1 +29,17 @@ casper.plopped = false;

});
casper.test.begin('events order', 2, function(test) {
casper.mowed = "Moo";
casper.on("mow", function() {
this.mowed = casper.mowed + " Moo";
});
casper.emit("mow");
test.assertEquals(casper.mowed, "Moo Moo", "mowed has the correct value");
casper.prependListener("mow", function() {
this.mowed = this.mowed + " Boo";
});
casper.emit("mow");
test.assertEquals(casper.mowed, "Moo Moo Boo Moo", "mowed has the correct value");
test.done();
});

@@ -1,7 +0,6 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('exists() tests', 2, function(test) {
casper.start('tests/site/index.html', function() {
test.assert(this.exists('a'), 'Casper.exists() can check if an element exists');
test.assertNot(this.exists('chucknorriz'), 'Casper.exists() can check than an element does not exist')
test.assertNot(this.exists('chucknorriz'), 'Casper.exists() can check than an element does not exist');
}).run(function() {

@@ -8,0 +7,0 @@ test.done();

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('fetchText() basic tests', 1, function(test) {

@@ -12,2 +11,11 @@ casper.start('tests/site/index.html', function() {

casper.test.begin('fetchText() basic tests', 1, function(test) {
casper.start('tests/site/index.html', function() {
test.assertEquals(this.fetchText('input[name="dummy_name"]'), 'dummy_value',
'Casper.fetchText() can retrieve text contents from an input element');
}).run(function() {
test.done();
});
});
casper.test.begin('fetchText() handles HTML entities', 1, function(test) {

@@ -23,1 +31,12 @@ casper.start().then(function() {

});
casper.test.begin('fetchText() handles empty elements', 1, function(test) {
casper.start().then(function() {
this.setContent('<html><body></body></html>');
test.assertEquals(this.fetchText('body'), '',
'Casper.fetchText() fetches empty string');
});
casper.run(function() {
test.done();
});
});

@@ -1,3 +0,2 @@

/*global casper, __utils__*/
/*jshint strict:false*/
/*eslint strict:0*/
var fs = require('fs');

@@ -8,4 +7,4 @@

'can fill an input[type=text] form field');
test.assertField('password', 'chuck',
'can fill an input[type=password] form field')
test.assertField('password', '42',
'can fill an input[type=password] form field');
test.assertField('content', 'Am watching thou',

@@ -15,2 +14,4 @@ 'can fill a textarea form field');

'can pick a value from a select form field');
test.assertField('multitopic', ['bar', 'car'],
'can pick a set of values from a multiselect form field');
test.assertField('check', true,

@@ -32,12 +33,30 @@ 'can check a form checkbox');

function testUrl(test) {
test.assertUrlMatch(/email=chuck@norris.com/, 'input[type=email] field was submitted');
test.assertUrlMatch(/password=chuck/, 'input[type=password] field was submitted');
test.assertUrlMatch(/content=Am\+watching\+thou/, 'textarea field was submitted');
test.assertUrlMatch(/check=on/, 'input[type=checkbox] field was submitted');
test.assertUrlMatch(/choice=no/, 'input[type=radio] field was submitted');
test.assertUrlMatch(/topic=bar/, 'select field was submitted');
test.assertUrlMatch(/strange=very/, 'strangely typed input field was submitted');
casper.waitForUrl(/(^\?|&)submit=submit($|&)/, function() {
test.assertUrlMatch(/email=chuck@norris.com/, 'input[type=email] field was submitted');
test.assertUrlMatch(/password=42/, 'input[type=password] field was submitted');
test.assertUrlMatch(/content=Am\+watching\+thou/, 'textarea field was submitted');
test.assertUrlMatch(/check=on/, 'input[type=checkbox] field was submitted');
test.assertUrlMatch(/choice=no/, 'input[type=radio] field was submitted');
test.assertUrlMatch(/topic=bar/, 'select field was submitted');
test.assertUrlMatch(/multitopic=bar&multitopic=car/, 'multitopic select fields were submitted');
test.assertUrlMatch(/strange=very/, 'strangely typed input field was submitted');
});
}
casper.test.begin('fill() & fillNames() tests', 16, function(test) {
/**
* Known regression in 2.0.0, will be fixed in 2.0.1
* https://github.com/ariya/phantomjs/issues/12506
*/
function skipPhantom200 (test, nb) {
return test.skipIfEngine(nb, {
name: 'phantomjs',
version: {
min: '2.0.0',
max: '2.0.0'
},
message: 'form regression 12506'
});
}
casper.test.begin('fill() & fillNames() tests', 18, function(test) {
var fpath = fs.pathJoin(phantom.casperPath, 'README.md');

@@ -48,3 +67,3 @@

email: 'chuck@norris.com',
password: 'chuck',
password: 42,
content: 'Am watching thou',

@@ -54,2 +73,3 @@ check: true,

topic: 'bar',
multitopic: ['bar', 'car'],
file: fpath,

@@ -60,5 +80,7 @@ 'checklist[]': ['1', '3'],

testFormValues(test);
test.assertEvalEquals(function() {
return __utils__.findOne('input[name="file"]').files.length === 1;
}, true, 'can select a file to upload');
if (!skipPhantom200(test, 1)) {
test.assertEvalEquals(function() {
return __utils__.findOne('input[name="file"]').files.length === 1;
}, true, 'can select a file to upload');
}
});

@@ -73,9 +95,41 @@ casper.thenClick('input[type="submit"]', function() {

casper.test.begin('fillSelectors() tests', 16, function(test) {
casper.test.begin('fillLabels() tests', 18, function(test) {
var fpath = fs.pathJoin(phantom.casperPath, 'README.md');
casper.start('tests/site/form.html', function() {
this.fillLabels('form[action="result.html"]', {
Email: 'chuck@norris.com',
Password: 42,
Content: 'Am watching thou',
Check: true,
No: true,
Topic: 'bar',
Multitopic: ['bar', 'car'],
File: fpath,
"1": true,
"3": true,
Strange: "very"
});
testFormValues(test);
if (!skipPhantom200(test, 1)) {
test.assertEvalEquals(function() {
return __utils__.findOne('input[name="file"]').files.length === 1;
}, true, 'can select a file to upload');
}
});
casper.thenClick('input[type="submit"]', function() {
testUrl(test);
});
casper.run(function() {
test.done();
});
});
casper.test.begin('fillSelectors() tests', 18, function(test) {
var fpath = fs.pathJoin(phantom.casperPath, 'README.md');
casper.start('tests/site/form.html', function() {
this.fillSelectors('form[action="result.html"]', {
"input[name='email']": 'chuck@norris.com',
"input[name='password']": 'chuck',
"input[name='password']": 42,
"textarea[name='content']": 'Am watching thou',

@@ -85,2 +139,3 @@ "input[name='check']": true,

"select[name='topic']": 'bar',
"select[name='multitopic']": ['bar', 'car'],
"input[name='file']": fpath,

@@ -91,5 +146,7 @@ "input[name='checklist[]']": ['1', '3'],

testFormValues(test);
test.assertEvalEquals(function() {
return __utils__.findOne('input[name="file"]').files.length === 1;
}, true, 'can select a file to upload');
if (!skipPhantom200(test, 1)) {
test.assertEvalEquals(function() {
return __utils__.findOne('input[name="file"]').files.length === 1;
}, true, 'can select a file to upload');
}
});

@@ -104,7 +161,7 @@ casper.thenClick('input[type="submit"]', function() {

casper.test.begin('fillXPath() tests', 15, function(test) {
casper.test.begin('fillXPath() tests', 17, function(test) {
casper.start('tests/site/form.html', function() {
this.fillXPath('form[action="result.html"]', {
'//input[@name="email"]': 'chuck@norris.com',
'//input[@name="password"]': 'chuck',
'//input[@name="password"]': 42,
'//textarea[@name="content"]': 'Am watching thou',

@@ -114,2 +171,3 @@ '//input[@name="check"]': true,

'//select[@name="topic"]': 'bar',
'//select[@name="multitopic"]': ['bar', 'car'],
'//input[@name="checklist[]"]': ['1', '3'],

@@ -139,3 +197,3 @@ '//input[@name="strange"]': "very"

casper.test.begin('multiple forms', 2, function(test) {
casper.test.begin('multiple forms', 1, function(test) {
casper.start('tests/site/multiple-forms.html', function() {

@@ -145,5 +203,3 @@ this.fill('form[name="f2"]', {

}, true);
}).then(function() {
test.assertUrlMatch(/\?f=f2&yo=ok$/, 'Casper.fill() handles multiple forms');
}).then(function() {
}).waitForUrl(/\?f=f2&yo=ok$/, function() {
this.fill('form[name="f2"]', {

@@ -168,5 +224,4 @@ yo: "ok"

}, true);
}).then(function() {
test.assertUrlMatch('?foo[bar]=bar&foo[baz]=baz',
'Casper.fill() handles array syntax field names');
}).waitForUrl("?foo[bar]=bar&foo[baz]=baz", function() {
test.pass('Casper.fill() handles array syntax field names');
}).run(function() {

@@ -181,3 +236,10 @@ test.done();

if (phantom.casperEngine === 'phantomjs') {
fileValue = 'C:\\fakepath\\README.md'; // phantomjs/webkit sets that;
if (utils.matchEngine({
name: 'phantomjs',
version: {min: '2.0.0', max: '2.0.0'}
})) {
fileValue = '';
} else {
fileValue = 'C:\\fakepath\\README.md'; // phantomjs/webkit sets that;
}
}

@@ -188,3 +250,3 @@

email: 'chuck@norris.com',
password: 'chuck',
password: 42,
language: 'english',

@@ -195,2 +257,3 @@ content: 'Am watching thou',

topic: 'bar',
multitopic: ['bar', 'car'],
file: fpath,

@@ -209,6 +272,7 @@ 'checklist[]': ['1', '3'],

"file": fileValue,
"password": "chuck",
"password": "42",
"submit": "submit",
"language": "english",
"topic": "bar",
"multitopic": ["bar", "car"],
"strange": "very"

@@ -220,3 +284,3 @@ }, 'Casper.getFormValues() retrieves filled values');

email: 'chuck@norris.com',
password: 'chuck',
password: '42',
language: 'english',

@@ -227,2 +291,3 @@ content: 'Am watching thou',

topic: 'bar',
multitopic: ["bar", "car"],
file: fpath,

@@ -241,6 +306,7 @@ 'checklist[]': ['1', '3'],

"file": fileValue,
"password": "chuck",
"password": "42",
"language": "english",
"submit": "submit",
"topic": "bar",
"multitopic": ["bar", "car"],
"strange": "very"

@@ -253,1 +319,21 @@ }, 'Casper.getFormValues() correctly retrieves values from radio inputs regardless of order');

});
casper.test.begin('fillSelectors() tests', 4, function(test) {
var fpath = fs.pathJoin(phantom.casperPath, 'README.md');
casper.start('tests/site/form.html', function() {
this.fillSelectors('form[action="result.html"]', {
"select[name='topic']": 'baz',
"select[name='multitopic']": ['baz', 'caz'],
});
test.assertField('topic', 'bar', 'can pick a value from a select form field by text value');
test.assertField('multitopic', ['bar', 'car'], 'can pick a set of values from a multiselect form field by text value');
});
casper.thenClick('input[type="submit"]', function() {
test.assertUrlMatch(/topic=bar/, 'select field was submitted');
test.assertUrlMatch(/multitopic=bar&multitopic=car/, 'multitopic select fields were submitted');
});
casper.run(function() {
test.done();
});
});

@@ -1,3 +0,2 @@

/*global casper, __utils__*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('handling frames', 16, function(test) {

@@ -4,0 +3,0 @@ casper.start('tests/site/frames.html');

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('getGLobal() tests', 3, function(test) {

@@ -4,0 +3,0 @@ casper.start('tests/site/global.html', function() {

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var server = require('webserver').create();

@@ -20,3 +19,3 @@ var service = server.listen(8090, function(request, response) {

test.done();
})
});
});

@@ -33,3 +32,3 @@

test.done();
})
});
});

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('handling navigation history', 4, function(test) {

@@ -4,0 +3,0 @@ casper.start('tests/site/page1.html');

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('onStepComplete() hook tests', 1, function(test) {

@@ -4,0 +3,0 @@ var stepResults = [];

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, casper, console, phantom, require*/

@@ -28,3 +28,3 @@ var utils = require('utils');

casper.test.begin('sendKeys() works on content-editable elements', function(test) {
casper.test.begin('sendKeys() works on content-editable elements', 1, function(test) {
casper.start('tests/site/elementattribute.html', function() {

@@ -31,0 +31,0 @@ this.click('#content-editable-div');

@@ -1,4 +0,4 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, casper, console, phantom, require*/
var utils = require('utils')
var utils = require('utils');

@@ -5,0 +5,0 @@ if (utils.ltVersion(phantom.version, '1.8.0')) {

@@ -1,21 +0,25 @@

/*jshint strict:false*/
/*global casper, __utils__*/
/*eslint strict:0*/
casper.test.begin('logging tests', 4, function(test) {
var oldLevel;
casper.start('tests/site/index.html');
var oldLevel = casper.options.logLevel;
casper.then(casper.createStep(function() {
oldLevel = casper.options.logLevel;
casper.options.logLevel = 'info';
casper.options.verbose = false;
casper.options.logLevel = 'info';
casper.options.verbose = false;
}, {skipLog: true}));
casper.log('foo', 'info');
casper.test.assert(casper.result.log.some(function(e) {
return e.message === 'foo' && e.level === 'info';
}), 'Casper.log() adds a log entry');
casper.then(casper.createStep(function() {
casper.log('foo', 'info');
}, {skipLog: true}));
casper.options.logLevel = oldLevel;
casper.options.verbose = true;
casper.then(casper.createStep(function() {
test.assert(casper.result.log.some(function(e) {
return e.message === 'foo' && e.level === 'info';
}), 'Casper.log() adds a log entry');
}, {skipLog: true}));
casper.then(function() {
var oldLevel = casper.options.logLevel;
casper.then(casper.createStep(function() {
casper.options.logLevel = 'debug';

@@ -27,2 +31,5 @@ casper.options.verbose = false;

});
}, {skipLog: true}));
casper.then(casper.createStep(function() {
test.assert(casper.result.log.some(function(e) {

@@ -34,10 +41,10 @@ return e.message === 'debug message' && e.level === 'debug' && e.space === 'remote';

}), 'ClientUtils.log() adds a log entry at a given level');
casper.options.logLevel = oldLevel;
casper.options.verbose = true;
});
test.assertEquals(this.result.log.length, 3, 'Casper.log() logged messages');
}, {skipLog: true}));
casper.run(function() {
test.assertEquals(this.result.log.length, 3, 'Casper.log() logged messages');
test.done();
casper.options.logLevel = oldLevel;
casper.options.verbose = true;
});
});

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false, maxstatements:99*/
/*eslint strict:0, max-statements:0*/
casper.test.begin('mouseEvent() tests', 16, function(test) {

@@ -4,0 +3,0 @@ casper.start('tests/site/mouse-events.html', function() {

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var server = require('webserver').create();

@@ -12,3 +11,3 @@ var service = server.listen(8090, function(request, response) {

casper.test.begin('Link Navigation updates response', function(test) {
casper.test.begin('Link Navigation updates response', 2, function(test) {
casper.start('http://localhost:8090', function(response) {

@@ -33,3 +32,3 @@ casper.click('a');

casper.test.begin('Form Submittal updates the response', function(test) {
casper.test.begin('Form Submittal updates the response', 2, function(test) {
casper.start('http://localhost:8090', function(response) {

@@ -36,0 +35,0 @@ casper.fill('form', {}, true);

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('page.error event tests', 2, function(test) {

@@ -4,0 +3,0 @@ var error = {};

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var usedSettings;

@@ -54,2 +53,22 @@

casper.test.begin('open() (JS disabled) tests', 3, {
setUp: setUp,
tearDown: tearDown,
test: function(test) {
casper.options.pageSettings.javascriptEnabled = false;
casper.open('tests/site/alert.html').then(function() {
test.pass("Casper.open() can open and load a location using GET, with JS disabled");
test.assertEquals(usedSettings, {
method: "get"
}, "Casper.open() used the expected GET settings");
test.assertHttpStatus(200, "Response Code is 200");
});
casper.run(function() {
test.done();
casper.options.pageSettings.javascriptEnabled = true;
});
}
});
casper.test.begin('open() POST tests', 2, {

@@ -103,2 +122,64 @@ setUp: setUp,

casper.test.begin('open() POST json object', 2, {
setUp: setUp,
tearDown: tearDown,
test: function(test) {
casper.open('tests/site/index.html', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
data: {
plop: 42,
chuck: 'norris',
john: {'Doe': 'is here'}
}
}).then(function() {
test.pass("Casper.open() can POST a JSON object");
test.assertEquals(usedSettings, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
data: '{"plop":42,"chuck":"norris","john":{"Doe":"is here"}}'
}, "Casper.open() used the expected POST settings");
});
casper.run(function() {
test.done();
});
}
});
casper.test.begin('open() POST json object with charset info', 2, {
setUp: setUp,
tearDown: tearDown,
test: function(test) {
casper.open('tests/site/index.html', {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
data: {
plop: 42,
chuck: 'norris',
john: {'Doe': 'is here'}
}
}).then(function() {
test.pass("Casper.open() can POST a JSON object");
test.assertEquals(usedSettings, {
method: "POST",
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
data: '{"plop":42,"chuck":"norris","john":{"Doe":"is here"}}'
}, "Casper.open() used the expected POST settings");
});
casper.run(function() {
test.done();
});
}
});
casper.test.begin('open() PUT tests', 2, {

@@ -105,0 +186,0 @@ setUp: setUp,

@@ -1,2 +0,2 @@

/*jshint strict:false, maxstatements:99*/
/*eslint strict:0, max-statements:0*/
/*global CasperError, casper, console, phantom, require*/

@@ -3,0 +3,0 @@ var utils = require('utils');

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('prompt tests', 1, function(test) {

@@ -8,3 +7,3 @@ casper.setFilter('page.prompt', function(message, value) {

casper.start('tests/site/prompt.html', function() {
test.assertEquals(this.getGlobal('name'), 'Chuck Norris', 'prompted value has been received');
test.assertEquals(this.getGlobal('username'), 'Chuck Norris', 'prompted value has been received');
}).run(function() {

@@ -11,0 +10,0 @@ test.done();

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var currentRequest;

@@ -4,0 +3,0 @@

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin("Basic resources tests", 5, function(test) {

@@ -14,3 +13,3 @@ casper.start("tests/site/resources.html", function() {

}, "phantom image found via test Function");
test.assertResourceExists("dummy.js", "phantom image found via test String");
test.assertResourceExists("dummy.js?querystring", "phantom image found via test String");
}, function onTimeout() {

@@ -17,0 +16,0 @@ test.fail("waitForResource timeout occured");

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('remote script includes tests', 4, {

@@ -4,0 +3,0 @@ setUp: function() {

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('Casper.scrollTo()', 2, function(test) {

@@ -4,0 +3,0 @@ casper.start().then(function() {

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('start() tests', 4, function(test) {

@@ -4,0 +3,0 @@ casper.start('tests/site/index.html', function() {

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('steps tests', 8, function(test) {

@@ -4,0 +3,0 @@ casper.start('tests/site/index.html');

@@ -1,25 +0,65 @@

/*global casper*/
/*jshint strict:false*/
casper.test.begin('urls tests', 6, function(test) {
casper.start('tests/site/urls.html', function() {
/*eslint strict:0*/
casper.test.begin('urls tests', 9, function(test) {
var assertURL = function(match, message) {
test.assertHttpStatus(200);
test.assertUrlMatches(match, message);
};
casper.start('tests/site/urls.html#fragment');
casper.waitForUrl(/urls.html/, function() {
assertURL('urls.html', 'Casper.start loads URL with fragment');
test.assertEqual(casper.evaluate(function() {
return location.hash;
}), '#fragment', 'location.hash equals fragment');
});
casper.then(function() {
this.clickLabel('raw unicode', 'a');
});
casper.waitForUrl(/Forlì/,
assertURL.bind(this,
'Forlì',
'Casper.getCurrentUrl() retrieves a raw unicode URL'
));
casper.then(function() {
test.assertHttpStatus(200);
test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves a raw unicode URL');
this.clickLabel('escaped', 'a');
});
casper.waitForUrl(/Farlì/,
assertURL.bind(this,
'Farlì',
'Casper.getCurrentUrl() retrieves an escaped URL'
));
casper.then(function() {
test.assertHttpStatus(200);
test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves an escaped URL');
this.clickLabel('uri encoded', 'a');
});
casper.waitForUrl(/Furlì/,
assertURL.bind(this,
'Furlì',
'Casper.getCurrentUrl() retrieves a decoded URL'
));
casper.run(function() {
test.assertHttpStatus(200);
test.assertUrlMatches('Forlì', 'Casper.getCurrentUrl() retrieves a decoded URL');
test.done();
});
});
// https://github.com/n1k0/casperjs/issues/841
casper.test.begin('url tests with javascript disabled', 1, function(test) {
casper.options.pageSettings.javascriptEnabled = false;
casper.start('tests/site/urls.html');
casper.then(function() {
test.assertMatch(this.getCurrentUrl(), /urls\.html$/,
'Casper.getCurrentUrl() can work, with javascript disabled');
});
casper.run(function() {
test.done();
casper.options.pageSettings.javascriptEnabled = true;
});
});

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var utils = require('utils');

@@ -27,8 +26,8 @@

var imgInfo = this.getElementInfo('img');
if (phantom.casperEngine === "slimerjs" && imgInfo.width !== 800) {
// sometimes, setting viewport could take more time in slimerjs/gecko
// and the image is not still ready: :-/
test.skip(2);
}
else {
// sometimes, setting viewport could take more time in slimerjs/gecko
// and the image is not still ready: :-/
if (!test.skipIfEngine(2, {
name: 'slimerjs',
message: 'Casper.viewport() change test'
})) {
test.assertEquals(imgInfo.width, 800, 'Casper.viewport() changes width asynchronously');

@@ -35,0 +34,0 @@ test.assertEquals(imgInfo.height, 600, 'Casper.viewport() changes height asynchronously');

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('visibility tests', 5, function(test) {

@@ -4,0 +3,0 @@ casper.start('tests/site/visible.html', function() {

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('wait() tests', 1, function(test) {

@@ -4,0 +3,0 @@ var waitStart;

@@ -1,3 +0,2 @@

/*global casper, __utils__*/
/*jshint strict:false*/
/*eslint strict:0*/
var x = require('casper').selectXPath;

@@ -4,0 +3,0 @@

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false, maxstatements:99*/
/*eslint strict:0, max-statements:0*/
var cli = require('cli');

@@ -4,0 +3,0 @@

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var fs = require('fs');

@@ -145,2 +144,31 @@ var x = require('casper').selectXPath;

casper.test.begin('ClientUtils.getElementBounds() page zoom factor tests', 3, function(test) {
casper.start().zoom(2).then(function() {
var html = '<div id="boxes">';
html += ' <div id="b1" style="position:fixed;top:10px;left:11px;width:50px;height:60px"></div>';
html += ' <div style="position:fixed;top:20px;left:21px;width:70px;height:80px"></div>';
html += '</div>';
this.page.content = html;
test.assertEquals(
this.getElementBounds('#b1'),
{ top: 20, left: 22, width: 100, height: 120 },
'ClientUtils.getElementBounds() is aware of the page zoom factor'
);
var bounds = this.getElementsBounds('#boxes div');
test.assertEquals(
bounds[0],
{ top: 20, left: 22, width: 100, height: 120 },
'ClientUtils.getElementsBounds() is aware of the page zoom factor'
);
test.assertEquals(
bounds[1],
{ top: 40, left: 42, width: 140, height: 160 },
'ClientUtils.getElementsBounds() is aware of the page zoom factor'
);
});
casper.run(function() {
test.done();
});
});
casper.test.begin('ClientUtils.getElementInfo() tests', 10, function(test) {

@@ -205,1 +233,21 @@ casper.page.content = '<a href="plop" class="plip plup"><i>paf</i></a>';

});
casper.test.begin('ClientUtils.getElementInfo() visibility tests', 4, function(test) {
casper.page.content = '<a href="plop" class="plip plup" style="display: inline"><i>paf</i></a>';
var info = casper.getElementInfo('a.plip');
test.assert(info.visible, 'ClientUtils.getElementInfo() retrieves element visibility with display inline');
casper.page.content = '<a href="plop" class="plip plup" style="display: inline-block"><i>paf</i></a>';
info = casper.getElementInfo('a.plip');
test.assert(info.visible, 'ClientUtils.getElementInfo() retrieves element visibility with display inline-block');
casper.page.content = '<a href="plop" class="plip plup" style="visibility: hidden"><i>paf</i></a>';
info = casper.getElementInfo('a.plip');
test.assertNot(info.visible, 'ClientUtils.getElementInfo() retrieves element visibility with visibility hidden');
casper.page.content = '<a href="plop" class="plip plup" style="display: none"><i>paf</i></a>';
info = casper.getElementInfo('a.plip');
test.assertNot(info.visible, 'ClientUtils.getElementInfo() retrieves element visibility with display none');
test.done();
});

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var fs = require('fs');

@@ -4,0 +3,0 @@

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
/**

@@ -4,0 +3,0 @@ * Special test server to test for HTTP status codes

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false, maxstatements:99*/
/*eslint strict:0, max-statements:0*/
var pagestack = require('pagestack');

@@ -4,0 +3,0 @@ var utils = require('utils');

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
var fs = require('fs');

@@ -17,12 +16,15 @@ var modroot = fs.pathJoin(phantom.casperPath, 'tests', 'sample_modules');

casper.test.begin('CoffeeScript module loading', 1, function(test) {
var csmod;
try {
csmod = require(fs.pathJoin(modroot, 'csmodule'));
test.assertTrue(csmod.ok, 'require() patched version can load a coffeescript module');
} catch (e) {
test.fail('require() patched version can load a coffeescript module');
}
test.done();
});
// only test if the engine supports coffeescript
if (".coffee" in require.extensions) {
casper.test.begin('CoffeeScript module loading', 1, function(test) {
var csmod;
try {
csmod = require(fs.pathJoin(modroot, 'csmodule'));
test.assertTrue(csmod.ok, 'require() patched version can load a coffeescript module');
} catch (e) {
test.fail('require() patched version can load a coffeescript module');
}
test.done();
});
}

@@ -29,0 +31,0 @@ casper.test.begin('JSON module loading', 1, function(test) {

@@ -1,6 +0,5 @@

/*global casper*/
/*jshint strict:false, maxstatements:99*/
/*eslint strict:0, max-statements:0*/
var fs = require('fs');
casper.test.begin('Common assertions tests', 46, function(test) {
casper.test.begin('Common assertions tests', 47, function(test) {
casper.start('tests/site/index.html', function() {

@@ -43,3 +42,3 @@ test.assertTextExists('form', 'Tester.assertTextExists() checks that page body contains text');

test.assertDoesntExist('foobar', 'Tester.assertDoesntExist() works as expected');
test.assertDoesntExist('foobar', 'Tester.assertNotExist() works as expected [alias]');
test.assertNotExists('foobar', 'Tester.assertNotExists() works as expected [alias]');
// using file:// protocol, HTTP status is always null

@@ -52,8 +51,8 @@ test.assertHttpStatus(200, 'Tester.assertHttpStatus() works as expected');

}, [], 'Tester.assertRaises() works as expected');
test.assertRaise(function() {
throw new Error('plop');
}, [], 'Tester.assertRaise() works as expected [alias]');
test.assertThrows(function() {
throw new Error('plop');
}, [], 'Tester.assertThrows() works as expected [alias]');
try {
test.assertRaises(function() {}, []);
test.fail("Tester.assertRaises() doesn't pass when no error is thrown");
} catch (err) {
test.pass("Tester.assertRaises() doesn't pass when no error is thrown");
}
test.assertResourceExists(/index\.html/, 'Tester.assertResourceExists() works as expected');

@@ -71,2 +70,3 @@ test.assertResourceExist(/index\.html/, 'Tester.assertResourceExist() works as expected [alias]');

test.assertInvisible('p#hidden', 'Tester.assertInvisible() works as expected [alias]');
test.assertExists('div#exports', 'Tester.assertExists() works as expected with reserved word id');
}).run(function() {

@@ -92,3 +92,3 @@ test.done();

test.assertField('choice', null, 'Tester.assertField() works as expected with radios');
test.assertField('topic', 'foo', 'Tester.assertField() works as expected with selects');
test.assertField('topic', '', 'Tester.assertField() works as expected with selects');
test.assertField('file', '', 'Tester.assertField() works as expected with file inputs');

@@ -105,3 +105,10 @@ test.assertField('checklist[]', [], 'Tester.assertField() works as expected with check lists');

if (phantom.casperEngine === 'phantomjs') {
fileValue = 'C:\\fakepath\\README.md'; // phantomjs/webkit sets that;
if (utils.matchEngine({
name: 'phantomjs',
version: {min: '2.0.0', max: '2.0.0'}
})) {
fileValue = '';
} else {
fileValue = 'C:\\fakepath\\README.md'; // phantomjs/webkit sets that;
}
}

@@ -108,0 +115,0 @@

@@ -1,3 +0,2 @@

/*jshint strict:false, eqeqeq:false*/
/*global CasperError, casper, console, phantom, require*/
/*eslint strict:0, eqeqeq:0*/
var steps = [];

@@ -4,0 +3,0 @@

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/

@@ -4,0 +3,0 @@ var setUp, tearDown;

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/

@@ -4,0 +3,0 @@ var setUp, tearDown;

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false*/
/*eslint strict:0*/
casper.test.begin('Skip tests', 4, function(test) {

@@ -4,0 +3,0 @@ test.assert(true, 'First test executed');

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, casper, console, phantom, require*/

@@ -3,0 +3,0 @@ var fs = require('fs');

@@ -1,3 +0,2 @@

/*jshint strict:false, maxstatements:99, maxcomplexity:99*/
/*global CasperError, casper, console, phantom, require*/
/*eslint strict:0, max-statements:0, complexity:0*/

@@ -4,0 +3,0 @@ var TestCaseResult = require('tester').TestCaseResult;

@@ -1,2 +0,2 @@

/*jshint strict:false*/
/*eslint strict:0*/
/*global CasperError, casper, console, phantom, require*/

@@ -3,0 +3,0 @@

@@ -1,3 +0,2 @@

/*global casper*/
/*jshint strict:false, maxstatements:99*/
/*eslint strict:0, max-statements:0*/
var utils = require('utils'),

@@ -318,3 +317,3 @@ t = casper.test,

'plop': false,
'gniii.coffee': true,
'gniii.coffee': '.coffee' in require.extensions,
'script.js': true

@@ -331,3 +330,3 @@ };

casper.test.begin('mergeObjects() tests', 10, function(test) {
/* jshint eqeqeq:false */
/*eslint eqeqeq:0 */
var testCases = [

@@ -334,0 +333,0 @@ {

@@ -1,3 +0,2 @@

/*global casper, __utils__*/
/*jshint strict:false*/
/*eslint strict:0*/
var tester = require('tester');

@@ -10,3 +9,3 @@ var testpage = require('webpage').create();

xunit.setResults(results);
test.assertTruthy(xunit.getXML());
test.assertTruthy(xunit.getSerializedXML());
test.done();

@@ -29,3 +28,3 @@ });

xunit.setResults(results);
casper.start().setContent(xunit.getXML());
casper.start().setContent(xunit.getSerializedXML());
test.assertEvalEquals(function() {

@@ -55,3 +54,3 @@ return __utils__.findAll('testsuite').length;

xunit.setResults(results);
casper.start().setContent(xunit.getXML());
casper.start().setContent(xunit.getSerializedXML());
test.assertExists('testsuite[name="foo"][package="foo"][tests="1"][failures="0"] testcase[name="footext"]');

@@ -76,3 +75,3 @@ test.done();

xunit.setResults(results);
casper.start().setContent(xunit.getXML());
casper.start().setContent(xunit.getSerializedXML());
test.assertExists('testsuite[name="foo"][package="foo"][tests="1"][failures="1"] testcase[name="footext"] failure[type="footype"]');

@@ -82,1 +81,23 @@ test.assertEquals(casper.getElementInfo('failure[type="footype"]').text, 'footext');

});
casper.test.begin('XUnitReporter() can handle custom name attribute for a test case', 2, function suite(test) {
var xunit = require('xunit').create();
var results = new tester.TestSuiteResult();
var suite1 = new tester.TestCaseResult({
name: 'foo',
file: '/foo'
});
suite1.addFailure({
success: false,
type: "footype",
message: "footext",
file: "/foo",
name: "foo bar baz"
});
results.push(suite1);
xunit.setResults(results);
casper.start().setContent(xunit.getSerializedXML());
test.assertExists('testsuite[name="foo"][package="foo"][tests="1"][failures="1"] testcase[name="foo bar baz"] failure[type="footype"]');
test.assertEquals(casper.getElementInfo('failure[type="footype"]').text, 'footext');
test.done();
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc