Updated Branches: refs/heads/master 2d5e3c88c -> 89f165e00
[CB-3567] Redirect initiated in JavaScript fails the app from loading Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/89f165e0 Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/89f165e0 Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/89f165e0 Branch: refs/heads/master Commit: 89f165e00cf2a2dd8596e398279084bd01585f1e Parents: 2d5e3c8 Author: Thomas @ BeeDesk <[email protected]> Authored: Wed May 29 01:47:21 2013 -0700 Committer: Shazron Abdullah <[email protected]> Committed: Thu Jul 11 16:55:21 2013 -0700 ---------------------------------------------------------------------- CordovaLib/Classes/CDVWebViewDelegate.m | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/89f165e0/CordovaLib/Classes/CDVWebViewDelegate.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVWebViewDelegate.m b/CordovaLib/Classes/CDVWebViewDelegate.m index 7254c2e..8d5ec2a 100644 --- a/CordovaLib/Classes/CDVWebViewDelegate.m +++ b/CordovaLib/Classes/CDVWebViewDelegate.m @@ -87,7 +87,8 @@ typedef enum { STATE_WAITING_FOR_LOAD_START, STATE_WAITING_FOR_LOAD_FINISH, STATE_IOS5_POLLING_FOR_LOAD_START, - STATE_IOS5_POLLING_FOR_LOAD_FINISH + STATE_IOS5_POLLING_FOR_LOAD_FINISH, + STATE_CANCELLED } State; @implementation CDVWebViewDelegate @@ -277,6 +278,12 @@ typedef enum { [self pollForPageLoadStart:webView]; break; + case STATE_CANCELLED: + fireCallback = YES; + _state = STATE_WAITING_FOR_LOAD_FINISH; + _loadCount += 1; + break; + case STATE_WAITING_FOR_LOAD_START: if (_loadCount != 0) { NSLog(@"CDVWebViewDelegate: Unexpected loadCount in didStart. count=%d", _loadCount); @@ -356,11 +363,17 @@ typedef enum { break; case STATE_WAITING_FOR_LOAD_FINISH: - if (_loadCount == 1) { - _state = STATE_IDLE; + if([error code] != NSURLErrorCancelled) { + if (_loadCount == 1) { + _state = STATE_IDLE; + fireCallback = YES; + } + _loadCount = -1; + } else { fireCallback = YES; + _state = STATE_CANCELLED; + _loadCount -= 1; } - _loadCount = -1; break; case STATE_IOS5_POLLING_FOR_LOAD_START:
