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 ...@@ -27,6 +27,7 @@ XXXX-XX-XX, v1.0.0
27 - 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 27 - 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
28 - fixed [#232](https://github.com/n1k0/casperjs/issues/232) - symlink resolution in the ruby version of the `casperjs` executable 28 - fixed [#232](https://github.com/n1k0/casperjs/issues/232) - symlink resolution in the ruby version of the `casperjs` executable
29 - added [`ClientUtils.getDocumentHeight()`](http://casperjs.org/api.html#clientutils.getDocumentHeight) 29 - added [`ClientUtils.getDocumentHeight()`](http://casperjs.org/api.html#clientutils.getDocumentHeight)
30 - added [`toString()`](http://casperjs.org/api.html#casper.toString) and [`status()`](http://casperjs.org/api.html#casper.status) methods to `Casper` prototype.
30 31
31 2012-06-26, v1.0.0-RC1 32 2012-06-26, v1.0.0-RC1
32 ---------------------- 33 ----------------------
......
...@@ -40,6 +40,16 @@ if (!phantom || phantom.version.major !== 1 || phantom.version.minor < 5) { ...@@ -40,6 +40,16 @@ if (!phantom || phantom.version.major !== 1 || phantom.version.minor < 5) {
40 bootstrap(window); 40 bootstrap(window);
41 } 41 }
42 42
43 // Polyfills
44 if (typeof Function.prototype.bind !== "function") {
45 Function.prototype.bind = function(scope) {
46 var _function = this;
47 return function() {
48 return _function.apply(scope, arguments);
49 };
50 };
51 }
52
43 function bootstrap(global) { 53 function bootstrap(global) {
44 "use strict"; 54 "use strict";
45 /** 55 /**
......
1 Subproject commit c535352bdd9db9574bd1d101b063af586b6979f4 1 Subproject commit bdbd9e202a92a420a3fc50b464ef73d13a0cdc83
......
...@@ -1304,6 +1304,32 @@ Casper.prototype.thenOpenAndEvaluate = function thenOpenAndEvaluate(location, fn ...@@ -1304,6 +1304,32 @@ Casper.prototype.thenOpenAndEvaluate = function thenOpenAndEvaluate(location, fn
1304 }; 1304 };
1305 1305
1306 /** 1306 /**
1307 * Returns a string representation of current instance
1308 *
1309 * @return String
1310 */
1311 Casper.prototype.toString = function toString() {
1312 return '[object Casper], currently at ' + this.getCurrentUrl();
1313 };
1314
1315 /**
1316 * Returns the current status of current instance
1317 *
1318 * @param Boolean asString Export status object as string
1319 * @return Object
1320 */
1321 Casper.prototype.status = function status(asString) {
1322 var properties = ['currentHTTPStatus', 'defaultWaitTimeout', 'loadInProgress', 'navigationRequested',
1323 'options', 'pendingWait', 'requestUrl', 'started', 'step', 'url'];
1324 var currentStatus = {};
1325 properties.forEach(function(property) {
1326 console.log(this[property]);
1327 currentStatus[property] = this[property];
1328 }.bind(this));
1329 return asString === true ? utils.dump(currentStatus) : currentStatus;
1330 };
1331
1332 /**
1307 * Sets the user-agent string currently used when requesting urls. 1333 * Sets the user-agent string currently used when requesting urls.
1308 * 1334 *
1309 * @param String userAgent User agent string 1335 * @param String userAgent User agent string
......