This is an automated email from the ASF dual-hosted git repository.

shazron pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git


The following commit(s) were added to refs/heads/master by this push:
     new d44cec6  CB-13093: (iOS) Infinite looping when stressing navigation 
(#328)
d44cec6 is described below

commit d44cec6266f5890802268e996722a380a0e51927
Author: Luís Silva <luis.si...@outsystems.com>
AuthorDate: Tue Aug 8 22:40:40 2017 +0100

    CB-13093: (iOS) Infinite looping when stressing navigation (#328)
    
    * CB-13093: (iOS) Infinite looping when stressing navigation
    
    * CB-13093: added a unit test to reproduce the issue
---
 .../Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m   |  9 ++++-----
 tests/CordovaLibTests/CDVWebViewDelegateTests.m         | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git 
a/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m 
b/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m
index 0af97df..6769121 100644
--- 
a/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m
+++ 
b/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m
@@ -256,11 +256,10 @@ static NSString *stripFragment(NSString* url)
                         NSLog(@"%@", description);
                         _loadCount = 0;
                         _state = STATE_WAITING_FOR_LOAD_START;
-                        if ([_delegate 
respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
-                            NSDictionary* errorDictionary = 
@{NSLocalizedDescriptionKey : description};
-                            NSError* error = [[NSError alloc] 
initWithDomain:@"CDVUIWebViewDelegate" code:1 userInfo:errorDictionary];
-                            [_delegate webView:webView 
didFailLoadWithError:error];
-                        }
+                                
+                        NSDictionary* errorDictionary = 
@{NSLocalizedDescriptionKey : description};
+                        NSError* error = [[NSError alloc] 
initWithDomain:@"CDVUIWebViewDelegate" code:1 userInfo:errorDictionary];
+                        [self webView:webView didFailLoadWithError:error];
                     }
             }
         } else {
diff --git a/tests/CordovaLibTests/CDVWebViewDelegateTests.m 
b/tests/CordovaLibTests/CDVWebViewDelegateTests.m
index d47f4a0..55b8ecf 100644
--- a/tests/CordovaLibTests/CDVWebViewDelegateTests.m
+++ b/tests/CordovaLibTests/CDVWebViewDelegateTests.m
@@ -47,6 +47,8 @@
 // expose private interface
 - (BOOL)shouldLoadRequest:(NSURLRequest*)request;
 
+-(BOOL)webView:(UIWebView*)webView 
shouldStartLoadWithRequest:(NSURLRequest*)request 
navigationType:(UIWebViewNavigationType)navigationType;
+
 @end
 
 @interface CDVWebViewDelegateTests : XCTestCase
@@ -64,6 +66,21 @@
     [super tearDown];
 }
 
+- (void)testShouldLoadRequestWithStateWaitForStart
+{
+    NSInteger initialState = 1; // STATE_WAITING_FOR_LOAD_START;
+    NSInteger expectedState = 0; // STATE_IDLE;
+    
+    CDVWebViewDelegate2* wvd = [[CDVWebViewDelegate2 alloc] 
initWithDelegate:nil]; // not really testing delegate handling
+    wvd.state = initialState;
+    
+    // Testing a top-level navigation
+    [wvd webView:[UIWebView new] shouldStartLoadWithRequest:nil 
navigationType:UIWebViewNavigationTypeLinkClicked];
+    
+    XCTAssertTrue(wvd.state == expectedState, @"If the navigation started with 
state STATE_WAITING_FOR_LOAD_START then it must fail and the state should be 
STATE_IDLE");
+}
+
+
 - (void)testFailLoadStateCancelled
 {
     NSInteger initialState = 1; // STATE_WAITING_FOR_LOAD_START;

-- 
To stop receiving notification emails like this one, please contact
['"commits@cordova.apache.org" <commits@cordova.apache.org>'].

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to