Browser.setDownloadBehavior doesn't work for WebView2

%3CLINGO-SUB%20id%3D%22lingo-sub-1685368%22%20slang%3D%22en-US%22%3EBrowser.setDownloadBehavior%20doesn't%20work%20for%20WebView2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1685368%22%20slang%3D%22en-US%22%3E%3CP%3EI%20receive%20invalid%20argument%20error%20(%3CSPAN%3E0x80070057%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ee_invalidarg)%26nbsp%3B%3C%2FSTRONG%3E%20when%20I%20use%26nbsp%3BCallDevToolsProtocolMethod%20with%26nbsp%3BBrowser.setDownloadBehavior%20as%20command%20and%26nbsp%3BL%22%7B%5C%22behavior%5C%22%3A%5C%22deny%5C%22%7D%22%20as%20parameters%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Econst%20wchar_t*%20command%20%3D%20L%22Browser.setDownloadBehavior%22%3B%3CBR%20%2F%3Econst%20wchar_t*%20parameters%20%3D%20L%22%7B%5C%22behavior%5C%22%3A%5C%22deny%5C%22%7D%22%3B%3CBR%20%2F%3EHRESULT%20res%20%3D%20webview-%26gt%3BCallDevToolsProtocolMethod(command%2C%3CBR%20%2F%3Eparameters%2C%3CBR%20%2F%3ECallback%3CICOREWEBVIEW2CALLDEVTOOLSPROTOCOLMETHODCOMPLETEDHANDLER%3E(%3CBR%20%2F%3E%5Bthis%5D(HRESULT%20error%2C%20PCWSTR%20resultJson)%20-%26gt%3B%20HRESULT%3CBR%20%2F%3E%7B%3CBR%20%2F%3Estd%3A%3Awstringstream%20formattedMessage%3B%3CBR%20%2F%3EformattedMessage%20%26lt%3B%26lt%3B%20%22Error%3A%200x%22%20%26lt%3B%26lt%3B%20std%3A%3Ahex%20%26lt%3B%26lt%3B%20std%3A%3Asetw(8)%20%26lt%3B%26lt%3B%20error%3B%3CBR%20%2F%3Estd%3A%3Awstring%20str%20%3D%20formattedMessage.str()%3B%3CBR%20%2F%3Ereturn%20S_OK%3B%3CBR%20%2F%3E%7D).Get())%3B%3C%2FICOREWEBVIEW2CALLDEVTOOLSPROTOCOLMETHODCOMPLETEDHANDLER%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOther%20Chrome%20Dev%20Tool%20Protocol%20methods%20works%20fine.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBrowser.setDownloadBehavior%20works%20when%20I%20start%20it%20in%20Dev%20Tools%20Window%3A%3C%2FP%3E%3CP%3Eawait%20Main.MainImpl.sendOverProtocol(%22Browser.setDownloadBehavior%22%2C%20%7B%3CBR%20%2F%3Ebehavior%3A%20%22deny%22%3CBR%20%2F%3E%7D)%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EIs%20this%20a%20known%20issue%20or%20I%20am%20doing%20something%20wrong%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWebView2%20version%3A%200.9.579%3C%2FP%3E%3CP%3EEdge%20Beta%20version%3A%26nbsp%3B%3CSPAN%3E86.0.622.15%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Visitor

I receive invalid argument error (0x80070057 e_invalidarg)  when I use CallDevToolsProtocolMethod with Browser.setDownloadBehavior as command and L"{\"behavior\":\"deny\"}" as parameters:

 

const wchar_t* command = L"Browser.setDownloadBehavior";
const wchar_t* parameters = L"{\"behavior\":\"deny\"}";
HRESULT res = webview->CallDevToolsProtocolMethod(command,
parameters,
Callback<ICoreWebView2CallDevToolsProtocolMethodCompletedHandler>(
[this](HRESULT error, PCWSTR resultJson) -> HRESULT
{
std::wstringstream formattedMessage;
formattedMessage << "Error: 0x" << std::hex << std::setw(8) << error;
std::wstring str = formattedMessage.str();
return S_OK;
}).Get());

 

Other Chrome Dev Tool Protocol methods works fine.

 

Browser.setDownloadBehavior works when I start it in Dev Tools Window:

await Main.MainImpl.sendOverProtocol("Browser.setDownloadBehavior", {
behavior: "deny"
});

 

Is this a known issue or I am doing something wrong?

 

WebView2 version: 0.9.579

Edge Beta version: 86.0.622.15  

0 Replies