Commit 37bdd108 37bdd108884d2859fd9df1c7549670d8fdb03b75 by Chris Lorenzo

Fix for when the url is changed via javascript

1 parent 5ed461e8
...@@ -117,6 +117,7 @@ var Casper = function Casper(options) { ...@@ -117,6 +117,7 @@ var Casper = function Casper(options) {
117 this.defaultWaitTimeout = 5000; 117 this.defaultWaitTimeout = 5000;
118 this.history = []; 118 this.history = [];
119 this.loadInProgress = false; 119 this.loadInProgress = false;
120 this.navigationRequested = false;
120 this.logFormats = {}; 121 this.logFormats = {};
121 this.logLevels = ["debug", "info", "warning", "error"]; 122 this.logLevels = ["debug", "info", "warning", "error"];
122 this.logStyles = { 123 this.logStyles = {
...@@ -316,7 +317,7 @@ Casper.prototype.captureSelector = function captureSelector(targetFile, selector ...@@ -316,7 +317,7 @@ Casper.prototype.captureSelector = function captureSelector(targetFile, selector
316 */ 317 */
317 Casper.prototype.checkStep = function checkStep(self, onComplete) { 318 Casper.prototype.checkStep = function checkStep(self, onComplete) {
318 "use strict"; 319 "use strict";
319 if (self.pendingWait || self.loadInProgress) { 320 if (self.pendingWait || self.loadInProgress || self.navigationRequested) {
320 return; 321 return;
321 } 322 }
322 var step = self.steps[self.step++]; 323 var step = self.steps[self.step++];
...@@ -1667,6 +1668,9 @@ function createPage(casper) { ...@@ -1667,6 +1668,9 @@ function createPage(casper) {
1667 page.onNavigationRequested = function onNavigationRequested(url, navigationType, navigationLocked, isMainFrame) { 1668 page.onNavigationRequested = function onNavigationRequested(url, navigationType, navigationLocked, isMainFrame) {
1668 casper.log(f('Navigation requested: url=%s, type=%s, lock=%s, isMainFrame=%s', 1669 casper.log(f('Navigation requested: url=%s, type=%s, lock=%s, isMainFrame=%s',
1669 url, navigationType, navigationLocked, isMainFrame), "debug"); 1670 url, navigationType, navigationLocked, isMainFrame), "debug");
1671 if(isMainFrame) {
1672 casper.navigationRequested = true;
1673 }
1670 casper.emit('navigation.requested', url, navigationType, navigationLocked, isMainFrame); 1674 casper.emit('navigation.requested', url, navigationType, navigationLocked, isMainFrame);
1671 }; 1675 };
1672 page.onPrompt = function onPrompt(message, value) { 1676 page.onPrompt = function onPrompt(message, value) {
...@@ -1701,6 +1705,7 @@ function createPage(casper) { ...@@ -1701,6 +1705,7 @@ function createPage(casper) {
1701 }; 1705 };
1702 page.onUrlChanged = function onUrlChanged(url) { 1706 page.onUrlChanged = function onUrlChanged(url) {
1703 casper.log(f('url changed to "%s"', url), "debug"); 1707 casper.log(f('url changed to "%s"', url), "debug");
1708 casper.navigationRequested = false;
1704 casper.emit('url.changed', url); 1709 casper.emit('url.changed', url);
1705 }; 1710 };
1706 casper.emit('page.created', page); 1711 casper.emit('page.created', page);
......