Bug 237141

Summary: Web Inspector: add `IterableWeakSet`
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, hi, inspector-bugzilla-changes, pangle, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=236533
Attachments:
Description Flags
[fast-cq] Patch
none
[fast-cq] Patch
pangle: review+
[fast-cq] Patch none

Description Devin Rousso 2022-02-24 09:10:02 PST
this allows clients to have a way to have an iterable collection (which btw `WeakSet`/`WeakMap` are not) that doesn't keep the objects in the collection alive (which btw `Set`/`Map`/`Array` do)
Comment 1 Devin Rousso 2022-02-24 09:22:02 PST
Created attachment 453107 [details]
[fast-cq] Patch
Comment 2 Devin Rousso 2022-02-24 16:31:17 PST
Created attachment 453154 [details]
[fast-cq] Patch
Comment 3 Patrick Angle 2022-02-25 13:35:25 PST
Comment on attachment 453154 [details]
[fast-cq] Patch

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

rs=me Nice!

> Source/WebInspectorUI/UserInterface/Base/IterableWeakSet.js:130
> +        return Array.from(this);

It seems a bit strange to me that it should be possible to mutate the result of `toJSON` as an array (even if those mutations won't affect the underlying backing). Any reason not to call `toJSON` on the created array to avoid that side effect? (`copy()` would need to change slightly if this does, though)

> LayoutTests/inspector/unit-tests/iterableweakset-expected.txt:13
> +PASS: has should return true if a key exists.

Nit: can we enclose `has` inside back-ticks or some other quote-like character. I read this sentence several times before I realized `has` was a function name, despite the test case header hinting at that 😅. Same throughout below.
Comment 4 Devin Rousso 2022-02-25 16:16:14 PST
Comment on attachment 453154 [details]
[fast-cq] Patch

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

>> Source/WebInspectorUI/UserInterface/Base/IterableWeakSet.js:130
>> +        return Array.from(this);
> 
> It seems a bit strange to me that it should be possible to mutate the result of `toJSON` as an array (even if those mutations won't affect the underlying backing). Any reason not to call `toJSON` on the created array to avoid that side effect? (`copy()` would need to change slightly if this does, though)

As discussed offline, this is intended to support `JSON.stringify` <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior> and is not required to return a `String`.

>> LayoutTests/inspector/unit-tests/iterableweakset-expected.txt:13
>> +PASS: has should return true if a key exists.
> 
> Nit: can we enclose `has` inside back-ticks or some other quote-like character. I read this sentence several times before I realized `has` was a function name, despite the test case header hinting at that 😅. Same throughout below.

Good idea.  Will change.
Comment 5 Devin Rousso 2022-02-27 22:28:11 PST
Created attachment 453367 [details]
[fast-cq] Patch
Comment 6 EWS 2022-02-28 13:02:09 PST
Committed r290612 (247885@main): <https://commits.webkit.org/247885@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453367 [details].
Comment 7 Radar WebKit Bug Importer 2022-02-28 13:03:19 PST
<rdar://problem/89576657>