Bug 578017 - [Browser][Edge] cannot invoke "evaluate" inside a BrowserFunction
Summary: [Browser][Edge] cannot invoke "evaluate" inside a BrowserFunction
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.22   Edit
Hardware: PC Windows 10
: P3 normal with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 575660
  Show dependency tree
 
Reported: 2022-01-02 13:00 EST by Kent Xu CLA
Modified: 2022-04-27 03:56 EDT (History)
5 users (show)

See Also:


Attachments
simple demo (2.18 KB, application/octet-stream)
2022-01-02 13:00 EST, Kent Xu CLA
no flags Details
simple html (747 bytes, text/html)
2022-01-02 13:01 EST, Kent Xu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Xu CLA 2022-01-02 13:00:19 EST
Created attachment 287762 [details]
simple demo

BrowserFunction gets stuck if "evaluate" is invoked inside it. This is only happening after we upgraded to Edge, worked fine on IE11 or OSX (Safari Webkit).
Comment 1 Kent Xu CLA 2022-01-02 13:01:06 EST
Created attachment 287763 [details]
simple html
Comment 2 Niraj Modi CLA 2022-01-07 05:52:28 EST
(In reply to Missing name from comment #0)
> Created attachment 287762 [details]
> simple demo
> 
> BrowserFunction gets stuck if "evaluate" is invoked inside it. This is only
> happening after we upgraded to Edge, worked fine on IE11 or OSX (Safari
> Webkit).

This a known issue with embedded EDGE browser(WebView2 support for SWT).
Limitation of 'evaluate()' method is mentioned in below readme file:
https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/174084/8/bundles/org.eclipse.swt/Readme.WebView2.md#103
Comment 3 Niraj Modi CLA 2022-01-07 05:53:34 EST
Work-around:
- Suggested to use async call, similar to attachment 287762 [details]

Possible alternate:
- by exposing the asynchronous `evaluate()` method
Comment 4 andrew le CLA 2022-02-25 14:30:46 EST
Hi, any update on this issue? Unfortunately, async can't be used in my scenario as the value is needed in order for the application to continue.
Comment 5 Akhil Kumar Mandava CLA 2022-04-04 12:34:20 EDT
Hi @Niraj Modi, is it possible to do a synchrounous operation for browser.evaluate()? I need to use the result from evaluate in the next line of program . 

I have a scenario something like this : 

class TestNamespacesFunction extends BrowserFunction
{
    private static final String FUNCTION_NAME = "createNamespaces"; //$NON-NLS-1$
    Browser browser;
    Object test;

    WrapNamespacesFunction(Browser browser)
    {
        super(browser, FUNCTION_NAME);
        this.browser = browser;
    }

    @Override
    public Object function(Object[] arguments)
    {
        test = null;
        final String IS_UNDEFINED_SCRIPT = "return typeof({0}) != ''function'';"; //$NON-NLS-1$
        test = browser.evaluate(MessageFormat.format(IS_UNDEFINED_SCRIPT, "createNamespaces"));

        return test;
    }

}

Appreciate any thoughts ?