nativescript-community / ui-webview

Extended WebView which adds many options such as custom scheme handlers, JavaScript execution, URL capturing, and more.
Apache License 2.0
13 stars 7 forks source link

Global variables cause some external sites to work incorrectly #14

Open pichurichko opened 9 months ago

pichurichko commented 9 months ago

Which platform(s) does your issue occur on?

Both (examples below reproducible on iOS)

Please, provide the following version numbers that your issue occurs with:

Does not matter, web view runtime issue

Please, tell us how to recreate the issue in as much detail as possible.

Open some site in web view which executes script in global scope like (code from real 3DS payment form): for (i = 0, ii = 0; i < method.length; i++) { ... }

Is there any code involved?

The reason of the issue is this code: https://github.com/nativescript-community/ui-webview/blob/b7c440fe9b7f82f53e624a93bc709f4434b65364/www-src/bridge.ios.ts#L83 https://github.com/nativescript-community/ui-webview/blob/b7c440fe9b7f82f53e624a93bc709f4434b65364/www-src/bridge.android.ts#L24

After minification "w" variable transforms to "i", and if some site will use it in "for" loop like from example, it will get error:

TypeError: Attempted to assign to readonly property.

Recommendation for fix is to wrap the related code from links into separate scope (not global one).