[Webkit-unassigned] [Bug 135446] New: Exception causing crash in UIWebView iOS 8 Beta

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jul 30 18:18:37 PDT 2014


https://bugs.webkit.org/show_bug.cgi?id=135446

           Summary: Exception causing crash in UIWebView iOS 8 Beta
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: iOS
        OS/Version: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: New Bugs
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: zack.ulrich at ensighten.com


Created an attachment (id=235789)
 --> (https://bugs.webkit.org/attachment.cgi?id=235789&action=review)
Stack trace from crash

I was testing out calling some Javascript with my iOS app and noticed that I could crash the app by causing an exception. The JS that I'm calling is attached below as well as the objective c code that I'm using to call it. 

I'm calling a named autoexecuting function which just has a generic try catch inside. The second time the function executes and the exception is caused the app crashes. 

I tested this same function using the new WKWebView and it doesn't crash the app but it seems to crash my the webview, I can't execute anything on it the second time the function runs.

I've run this code on iOS 7 and it doesn't cause a crash.




function ActivateDemo() {

        this.testFunction = function()
        {
            if (document.body.style.backgroundColor == "red") 
            {
                document.body.style.backgroundColor="blue";
            }
            else
            {
                document.body.style.backgroundColor="red";
            }

            (function namedFunc() {
            try{
                eval("console.log('hey from function'aa')")
            }
            catch(e)
            {
                console.log('exception ' + e)
            }
            })();
        }
    }
    var AD = window.AD = new ActivateDemo();



////objc code //////////////

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.


    NSString *fullURL = @"http://10.20.11.166/testWeb.html";
    NSURL *url = [NSURL URLWithString:fullURL];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    self.wkTest = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
    [self.view addSubview:self.wkTest];
    [self.wkTest loadRequest:requestObj];

    self.testButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 350, 50, 50)];

    [self.testButton setBackgroundColor:[UIColor blueColor]];

    [self.testButton setTitle:@"Test" forState:UIControlStateNormal];

    [self.testButton addTarget:self action:@selector(testBut) forControlEvents:UIControlEventTouchUpInside];

    self.testWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 400, 100, 300)];

    [self.view addSubview:self.testWebView];

    [self.testWebView loadRequest:requestObj];

    [self.view addSubview:self.testButton];
}

-(void)testBut
{
    [self.wkTest evaluateJavaScript:@"AD.testFunction()" completionHandler:nil];

    [self.testWebView stringByEvaluatingJavaScriptFromString:@"AD.testFunction();"];

}

//

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list