Bug 77917

Summary: Web Inspector: In Inspector.json PropertyDescriptor.writable should be declared optional
Product: WebKit Reporter: Peter Rybin <prybin>
Component: Web Inspector (Deprecated)Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, bweinstein, dglazkov, joepeck, keishi, loislo, pfeldman, pmuellr, prybin, rik, timothy, vsevik, webkit.review.bot, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
original InspectorTypeBuilder.h
none
original InspectorTypeBuilder.cpp
none
new InspectorTypeBuilder.h
none
new InspectorTypeBuilder.cpp
none
Patch
none
Patch
none
Patch none

Description Peter Rybin 2012-02-06 17:27:36 PST
Property PropertyDescriptor.writable in de facto optional. It's also conceptually optional (because only it makes sense for "data" properties, not for "accessor" properties).

Inspector.json should be fixed accordingly.

Note that it formally breaks compatibility with "1.0" and "0.1". Probably they should be patched retroactively too.
Comment 1 Peter Rybin 2012-02-06 17:34:55 PST
Created attachment 125738 [details]
Patch
Comment 2 Pavel Feldman 2012-02-07 03:26:38 PST
Comment on attachment 125738 [details]
Patch

Why should it be optional?
Comment 3 Peter Rybin 2012-02-07 04:50:28 PST
(In reply to comment #2)
> (From update of attachment 125738 [details])
> Why should it be optional?

I'm not sure it must be optional.

But it makes sense, because according to JS specification, "writable" exists only for "data" properties, i.e. there's no "writable" when there is getter or setter.
Comment 4 Peter Rybin 2012-02-07 04:51:49 PST
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 125738 [details] [details])
> > Why should it be optional?
> 
> I'm not sure it must be optional.

Another option would be to patch the code to conform with Inspector.json
Comment 5 Peter Rybin 2012-02-07 08:54:44 PST
Created attachment 125850 [details]
original InspectorTypeBuilder.h
Comment 6 Peter Rybin 2012-02-07 08:55:45 PST
Created attachment 125851 [details]
original InspectorTypeBuilder.cpp
Comment 7 Peter Rybin 2012-02-07 09:01:30 PST
Created attachment 125853 [details]
new InspectorTypeBuilder.h
Comment 8 Peter Rybin 2012-02-07 09:01:57 PST
Created attachment 125854 [details]
new InspectorTypeBuilder.cpp
Comment 9 Peter Rybin 2012-02-07 09:04:55 PST
attachments 2-5 are added here by mistake.
see correct bug: https://bugs.webkit.org/show_bug.cgi?id=77919
Comment 10 Peter Rybin 2012-02-07 14:36:17 PST
I think "writable" is ok to be optional.
I looked at the code. It seems to be correct taking that "writable" is optional.
Comment 11 Peter Rybin 2012-02-07 17:38:02 PST
Created attachment 125965 [details]
Patch
Comment 12 Peter Rybin 2012-02-07 17:42:38 PST
Additional fix is about "set" and "get" properties. They may be "undefined" in JavaScript descriptor, that gets converted to "null" in JSON format.
"Null" is a problem, because our protocol doesn't have nullable types (only type "any" allows "null" value).
Comment 13 Pavel Feldman 2012-02-08 01:50:02 PST
Comment on attachment 125965 [details]
Patch

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

> Source/WebCore/inspector/InjectedScriptSource.js:236
> +                        if (typeof descriptor.get != "function") {

Should be !==, no need for {}

> Source/WebCore/inspector/InjectedScriptSource.js:239
> +                        if (typeof descriptor.set != "function") {

ditto
Comment 14 Peter Rybin 2012-02-08 15:56:07 PST
Created attachment 126171 [details]
Patch
Comment 15 Peter Rybin 2012-02-08 16:11:14 PST
New patch makes sure the output conforms with our protocol (in all cases, including when exception is thrown).

It doesn't lose 'undefined' values of getters and setters, because conceptually accessor property HAS getter and setter, even if both are 'undefined' (this can be checked by getOwnPropertyDescriptor call on such property).

This cases undefined getter/setter showing in UI. This may or may not need fixing.
Comment 16 WebKit Review Bot 2012-02-08 17:54:48 PST
Comment on attachment 126171 [details]
Patch

Attachment 126171 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11460668

New failing tests:
inspector/runtime/runtime-getProperties.html
Comment 17 WebKit Review Bot 2012-02-09 05:01:43 PST
Comment on attachment 126171 [details]
Patch

Rejecting attachment 126171 [details] from commit-queue.

New failing tests:
inspector/runtime/runtime-getProperties.html
Full output: http://queues.webkit.org/results/11447199
Comment 18 Peter Rybin 2012-02-09 14:24:51 PST
Created attachment 126373 [details]
Patch
Comment 19 Vsevolod Vlasov 2012-02-13 06:28:12 PST
Committed r107567: <http://trac.webkit.org/changeset/107567>
Comment 20 Vsevolod Vlasov 2012-02-14 06:27:28 PST
Comment on attachment 126373 [details]
Patch

Clearing r?