Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behaviour of execute JS between Android and IOS #26

Open
Ninerian opened this issue Dec 23, 2019 · 2 comments
Open

Different behaviour of execute JS between Android and IOS #26

Ninerian opened this issue Dec 23, 2019 · 2 comments

Comments

@Ninerian
Copy link

While working with the executeJS function of the tabs module I found an issue.

Sample Code

function y (result) { console.log('result',result)}
function x () {  return [[{"ss":"zz"}]]; }

// a native tab, bound to a global variable
window.testTab.executeJS('(' + x.toString() + ')();',y)

Expected Result

A log entry with: [FORGE] '[[{"ss":"zz"}]]'

Actual Result

Android log entry: [FORGE] '[{"ss":"zz"}]'
IOS log entry: [FORGE] '[[{"ss":"zz"}]]'

On android the first and last character is removed from the output. This makes it impossible to send a valid JSON string as return value and parse it on the application side. Also if nothing is return, the callback parameter is ul, as null gets the same handling.

It think this line causes the behaviour:

I also couldn't get into the value==null path.

How is the recommended way to return a value from an injected JS function?

@antoinevg
Copy link
Contributor

Wow, looks like that line has been in there since the code was originally written 6 years ago!

I have no idea what the reason was for that originally but it a) looks like a rather ugly hack, b) doesn't look safe as there are no bounds checks on the variable and c) frankly doesn't make any sense.

That said, I've modified it in dec3258 and the module tests are still passing.

Can you please give it a shot on your side?

Published as:

"tabs": {
    "version": "3.6.1",
    "config": { }
},

Needs:

"platform_version": "v2.8.5"

@Ninerian
Copy link
Author

Thank you @antoinevg. I'll try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants