Javascript disabled over HTTP in WebView on macOS
What is the problem or limitation you are having?
After using the Positron design pattern (WebView widget paired with HTTP server running on another thread to serve assets to the web view), I was puzzled that none of the Javascript worked, but only when I built the macOS app and ran it. Everything was fine when running the application in dev mode.
After some hunting, I discovered this Stack Overflow answer: https://stackoverflow.com/a/62537163
It explains that I need to add to the project's Info in Xcode a dictionary called "App Transport Security Settings" with a key called "Allow Arbitrary Loads" set to YES. Once I manually added this to the Xcode project, everything worked fine.
Describe the solution you'd like
It would be useful to call out this issue on the WebView documentation page. Additionally, I couldn't tell if there was a persistent way to add this Info setting in the pyproject.toml for my Briefcase app. Since I had to open Xcode to manually add this setting, I assume the setting will be lost if Briefcase ever needs to regenerate the Xcode project.
Describe alternatives you've considered
The alternative I found was to add the setting manually with Xcode after generating the project with Briefcase and hope it isn't overwritten in the future.
Additional context
No response
This should be possible to accomodate by default in the template. Briefcase can inject Info.plist values; so we can add a setting defining the appropriate key to the macOS section of the Positron plugins. None of the plugins currently have a definition for this; but the Toga template that the Positron templates are based on defines a pyproject_table_macOS entry point. If we add a info."something" =True definition to the Positron template (whatever the key is called), we can ensure this setting exists for all apps.
Two notes on the implementation:
- We need to find the underlying key name - "Allow arbitrary loads" is the human version of the key; we need the Info.plist key. You can find this key name by manually adding the setting in the Xcode project, then inspecting the Info.plist file that is generated
- It might be worth introducing an abstract "Positron base" template. This macOS setting will be needed on all the Positron templates, so it makes sense to define it once and use it everywhere.
Could you please assign this issue to me I will be happy to work
@MhussainD4772 We don't explicitly assign issues - expressing interest in an issue (as you have done here) is all you need to do. Our contribution guide is here; if you need any additional assistance, let us know. I look forward to seeing your PR!
Thank you so much!!