@@ -27,7 +27,10 @@ function toString(value: unknown, defaultValue: string) {
2727function consoleMessage ( level , args ) {
2828 performOp ( "console/message" , level , getMessage ( args ) ) ;
2929}
30- const consoleImpl = {
30+ // For historical web-compatibility reasons, the namespace object for console
31+ // must have as its [[Prototype]] an empty object, created as if by
32+ // ObjectCreate(%ObjectPrototype%), instead of %ObjectPrototype%.
33+ const consoleImpl = Object . assign ( Object . create ( { } ) , {
3134 debug : function ( ...args ) {
3235 consoleMessage ( "DEBUG" , args ) ;
3336 } ,
@@ -65,14 +68,18 @@ const consoleImpl = {
6568 performOp ( "console/timeEnd" , labelStr ) ;
6669 } ,
6770 // TODO: Implement the rest of the Console API.
68-
69- get [ Symbol . toStringTag ] ( ) {
70- return "console" ;
71- } ,
72- } ;
71+ } ) ;
72+ Object . defineProperty ( consoleImpl , Symbol . toStringTag , {
73+ value : "console" ,
74+ enumerable : false ,
75+ writable : false ,
76+ } ) ;
7377export function setupConsole ( global ) {
7478 // Delete v8's console since it doesn't go anywhere. We'll eventually want to mirror our console
7579 // output to v8's console since apparently its output shows up in v8's debugger.
7680 delete global . console ;
77- global . console = consoleImpl ;
81+ Object . defineProperty ( global , "console" , {
82+ value : consoleImpl ,
83+ enumerable : false ,
84+ } ) ;
7885}
0 commit comments