apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 985 forks source link

window.webkit.messageHandlers undefined after iframe triggers navigation action #1261

Open elisemn opened 2 years ago

elisemn commented 2 years ago

Bug Report

Problem

An iframe in our app triggers a navigation action via window.open or window.top.location.href to a url that is in our allow-intent allow list. The url is correctly opened in the system browser. However after it is opened window.webkit.messageHandlers is undefined which causes runtime errors within the cordova exec.js file when it attempts to use the cordova message handler to post a message.

TypeError null is not an object (evaluating 'window.webkit.messageHandlers.cordova')

What is expected to happen?

The URL opened by the iframe should be opened in the system browser without triggering errors within the cordova app.

What does actually happen?

After the URL is opened window.webkit.messageHandlers undefined errors occur

Information

Command or Code

Environment, Platform, Device

This issues appears to happen on any iOS mobile device.

Version information

Cordova Packages:

    cli: 11.0.0
        common: 4.0.2
        create: 4.0.0
        lib: 11.0.0
            common: 4.0.2
            fetch: 3.0.1
            serve: 4.0.0

Project Installed Platforms:

    ios: 6.2.0

Checklist

dpogue commented 2 years ago

To clarify: when you say "system browser" you mean opening in Safari (or Chrome, etc.) and leaving the Cordova app, right?

and then webkit.messageHandlers is undefined when you return to the Cordova app?

dpogue commented 2 years ago

Also, the linked bug has some mention of App-Bound Domains, which aren't something that has been thoroughly tested on the Cordova side. Is your app using App-Bound Domains?

elisemn commented 2 years ago

To clarify: when you say "system browser" you mean opening in Safari (or Chrome, etc.) and leaving the Cordova app, right?

and then webkit.messageHandlers is undefined when you return to the Cordova app?

Correct

Also, the linked bug has some mention of App-Bound Domains, which aren't something that has been thoroughly tested on the Cordova side. Is your app using App-Bound Domains?

It does look like our app is setting a number of WKAppBoundDomains and the iframe url is not one of them. I can investigate updating them.