Bug 218686

Summary: Web Inspector: ensure that `JSON::ArrayOf<T>` doesn't allow `addItem` to be called with a type other than `T`
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, benjamin, cdumez, cmarcelo, ews-watchlist, hi, inspector-bugzilla-changes, joepeck, keith_miller, mark.lam, msaboff, saam, tzagallo, 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=219483
Attachments:
Description Flags
Patch
none
Patch none

Description Devin Rousso 2020-11-07 11:16:04 PST
Right now, `JSON::ArrayOf<T>` always has `addItem` overloads for `int`, `double`, `String`, and `Ref<T>` (even when `T` is not a `JSON::Value`).  This means that I could have a `JSON::ArrayOf<int>` and call `addItem(42.0)` or `addItem("foo"_s)` and it would work.  We should prevent that.
Comment 1 Devin Rousso 2020-11-07 11:16:36 PST
Created attachment 413529 [details]
Patch
Comment 2 Devin Rousso 2020-11-08 23:58:56 PST
Created attachment 413563 [details]
Patch
Comment 3 EWS Watchlist 2020-11-08 23:59:53 PST
This patch modifies the inspector protocol generator. Please ensure that you have rebaselined any generator test results (i.e., by running `Tools/Scripts/run-inspector-generator-tests --reset-results`)
Comment 4 BJ Burg 2020-11-12 14:32:08 PST
Comment on attachment 413563 [details]
Patch

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

r=me

> Source/JavaScriptCore/inspector/scripts/codegen/cpp_generator_templates.py:142
> +    static NeverDestroyed<DispatchMap> dispatchMap = DispatchMap({

🤯

> Source/JavaScriptCore/inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:342
> +    static NeverDestroyed<DispatchMap> dispatchMap = DispatchMap({

Ugh, you are the best, Devin! This is so much nicer.
Comment 5 EWS 2020-11-12 14:54:41 PST
Committed r269757: <https://trac.webkit.org/changeset/269757>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 413563 [details].
Comment 6 Radar WebKit Bug Importer 2020-11-12 14:55:19 PST
<rdar://problem/71345351>