Taritsyn/JavaScriptEngineSwitcher

Any way to debug js or capture console output?

hzexe opened this issue · 3 comments

hzexe commented

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?

Hello!

What module of the JavaScript Engine Switcher are you using?

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

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