Skip to content

[Problem/Bug]: conflict between existing script and webview #4227

Open
@vovanb

Description

@vovanb

What happened?

I am using .Net core winforms with webview2. When I call CoreWebView2.PostWebMessageAsString , I got error :

VM7:1  Uncaught TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.
    at EmbeddedBrowserWebView.<anonymous> (<anonymous>:1:40673)

in below code, which is coming from webview2 implementation:

                embeddedBrowserWebView.addEventListener("message", native_event=>{
                if (logNativeEvent)
                    console.log("native event:", native_event);
                let eventArg = new Event("message");
                Object.defineProperty(eventArg, 'data', {
                    value: JSON.parse(native_event.data)
                });
                Object.defineProperty(eventArg, 'source', {
                    value: webview
                });
                webview.dispatchEvent(eventArg);

So I think object Event is conflicting with one of own classes, which is not possible to change. What is possible to do? Is it possible to modify webview2 JS to use another name for Event class?

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

No response

Framework

Winforms

Operating System

Windows 10

OS Version

No response

Repro steps

create winform application using our client

Repros in Edge Browser

No

Regression

No, this never worked

Last working version (if regression)

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions