MicrosoftEdge / WebView2Browser

A web browser built with the Microsoft Edge WebView2 control.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

applyHostFunction method is not working

Bearfot opened this issue · comments

The applyHostFunction method is not working as the called method name always becomes an empty string.

The applyHostFunction internally calls postSyncRequestMessage, but the method name is the second argument, which always is set to an empty string as seen in the code below.

applyHostFunction(parameters) {
if (this._resultObjectId !== null) {
const name = this._debugId?.slice(-1)[0];
if (name && chrome.webview.hostObjects.getLocalProperty('options')?.forceAsyncMethodMatches?.filter(r=>name.match(r))?.length > 0) {
let hostFunctionPromise = this.async().applyHostFunction(parameters);
let syncPromise = hostFunctionPromise.sync();
syncPromise._cancelablePromise = hostFunctionPromise;
return syncPromise;
} else {
return this._options.remoteMessenger.postSyncRequestMessage(this._resultObjectId, "", "apply", parameters, this._debugId.concat("()")).value;
}
}
throw new Error("Unable to call method on non-function.");
}

I would have expected that the method name was retrieved from the first element in the provided parameters array, or?

wrong repo, should webview2feedback