Bug 160354 - Window's named properties should be exposed on a WindowProperties object in its prototype
Summary: Window's named properties should be exposed on a WindowProperties object in i...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: http://heycam.github.io/webidl/#named...
Keywords: WebExposed
Depends on: 160596
Blocks:
  Show dependency treegraph
 
Reported: 2016-07-29 12:56 PDT by Chris Dumez
Modified: 2016-08-05 11:37 PDT (History)
7 users (show)

See Also:


Attachments
WIP Patch (24.16 KB, patch)
2016-07-29 13:00 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (30.23 KB, patch)
2016-07-29 13:44 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (31.07 KB, patch)
2016-07-29 16:47 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (31.08 KB, patch)
2016-08-05 10:24 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-07-29 12:56:46 PDT
Window's named properties should be exposed on a WindowProperties object in its prototype:
- http://heycam.github.io/webidl/#named-properties-object

Firefox and Chrome both comply with the specification. However, in WebKit, there is no "WindowProperties" object in the Window prototype chain and the named properties are exposed on the Window object itself.
Comment 1 Chris Dumez 2016-07-29 13:00:49 PDT
Created attachment 284892 [details]
WIP Patch
Comment 2 Chris Dumez 2016-07-29 13:44:01 PDT
Created attachment 284897 [details]
Patch
Comment 3 Gavin Barraclough 2016-07-29 15:42:56 PDT
Comment on attachment 284897 [details]
Patch

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

r- for index getter precedence.

> Source/WebCore/bindings/js/JSDOMWindowProperties.cpp:41
> +static bool jsDOMWindowPropertiesGetOwnPropertySlotNamedItemGetter(JSDOMWindowProperties* thisObject, Frame& frame, ExecState* exec, PropertyName propertyName, PropertySlot& slot)

Given comments below, you may just be able to fold this in to getOwnPropertySlot.

> Source/WebCore/bindings/js/JSDOMWindowProperties.cpp:87
> +    if (thisObject->classInfo() == info() && frame)

I think the info part of this check is redundant – isn't think checking the same thing as ASSERT_GC_OBJECT_INHERITS above?

> Source/WebCore/bindings/js/JSDOMWindowProperties.cpp:99
> +    if (thisObject->classInfo() == info() && frame)

Ditto – info check appears to be redundant.

> Source/WebCore/bindings/js/JSDOMWindowProperties.cpp:100
> +        return jsDOMWindowPropertiesGetOwnPropertySlotNamedItemGetter(thisObject, *frame, state, propertyName, slot);

getOwnPropertySlotByIndex should be the same as getOwnPropertySlot - own properties should take precedence, then you should check for presence on the prototype before allowing named getters.
I'd probably just make getOwnPropertySlotByIndex call getOwnPropertySlot.

> LayoutTests/fast/dom/Window/es52-globals-expected.txt:5
> +FAIL window.hasOwnProperty("div") should be true. Was false.

Maybe should keep these but also add checks for window.__proto__.__proto.hasOwnProperty("f") (I think it's the proto-proto its' now on?)

[ Or more standardsy: Object.getPrototypeOf(Object.getPrototypeOf(window)).hasOwnProperty("f") ]
Comment 4 Chris Dumez 2016-07-29 16:47:21 PDT
Created attachment 284917 [details]
Patch
Comment 5 Chris Dumez 2016-07-29 18:09:59 PDT
Comment on attachment 284917 [details]
Patch

Clearing flags on attachment: 284917

Committed r203935: <http://trac.webkit.org/changeset/203935>
Comment 6 Chris Dumez 2016-07-29 18:10:04 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 WebKit Commit Bot 2016-08-05 04:19:53 PDT
Re-opened since this is blocked by bug 160596
Comment 8 Chris Dumez 2016-08-05 08:43:17 PDT
Comment on attachment 284917 [details]
Patch

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

> Source/WebCore/bindings/js/JSDOMWindowProperties.h:61
> +    Ref<DOMWindow> m_window;

Assuming the memory regression is real, I suspect the Ref'ing of the DOMWindow here is a bad thing. I don't think we really need it either. We can probably just get the window from the JSGlobalObject when needed.
Comment 9 Chris Dumez 2016-08-05 10:24:15 PDT
Created attachment 285429 [details]
Patch
Comment 10 Chris Dumez 2016-08-05 10:25:17 PDT
Comment on attachment 285429 [details]
Patch

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

> Source/WebCore/bindings/js/JSDOMWindowProperties.cpp:87
> +    auto& window = jsCast<JSDOMWindowBase*>(thisObject->globalObject())->wrapped();

I got rid of the m_window data member (which was a string Ref to DOMWindow) and access the Window via the global object now.
Comment 11 Chris Dumez 2016-08-05 11:37:44 PDT
Comment on attachment 285429 [details]
Patch

Clearing flags on attachment: 285429

Committed r204179: <http://trac.webkit.org/changeset/204179>
Comment 12 Chris Dumez 2016-08-05 11:37:50 PDT
All reviewed patches have been landed.  Closing bug.