Implement the Console API as built-in JS globals.
Scope#
Console Object#
- Register
consoleas a global object in the JS VM duringinit_builtins() - Implement as a plain object with native function methods
Methods#
console.log(...args)— format arguments and write to stdoutconsole.error(...args)— format arguments and write to stderrconsole.warn(...args)— format arguments and write to stderrconsole.info(...args)— alias for console.logconsole.debug(...args)— alias for console.log (or no-op)
Formatting#
- Convert each argument to its string representation using the existing
to_js_string()on Value - Separate multiple arguments with spaces
- Objects should show
[object Object]or a more useful representation - Arrays should show their contents
Output Channel#
- Provide a configurable output sink (trait or callback) so the browser can redirect console output to a dev tools panel later
- Default implementation writes to stdout/stderr
Integration#
- Works in the existing
evaluate()/evaluate_with_preamble()API - No DOM dependency required — pure JS engine feature
Acceptance Criteria#
-
console.log("hello")prints to stdout -
console.error("oops")prints to stderr - Multiple arguments:
console.log("a", 1, true)→a 1 true - Object formatting:
console.log({x: 1})→ reasonable output -
console.logdoes not throw — always returns undefined - Works with the existing Test262 infrastructure (can be used as
print()replacement)
Phase 11 — DOM-JS Bindings (issue 1 of 8). No dependencies on other Phase 11 issues.