From 953e709db3e3567e66670a995ac3ed14f9010d95 Mon Sep 17 00:00:00 2001 From: pbenschop Date: Mon, 29 Sep 2014 17:31:30 -0700 Subject: [PATCH] CDVWebViewDelegate fails to update the webview state properly in iOS when a page loads an iframe using javascript and does a redirect to another page using javascript. Method didFailLoadWithError gets called while in STATE_WAITING_FOR_LOAD_START with a NSURLErrorCancelled (-999) error. Instead of entering STATE_CANCELLED in this situation it always enters STATE_IDLE, which causes didFailLoadWithError event to never fire (which depending on the app, and definitely in our case, can cause a hang condition). For a simplified Cordova project that reproduces the problem in the most straigtforward way possible, please refer to: https://github.com/greatvines/cordova-webview-state-bug-www --- CordovaLib/Classes/CDVWebViewDelegate.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CordovaLib/Classes/CDVWebViewDelegate.m b/CordovaLib/Classes/CDVWebViewDelegate.m index cdc3980e32..5a187f400f 100644 --- a/CordovaLib/Classes/CDVWebViewDelegate.m +++ b/CordovaLib/Classes/CDVWebViewDelegate.m @@ -378,7 +378,11 @@ - (void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error break; case STATE_WAITING_FOR_LOAD_START: - _state = STATE_IDLE; + if ([error code] == NSURLErrorCancelled) { + _state = STATE_CANCELLED; + } else { + _state = STATE_IDLE; + } fireCallback = YES; break;