Post

Replies

Boosts

Views

Activity

Reply to WKURLSchemeHandler and fetch
I believe I know the root of this issue. In my case, the webview has its base URL set as a valid location, with a scheme of https. WKWebView sees custom schemes as insecure. WKWebView also does not allow pages loaded with a secure scheme to fetch from domains which are not secure. If I set the base url of my page to nil or an http URL, fetch loads from the custom scheme handler as expected. I haven't yet found any way to change the policy to allow the "insecure" fetch to proceed.
Topic: Safari & Web SubTopic: General Tags:
Mar ’23
Reply to WKWebView JS Execution in test target
I've figured out a workaround, but still not entirely sure of the root cause. The fix does, in fact, seem to be that a host app is required when using WKWebView in a unit test. However, it also seems to require loading or importing WebKit in the host app that is hosting the test. If my host app is written in Swift, it requires an import WebKit or if my host app is written in Objective-C it requires importing WebKit but then also seems to require loading of WebKit by alloc'ing a WKWebView instance in the didFinishLoad of the AppDelegate. My issue was further complicated by using CocoaPods and its functionality to generate a host app if a test target requires it, but a workaround was found. This behavior doesn't seem to be documented, and is maybe not even intended?
Topic: Safari & Web SubTopic: General Tags:
Sep ’22