Taritsyn / JavaScriptEngineSwitcher

JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines. This library allows you to quickly and easily switch to using of another JavaScript engine.
Apache License 2.0
439 stars 49 forks source link

Any way to debug js or capture console output? #108

Closed hzexe closed 1 year ago

hzexe commented 1 year ago

In some case js run in node and browser,but not work correct with js engine. So wish some way to detect what happened.

Any idea?

Taritsyn commented 1 year ago

Hello!

What module of the JavaScript Engine Switcher are you using?

Taritsyn commented 1 year ago

Looking ahead, I will only say that the JavaScript Engine Switcher library is focused on working with pure ECMAScript and does not support APIs specific for browsers and Node.js (including the console object). Specific debugging mechanisms are provided for some modules (see the documentation).

In addition, to implement your own console, you can use the methods that responsible for .NET-iterop (EmbedHostObject or EmbedHostType):

var log = new Action<string>(Console.WriteLine);

using (IJsEngine engine = new JintJsEngine())
{
    engine.EmbedHostObject("log", log);
    engine.Execute("log('Current time: ' + new Date());");
}

In this example, the JavaScriptEngineSwitcher.Jint module is used, but it can also work with all modules except the JavaScriptEngineSwitcher.Node and JavaScriptEngineSwitcher.Vroom.

hzexe commented 1 year ago

Thanks,change to v8 engine and enable remote debuging follow documentation. then found the problem in return value of the function atob