question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix handling of Javascript functions from Rewards WebUI pages

See original GitHub issue

@bridiver noticed a few problems in the Rewards WebUI pages:

  1. We shouldn’t call CallJavascriptFunctionUnsafe. Instead, use WebUIMessageHandler::CallJavascriptFunction or FireWebUIListener, since those are safe alternatives.
  2. We should call IsJavascriptAllowed instead of CanCallJavascript.
  3. Ensure that we’re calling AllowJavascript correctly, per the docs in the header file. It’s sometimes not called when it should be and sometimes called when it shouldn’t be.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SergeyZhukovskycommented, May 5, 2021

that call

GetMojomFrameInRenderer()->JavaScriptExecuteRequest(javascript, wants_result,
                                                      std::move(callback));

isn’t going throw where javascript is the actual script to be executed. In what place couldn’t it find the function? that’s the crash place before any validations GetMojomFrameInRenderer()->. It would crash constantly and always the way you explain it. But in fact we cannot replicate that, we just see crashes from users.

0reactions
zenparsingcommented, May 5, 2021

Right, because CallJavascriptFunctionUnsafe can’t find the named JS function “brave_rewards.statement” in the Android version of the rewards page. We really need to get a native version of the Rewards page for Android! 😄

…although in this case the android page appears to provide that function, so there’s probably something more going on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling common JavaScript problems - MDN Web Docs
Incorrectly using functions inside loops that iterate with a global variable (more generally "getting the scope wrong"). For example, in bad-for ...
Read more >
Set up a JavaScript Firebase Cloud Messaging client app
Set up a JavaScript Firebase Cloud Messaging client app · On this page · Add and initialize the FCM SDK · Configure Web...
Read more >
How to enable JavaScript in Windows - Microsoft Support
Click the Refresh button to refresh the page and run scripts. Click the Refresh button to refresh the page and run scripts. To...
Read more >
Telerik Web UI Grid Overview Demo | Telerik UI for ASP.NET ...
Explore RadGrid demos to find out how Telerik's Datagrid control can help you with editing and fast loading of large data in your...
Read more >
[WebUI] Execute JavaScript - Katalon Docs
Execute JavaScript on the currently selected frame or window. The provided script fragment will be executed as the body of an anonymous function....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found