Bug 208758 - JSContext Inspector: CommandLineAPI `dir({a:1})` does not work - undefined is not an object (evaluating 'inspectedGlobalObject.console.dir')
Summary: JSContext Inspector: CommandLineAPI `dir({a:1})` does not work - undefined is...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-06 21:30 PST by Joseph Pecoraro
Modified: 2020-03-07 00:01 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.