Bug 208758

Summary: JSContext Inspector: CommandLineAPI `dir({a:1})` does not work - undefined is not an object (evaluating 'inspectedGlobalObject.console.dir')
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: hi, inspector-bugzilla-changes, joepeck, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   

Description Joseph Pecoraro 2020-03-06 21:30:51 PST
CommandLineAPI `dir({a:1})` does not work - undefined is not an object (evaluating 'inspectedGlobalObject.console.dir')

Something with the Basic Command Line API for JSContexts is broken.

Steps to Reproduce:
1. Setup Safari to auto-inspect JSContexts
2. $ jsc --remote-debug
3. jsc> 123
4. In JSContext Inspector evaluate: dir({a:1})
  => TypeError: undefined is not an object (evaluating 'inspectedGlobalObject.console.dir')
Comment 1 Radar WebKit Bug Importer 2020-03-06 21:31:17 PST
<rdar://problem/60181982>
Comment 2 Devin Rousso 2020-03-06 23:07:44 PST
(In reply to Joseph Pecoraro from comment #0)
> Steps to Reproduce:
> 1. Setup Safari to auto-inspect JSContexts
> 2. $ jsc --remote-debug
> 3. jsc> 123
> 4. In JSContext Inspector evaluate: dir({a:1})
>   => TypeError: undefined is not an object (evaluating 'inspectedGlobalObject.console.dir')

Interestingly, it looks like `console` and `globalThis.console` are `undefined` here too.  I'm not sure how that is possible 🤔
Comment 3 Joseph Pecoraro 2020-03-06 23:58:36 PST
(In reply to Devin Rousso from comment #2)
> (In reply to Joseph Pecoraro from comment #0)
> > Steps to Reproduce:
> > 1. Setup Safari to auto-inspect JSContexts
> > 2. $ jsc --remote-debug
> > 3. jsc> 123
> > 4. In JSContext Inspector evaluate: dir({a:1})
> >   => TypeError: undefined is not an object (evaluating 'inspectedGlobalObject.console.dir')
> 
> Interestingly, it looks like `console` and `globalThis.console` are
> `undefined` here too.  I'm not sure how that is possible 🤔

Ohhhh, this might just be `jsc` which purposely deletes `console`.

This might be my mistake then.
Comment 4 Joseph Pecoraro 2020-03-07 00:01:18 PST
Yeah, my mistake. Working with a test program:

```
#import <Foundation/Foundation.h>
#import <JavaScriptCore/JavaScriptCore.h>

int main() {
    JSContext* context = [[JSContext alloc] init];
    [context evaluateScript:@"1+1"];
    [[NSRunLoop mainRunLoop] run];
    return 0;
}
```

Everything works fine.

Closing.