Not providing console does not fail
It looks like console is defined by default, just it does not work - it does not print anything to the terminal. I have a script which uses console and running it did not raise any error (while if I try to access some other symbol it fails).
So I suggest the default console is removed, or a working implementation is provided instead.
console is a "special" object in V8. You can create callback functions for the API, but we don't have these exposed in v8go yet. What we do have is a way to set the console global object and use a FunctionTemplate to do what you want when console.log etc is called.
The aim of this project is to provide a rich binding to V8, not a general purpose JavaScript engine; If you are looking for some of the common polyfils I would take a look at a project like: https://github.com/kuoruan/v8go-polyfills
This is now what this issue is about. I am saying that without setting console, a script using console should fail. But it does not. So you are setting some form of console by default, which I think you should not be doing?
This project does not set anything for console, this is done be V8 itself and is the default behaviour
I see. But then this package should provide some way to use ConsoleDelegate properly?
- https://source.chromium.org/chromium/chromium/src/+/master:v8/src/d8/d8-console.h;l=14
- https://stackoverflow.com/questions/57531024/v8-console-log-does-not-print
I think it still confusing and this package should probably set something which throws an error unless something else is set for console.
Yup. ConsoleDelegate was what I was meaning by:
You can create callback functions for the API, but we don't have these exposed in v8go yet
I agree that it can be confusing for a first-time V8 user, but even with the ConsoleDelegate APIs exposed, it would still be the responsibility of the caller to implement that delegate.
Yup.
ConsoleDelegatewas what I was meaning by:You can create callback functions for the API, but we don't have these exposed in v8go yet
I agree that it can be confusing for a first-time V8 user, but even with the
ConsoleDelegateAPIs exposed, it would still be the responsibility of the caller to implement that delegate.
And thus, would it be possible to expose the API allowing us to implement the delegate? :D