Bug 193147

Summary: Web Inspector: Include `globalThis` in default JavaScript completions
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, hi, inspector-bugzilla-changes, joepeck, keith_miller, mark.lam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix none

Description Joseph Pecoraro 2019-01-04 11:00:01 PST
Include `globalThis` in default JavaScript completions
Comment 1 Joseph Pecoraro 2019-01-04 11:00:44 PST
Created attachment 358336 [details]
[PATCH] Proposed Fix
Comment 2 Devin Rousso 2019-01-04 11:49:59 PST
Comment on attachment 358336 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=358336&action=review

r=me

Is `globalThis` something we'd also want to always show in the Scope chain when paused?

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js:661
>              "return", "static", "super", "switch", "this", "throw", "true", "try",

Should we be including `"globalThis"` in `allKeywords` as well?

Ditto (727) (I can't comment on it because it's outside of this diff's range)

> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js:664
> +        var valueKeywords = ["false", "Infinity", "NaN", "null", "this", "true", "undefined", "globalThis"];

`"globalThis"` should be placed before `"Infinity"` if we want to keep it alphabetized.

NIT: considering how small this patch is, I wouldn't be against a bit of refactoring (e.g. `.keySet()` to `new Set()`)
Comment 3 Joseph Pecoraro 2019-01-04 12:04:04 PST
Comment on attachment 358336 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=358336&action=review

>> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js:661
>>              "return", "static", "super", "switch", "this", "throw", "true", "try",
> 
> Should we be including `"globalThis"` in `allKeywords` as well?
> 
> Ditto (727) (I can't comment on it because it's outside of this diff's range)

`globalThis` is not a keyword.

>> Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js:664
>> +        var valueKeywords = ["false", "Infinity", "NaN", "null", "this", "true", "undefined", "globalThis"];
> 
> `"globalThis"` should be placed before `"Infinity"` if we want to keep it alphabetized.
> 
> NIT: considering how small this patch is, I wouldn't be against a bit of refactoring (e.g. `.keySet()` to `new Set()`)

Good idea but I'll keep the code as is for now to avoid breaking something inadvertently.
Comment 4 WebKit Commit Bot 2019-01-04 12:29:34 PST
Comment on attachment 358336 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 358336

Committed r239630: <https://trac.webkit.org/changeset/239630>
Comment 5 WebKit Commit Bot 2019-01-04 12:29:36 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 Radar WebKit Bug Importer 2019-01-04 12:30:36 PST
<rdar://problem/47054614>