WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

[Problem/Bug]: ignoreMemberNotFoundError can not prevent exception when accessing an non-existing function

Open richard-chen-coding opened this issue 1 year ago • 2 comments

What happened?

When using a host object, I was trying to check whether a function exists before calling it, according to ignoreMemberNotFoundError, I shall be able to use this option to prevent exception. However, this option doesn't work in my end. Here is the test case I was using. image

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

123.0.2420.97

SDK Version

1.0.2420.47

Framework

WPF

Operating System

Windows 10

OS Version

10.0.19045

Repro steps

  • Create a C# host class
  • Register the host object with CoreWebView2.AddHostObjectToScript
  • Follow winrt-from-js sample, hook up JS with AddScriptToExecuteOnDocumentCreatedAsync()
  • Start application, inspect state in debug console, see screenshot: getIsEntitled() is a valid function from host C# object, fakeMethod doesn't exist at all, however, since ignoreMemberNotFoundError was set to true, I am expecting accessing fakeMethod should return an undefined instead of throwing an exception image

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

AB#50274346

richard-chen-coding avatar Apr 22 '24 15:04 richard-chen-coding

It seems that WebView2 implementation only covers DISP_E_MEMBERNOTFOUND and missed handling of DISP_E_UNKNOWNNAME. Created internal work item to track the issue.

LiangTheDev avatar Apr 22 '24 19:04 LiangTheDev

The fix has been checked in and will be available in newer Edge builds with version >= 126.0.2562.0.

LiangTheDev avatar May 03 '24 21:05 LiangTheDev