WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 173662
Web Inspector: move Inspector::Protocol::Array<T> to JSON namespace
https://bugs.webkit.org/show_bug.cgi?id=173662
Summary
Web Inspector: move Inspector::Protocol::Array<T> to JSON namespace
Blaze Burg
Reported
2017-06-21 10:36:47 PDT
This is really the parametric version of JSON::Array. It should be alongside that so we can improve both to have more consistent API.
Attachments
Patch
(161.43 KB, patch)
2017-06-21 14:19 PDT
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Patch
(190.25 KB, patch)
2017-11-30 14:31 PST
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Patch
(190.23 KB, patch)
2017-11-30 16:56 PST
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Fix Mac builds
(190.19 KB, patch)
2017-12-01 11:15 PST
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Take 2
(190.04 KB, patch)
2017-12-01 13:53 PST
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Blaze Burg
Comment 1
2017-06-21 14:19:19 PDT
Created
attachment 313550
[details]
Patch Depends on earlier renaming, so it won't build. I'll attach a combined patch when I'm done with this series.
Build Bot
Comment 2
2017-06-21 14:21:34 PDT
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`)
Build Bot
Comment 3
2017-06-21 14:21:50 PDT
Attachment 313550
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/inspector/InspectorProtocolTypes.h:156: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] Total errors found: 1 in 56 files If any of these errors are false positives, please file a bug against check-webkit-style.
Joseph Pecoraro
Comment 4
2017-06-28 16:20:31 PDT
Comment on
attachment 313550
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=313550&action=review
> Source/JavaScriptCore/ChangeLog:10 > + Move the parametric JSON array type to the JSON namespace, alongside JSON::Array. > + Rename it to ArrayOf<T> so that it reads well in most cases. This also avoids > + overloading the term "typed array" or similar concepts in the code base.
This patch seems out of date. It introduces JSON::TypedArray<T> but the changelog says it wants to introduce JSON::ArrayOf<T>. Is this just an outdated patch?
Blaze Burg
Comment 5
2017-11-30 14:31:53 PST
Created
attachment 328030
[details]
Patch
Blaze Burg
Comment 6
2017-11-30 16:56:19 PST
Created
attachment 328058
[details]
Patch
Blaze Burg
Comment 7
2017-12-01 11:15:46 PST
Created
attachment 328124
[details]
Fix Mac builds
Joseph Pecoraro
Comment 8
2017-12-01 11:28:47 PST
Comment on
attachment 328124
[details]
Fix Mac builds View in context:
https://bugs.webkit.org/attachment.cgi?id=328124&action=review
Looks good, but fix the test then I'll re-review.
> Source/WTF/wtf/JSONValues.h:435 > + Array& openAccessors() > + { > + COMPILE_ASSERT(sizeof(Array) == sizeof(ArrayOf<T>), cannot_cast); > + return *static_cast<Array*>(static_cast<ArrayBase*>(this)); > + }
I've never like the name `openAccessors()`. Maybe something like `asArray()`? Moot point though since it is only used right here.
> Tools/TestWebKitAPI/Tests/WTF/JSONValue.cpp:256 > + array->addItem(1); > + EXPECT_EQ(array->length(), 3U); > + value = array->get(2); > + EXPECT_TRUE(value->type() == JSON::Value::Type::Integer); > + int integerValue; > + EXPECT_TRUE(value->asInteger(integerValue)); > + EXPECT_EQ(integerValue, 1);
I'd expect the length to be 2 here, not 3. So the get should be `->get(1)`. The array only has the null added above. Maybe given the comment about booleans everything shifted a number.
> Tools/TestWebKitAPI/Tests/WTF/JSONValue.cpp:259 > + EXPECT_EQ(array->length(), 4U);
3U and so on...
> Tools/TestWebKitAPI/Tests/WTF/JSONValue.cpp:299 > + value = it->get(); > + EXPECT_TRUE(value->type() == JSON::Value::Type::Boolean); > + ++it; > + EXPECT_FALSE(it == array->end());
Yeah, there is no boolean in the list.
Blaze Burg
Comment 9
2017-12-01 13:07:26 PST
Comment on
attachment 328124
[details]
Fix Mac builds View in context:
https://bugs.webkit.org/attachment.cgi?id=328124&action=review
>> Tools/TestWebKitAPI/Tests/WTF/JSONValue.cpp:256 >> + EXPECT_EQ(integerValue, 1); > > I'd expect the length to be 2 here, not 3. So the get should be `->get(1)`. The array only has the null added above. Maybe given the comment about booleans everything shifted a number.
Yep, forgot to double check.
>> Tools/TestWebKitAPI/Tests/WTF/JSONValue.cpp:259 >> + EXPECT_EQ(array->length(), 4U); > > 3U and so on...
Gah. Fixing it.
Blaze Burg
Comment 10
2017-12-01 13:53:48 PST
Created
attachment 328151
[details]
Take 2
Joseph Pecoraro
Comment 11
2017-12-01 14:19:04 PST
Comment on
attachment 328151
[details]
Take 2 View in context:
https://bugs.webkit.org/attachment.cgi?id=328151&action=review
r=me. Watch the bots closely!
> Tools/TestWebKitAPI/Tests/WTF/JSONValue.cpp:240 > + Ref<JSON::ArrayOf<JSON::Value>> array = JSON::ArrayOf<JSON::Value>::create();
You normally auto these =) This test actually brings to mind that JSON doesn't allow cyclic references but a programmer could create a cyclic reference. It is certainly a programmer error to do so. But what happens in this case? auto array = JSON::ArrayOf<JSON::Value>::create(); array->addItem(array); array->toJSONString(); It seems we would infinite loop. Since there is no cycle detection. I wonder if we should have any kind of mitigations / detection with assertions. Certainly not part of this patch but something to think about. A straightforward approach would be: String toJSONString() { #ifndef NDEBUG assertValidity(); #endif StringBuilder result; result.reserveCapacity(512); writeJSON(result); return result.toString(); } But catching issues would be even better if the moment an item is added and a cycle is detected that we catch it.
WebKit Commit Bot
Comment 12
2017-12-01 15:45:55 PST
Comment on
attachment 328151
[details]
Take 2 Clearing flags on attachment: 328151 Committed
r225425
: <
https://trac.webkit.org/changeset/225425
>
WebKit Commit Bot
Comment 13
2017-12-01 15:45:57 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 14
2017-12-01 15:46:30 PST
<
rdar://problem/35807927
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug