Skip to content

Error transferring byte array data from C # to JavaScript #5081

Description

@qwertzou

Is there an existing issue for this?

  • I have searched both open/closed issues, no issue already exists.

CefSharp Version

135.0.170

Operating System

Windows 10

Architecture

x64

.Net Version

net472

Implementation

WinForms

Reproduction Steps

Reference example: CefSharp/CefSharp.Test/Javascript/EvaluateScriptAsyncTests.cs -> CanEvaluateScriptAsyncReturnArrayBuffer
Can only receive ArrayBuffer data returned by Javascript, cannot transfer byte array data to Javascript

Expected behavior

C#:
byte[] bytes = Encoding.UTF8.GetBytes(str); var javascriptResponse = await browser.EvaluateScriptAsync($"putByte({bytes})"); if (javascriptResponse.Success) { var actualBytes = (byte[])javascriptResponse.Result; string newstr = Encoding.UTF8.GetString(actualBytes); Debug.WriteLine(newstr); }

Javascript:
<script> function putByte(pData) { console.log(pData); return pData; } </script>

Actual behavior

error message: Uncaught SyntaxError: Unexpected token ']'\n@ about:blank:1:20"

Regression?

No response

Known Workarounds

No response

Does this problem also occur in the CEF Sample Application

Yes using WinForms command line args

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions