Commit 947f1baf 947f1baffe0b45a1964973e3705048073df43c22 by Nicolas Perriault

fixes #644 - better handling of deleted page objects

1 parent effe51a5
...@@ -938,9 +938,16 @@ Casper.prototype.getPageContent = function getPageContent() { ...@@ -938,9 +938,16 @@ Casper.prototype.getPageContent = function getPageContent() {
938 Casper.prototype.getCurrentUrl = function getCurrentUrl() { 938 Casper.prototype.getCurrentUrl = function getCurrentUrl() {
939 "use strict"; 939 "use strict";
940 this.checkStarted(); 940 this.checkStarted();
941 try {
941 return utils.decodeUrl(this.evaluate(function _evaluate() { 942 return utils.decodeUrl(this.evaluate(function _evaluate() {
942 return document.location.href; 943 return document.location.href;
943 })); 944 }));
945 } catch (e) {
946 // most likely the current page object has been "deleted" (think closed popup)
947 if (/deleted QObject/.test(e.message))
948 return "";
949 throw e;
950 }
944 }; 951 };
945 952
946 /** 953 /**
......