Fixes an infinite loop with checkStep
the navigationRequested boolean should be false when the new URL has only a difference on the hash part with the previous URL, because in this case we don't have a loadStarted/loadFinished event (at least with Gecko) and then navigationRequested cannot be turn into false. The consequence is that checkStep doesn't execute the next step because of its test on navigationRequested.
Showing
1 changed file
with
16 additions
and
0 deletions
... | @@ -2408,6 +2408,22 @@ function createPage(casper) { | ... | @@ -2408,6 +2408,22 @@ function createPage(casper) { |
2408 | url, type, willNavigate, isMainFrame), "debug"); | 2408 | url, type, willNavigate, isMainFrame), "debug"); |
2409 | casper.browserInitializing = false; | 2409 | casper.browserInitializing = false; |
2410 | if (isMainFrame && casper.requestUrl !== url) { | 2410 | if (isMainFrame && casper.requestUrl !== url) { |
2411 | var currentUrl = casper.requestUrl; | ||
2412 | var newUrl = url; | ||
2413 | var pos = currentUrl.indexOf('#') | ||
2414 | if (pos !== -1) { | ||
2415 | currentUrl = currentUrl.substring(0, pos); | ||
2416 | } | ||
2417 | pos = newUrl.indexOf('#') | ||
2418 | if (pos !== -1) { | ||
2419 | newUrl = newUrl.substring(0, pos); | ||
2420 | } | ||
2421 | // for URLs that are only different by their hash part | ||
2422 | // don't turn navigationRequested to true, because | ||
2423 | // there will not be loadStarted, loadFinished events | ||
2424 | // so it could cause issues (for exemple, checkStep that | ||
2425 | // do no execute the next step -> infinite loop on checkStep) | ||
2426 | if (currentUrl !== newUrl) | ||
2411 | casper.navigationRequested = true; | 2427 | casper.navigationRequested = true; |
2412 | 2428 | ||
2413 | if (willNavigate) { | 2429 | if (willNavigate) { | ... | ... |
-
Please register or sign in to post a comment