Skip to content

Commit

Permalink
Add test case for issue ariya#13114
Browse files Browse the repository at this point in the history
  • Loading branch information
cdroulers committed Apr 20, 2015
1 parent d3ed8e8 commit a18eab4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/regression/issue13114/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<body>
<script>
setTimeout(function () {
window.location.replace("http://localhost:8001/index2.html");
}, 2500);
</script>
TEST will redirect
</body>
</html>
5 changes: 5 additions & 0 deletions test/regression/issue13114/index2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
TEST2
</body>
</html>
40 changes: 40 additions & 0 deletions test/regression/issue13114/issue13114.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var system = require("system");
var webpage = require("webpage");

var myurl = 'http://localhost:8000/';

var renderPage = function (url) {
page = webpage.create();

page.onNavigationRequested = function (url, type, willNavigate, main) {
if (main && url != myurl) {
myurl = url;
console.log("redirect caught")
page.close()
renderPage(url);
}
};

page.onResourceError = function (resourceError) {
page.reason = resourceError.errorString;
page.reason_url = resourceError.url;
console.log(page.reason);
console.log(page.reason_url);
};

page.open(url, function (status) {
if (status === "success") {
var port = url.substring(17, 21);
console.log("success", port)
page.render('yourscreenshot' + port + '.png');
if (port === 8001) {
phantom.exit(0);
}
} else {
console.log("failed", url)
phantom.exit(1);
}
});
}

renderPage(myurl);

0 comments on commit a18eab4

Please sign in to comment.