Skip to content

Commit

Permalink
Revert "CB-14045 - Reinit url after app freezes (apache#363)"
Browse files Browse the repository at this point in the history
This reverts commit 6b3f10f.
  • Loading branch information
shazron committed May 16, 2018
1 parent 6b3f10f commit 00a4b27
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 54 deletions.
24 changes: 0 additions & 24 deletions CordovaLib/Classes/Public/CDVViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -720,33 +720,12 @@ - (void)onAppWillTerminate:(NSNotification*)notification
}
}

- (bool)isUrlEmpty:(NSURL *)url
{
if (!url || (url == (id) [NSNull null])) {
return true;
}
NSString *urlAsString = [url absoluteString];
return (urlAsString == (id) [NSNull null] || [urlAsString length]==0 || [urlAsString isEqualToString:@"about:blank"]);
}

- (bool)checkAndReinitViewUrl
{
NSURL* appURL = [self appUrl];
if ([self isUrlEmpty: [self.webViewEngine URL]] && ![self isUrlEmpty: appURL]) {
NSURLRequest* appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
[self.webViewEngine loadRequest:appReq];
return true;
}
return false;
}

/*
This method is called to let your application know that it is about to move from the active to inactive state.
You should use this method to pause ongoing tasks, disable timer, ...
*/
- (void)onAppWillResignActive:(NSNotification*)notification
{
[self checkAndReinitViewUrl];
// NSLog(@"%@",@"applicationWillResignActive");
[self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resign');" scheduledOnRunLoop:NO];
}
Expand All @@ -758,7 +737,6 @@ - (void)onAppWillResignActive:(NSNotification*)notification
*/
- (void)onAppWillEnterForeground:(NSNotification*)notification
{
[self checkAndReinitViewUrl];
// NSLog(@"%@",@"applicationWillEnterForeground");
[self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resume');"];

Expand All @@ -773,7 +751,6 @@ - (void)onAppWillEnterForeground:(NSNotification*)notification
// This method is called to let your application know that it moved from the inactive to active state.
- (void)onAppDidBecomeActive:(NSNotification*)notification
{
[self checkAndReinitViewUrl];
// NSLog(@"%@",@"applicationDidBecomeActive");
[self.commandDelegate evalJs:@"cordova.fireDocumentEvent('active');"];
}
Expand All @@ -784,7 +761,6 @@ - (void)onAppDidBecomeActive:(NSNotification*)notification
*/
- (void)onAppDidEnterBackground:(NSNotification*)notification
{
[self checkAndReinitViewUrl];
// NSLog(@"%@",@"applicationDidEnterBackground");
[self.commandDelegate evalJs:@"cordova.fireDocumentEvent('pause', null, true);" scheduledOnRunLoop:NO];
}
Expand Down
30 changes: 0 additions & 30 deletions tests/CordovaLibTests/CDVViewControllerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ @interface CDVViewControllerTest : XCTestCase

@end

@interface CDVViewController ()

// expose private interface
- (bool)checkAndReinitViewUrl;
- (bool)isUrlEmpty:(NSURL*)url;

@end

@implementation CDVViewControllerTest

-(CDVViewController*)viewController{
Expand Down Expand Up @@ -97,27 +89,5 @@ -(void)testColorFromColorString{
XCTAssertNil([viewController colorFromColorString:@"#NOTHEX"]);
}

-(void)testIsUrlEmpty{
CDVViewController* viewController = [self viewController];
XCTAssertTrue([viewController isUrlEmpty:(id)[NSNull null]]);
XCTAssertTrue([viewController isUrlEmpty:nil]);
XCTAssertTrue([viewController isUrlEmpty:[NSURL URLWithString:@""]]);
XCTAssertTrue([viewController isUrlEmpty:[NSURL URLWithString:@"about:blank"]]);
}

-(void)testIfItLoadsAppUrlIfCurrentViewIsBlank{
CDVViewController* viewController = [self viewController];

NSString* appUrl = @"about:blank";
NSString* html = @"<html><body></body></html>";
[viewController.webViewEngine loadHTMLString:html baseURL:[NSURL URLWithString:appUrl]];
XCTAssertFalse([viewController checkAndReinitViewUrl]);

appUrl = @"https://cordova.apache.org";
viewController.startPage = appUrl;
[viewController.webViewEngine loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:appUrl]]];
XCTAssertTrue([viewController checkAndReinitViewUrl]);
}

@end

0 comments on commit 00a4b27

Please sign in to comment.