[Webkit-unassigned] [Bug 227589] New: WKWebView javascript injection doesn't work if app includes WKAppBoundDomains

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jul 1 11:16:16 PDT 2021


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

            Bug ID: 227589
           Summary: WKWebView javascript injection doesn't work if app
                    includes WKAppBoundDomains
           Product: WebKit
           Version: Other
          Hardware: All
                OS: iOS 14
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebKit Misc.
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: juliosincesar at hotmail.com

Sample app:
https://github.com/jcesarmobile/appboundsbug

Steps to reproduce:
1. Clone the app
2. Run the app on iOS 14 or newer (also affects iOS 15 beta 2)

Expected:
The background should be red

Actual behavior:
The background is white

JavaScript injection can be enabled back by adding:
webViewConfiguration.limitsNavigationsToAppBoundDomains = true

and adding localhost to the WKAppBoundDomains

<key>WKAppBoundDomains</key>
<array>
    <string>localhost</string>
</array>


But according to this article https://webkit.org/blog/10882/app-bound-domains/, you should not need to add localhost as it's loading local assets.


Also the article says that to enable app bound domains you can just add the key
<key>WKAppBoundDomains</key>
but that doesn't let the app to compile, you need to add an empty array.


TLDR: Adding WKAppBoundDomains key in the info.plist should not disable JavaScript injection in apps that load local assets, it should only disable it for the external domains that you add in the WKAppBoundDomains list if limitsNavigationsToAppBoundDomains is not set to true. But for local assets it should always work no matter what the value is and users should not need to add localhost to the list.


The sample app is a simple example, but adding WKAppBoundDomains key breaks all Ionic Capacitor plugins as they rely on the JavaScript injection

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210701/0ce712c2/attachment.htm>


More information about the webkit-unassigned mailing list