Commit a6d2a59a a6d2a59aefd2eecbf90e486d69198148ca779ebe by Nicolas Perriault

added toString() and status() to Casper prototype

1 parent b75fed22
......@@ -27,6 +27,7 @@ XXXX-XX-XX, v1.0.0
- fixed [#222](https://github.com/n1k0/casperjs/pull/222) & [#211](https://github.com/n1k0/casperjs/issues/211) - Change mouse event to include an X + Y value for click position
- fixed [#232](https://github.com/n1k0/casperjs/issues/232) - symlink resolution in the ruby version of the `casperjs` executable
- added [`ClientUtils.getDocumentHeight()`](http://casperjs.org/api.html#clientutils.getDocumentHeight)
- added [`toString()`](http://casperjs.org/api.html#casper.toString) and [`status()`](http://casperjs.org/api.html#casper.status) methods to `Casper` prototype.
2012-06-26, v1.0.0-RC1
----------------------
......
......@@ -40,6 +40,16 @@ if (!phantom || phantom.version.major !== 1 || phantom.version.minor < 5) {
bootstrap(window);
}
// Polyfills
if (typeof Function.prototype.bind !== "function") {
Function.prototype.bind = function(scope) {
var _function = this;
return function() {
return _function.apply(scope, arguments);
};
};
}
function bootstrap(global) {
"use strict";
/**
......
Subproject commit c535352bdd9db9574bd1d101b063af586b6979f4
Subproject commit bdbd9e202a92a420a3fc50b464ef73d13a0cdc83
......
......@@ -1304,6 +1304,32 @@ Casper.prototype.thenOpenAndEvaluate = function thenOpenAndEvaluate(location, fn
};
/**
* Returns a string representation of current instance
*
* @return String
*/
Casper.prototype.toString = function toString() {
return '[object Casper], currently at ' + this.getCurrentUrl();
};
/**
* Returns the current status of current instance
*
* @param Boolean asString Export status object as string
* @return Object
*/
Casper.prototype.status = function status(asString) {
var properties = ['currentHTTPStatus', 'defaultWaitTimeout', 'loadInProgress', 'navigationRequested',
'options', 'pendingWait', 'requestUrl', 'started', 'step', 'url'];
var currentStatus = {};
properties.forEach(function(property) {
console.log(this[property]);
currentStatus[property] = this[property];
}.bind(this));
return asString === true ? utils.dump(currentStatus) : currentStatus;
};
/**
* Sets the user-agent string currently used when requesting urls.
*
* @param String userAgent User agent string
......