Bug 237141 - Web Inspector: add `IterableWeakSet`
Summary: Web Inspector: add `IterableWeakSet`
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-24 09:10 PST by Devin Rousso
Modified: 2022-02-28 13:03 PST (History)
5 users (show)

See Also:


Attachments
[fast-cq] Patch (22.53 KB, patch)
2022-02-24 09:22 PST, Devin Rousso
no flags Details | Formatted Diff | Diff
[fast-cq] Patch (23.95 KB, patch)
2022-02-24 16:31 PST, Devin Rousso
pangle: review+
Details | Formatted Diff | Diff
[fast-cq] Patch (24.01 KB, patch)
2022-02-27 22:28 PST, Devin Rousso
no flags Details | Formatted Diff | Diff

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