Bug 173235 - WKNavigationAction.sourceFrame is not annotated as nullable, causing it to crash when accessed from Swift
Summary: WKNavigationAction.sourceFrame is not annotated as nullable, causing it to cr...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: All Other
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-06-11 04:25 PDT by Matt Curtis
Modified: 2017-06-13 12:48 PDT (History)
5 users (show)

See Also:


Attachments
An Xcode Swift project demonstrating the issue. (50.52 KB, application/zip)
2017-06-11 04:25 PDT, Matt Curtis
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Curtis 2017-06-11 04:25:17 PDT
Created attachment 312599 [details]
An Xcode Swift project demonstrating the issue.

Overview:

The WKNavigationAction.sourceFrame property is not annotated as nullable, causing it to crash when accessed from Swift. This bug shows up when making a navigation request that does not originate from the page itself using one of the WKWebView load methods. I've also filed this bug with Apple under rdar://32686815.

Steps to Reproduce:

This bug can be reproduced from both Objective-C and Swift but is more critical in Swift, as access of the property causes crashing:

1. Create a WKWebView and set its navigationDelegate to an object implementing the WKNavigationDelegate protocol method `webView(WKWebView, decidePolicyFor: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void)` insert `print(navigationAction.sourceFrame)` in its body.
2. Create a new navigation load request for the WKWebView using `webView.loadHTMLString(String)`
3. Run the project.

Actual Results:

The sourceFrame property is bridged as non-nullable, and upon access the application will crash.

Expected Results:

`nil` should be printed.

Build Date & Hardware: iOS 10, 9 & OSX 10.11 >.
Comment 1 Radar WebKit Bug Importer 2017-06-12 18:12:56 PDT
<rdar://problem/32728039>