Commit c49f8a79 c49f8a79ea89c5b8c3c08e57451beeee897ab6ad by Nicolas Perriault

Merge pull request #924 from n1k0/bug-919-native-reload

Native use of phantomjs WebPage#reload()
2 parents c81d79d6 c447f791
...@@ -1436,9 +1436,8 @@ Casper.prototype.open = function open(location, settings) { ...@@ -1436,9 +1436,8 @@ Casper.prototype.open = function open(location, settings) {
1436 Casper.prototype.reload = function reload(then) { 1436 Casper.prototype.reload = function reload(then) {
1437 "use strict"; 1437 "use strict";
1438 this.checkStarted(); 1438 this.checkStarted();
1439 // window.location.reload() is broken under phantomjs
1440 this.then(function() { 1439 this.then(function() {
1441 this.open(this.getCurrentUrl()); 1440 this.page.reload();
1442 }); 1441 });
1443 if (utils.isFunction(then)) { 1442 if (utils.isFunction(then)) {
1444 this.then(this.createStep(then)); 1443 this.then(this.createStep(then));
......
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
37 (function () { 37 (function () {
38 'use strict'; 38 'use strict';
39 39
40 // Force fields initialization
41 document.querySelector("input[name=email]").value = "";
42
40 // El-cheapo autocomplete 43 // El-cheapo autocomplete
41 44
42 var choices = [ 45 var choices = [
......
1 /*global casper*/
2 /*jshint strict:false, maxstatements: 99*/
3
4 casper.test.begin('reload() tests', 3, function(test) {
5 var formUrl = 'tests/site/form.html';
6
7 casper.start(formUrl, function() {
8 this.fill("form", {email: "foo@foo.com"}, false);
9 });
10 casper.once("page.resource.requested", function(resource) {
11 test.assert(resource.url.indexOf(formUrl) > 0);
12 }).reload(function() {
13 test.assertUrlMatches(formUrl);
14 test.assertField("email", "");
15 }).run(function() {
16 test.done();
17 });
18 });