Bug 160797

Summary: customElements.define should retrieve lifecycle callbacks
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: DOMAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, cdumez, cmarcelo, commit-queue, esprehn+autocc, kangil.han, kling, koivisto, mmaxfield, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 160801, 160932    
Bug Blocks: 154907    
Attachments:
Description Flags
Fixes the behavior
none
Fixes the behavior
none
Archive of layout-test-results from ews102 for mac-yosemite
none
Archive of layout-test-results from ews104 for mac-yosemite-wk2
none
Archive of layout-test-results from ews114 for mac-yosemite
none
Archive of layout-test-results from ews122 for ios-simulator-elcapitan-wk2
none
Patch
none
Added one more test case
none
Patch for landing
none
Patch for landing none

Description Ryosuke Niwa 2016-08-11 20:27:16 PDT
The latest spec mandates that `customElements.define` invoke `Get(constructor, "prototype")`
as well as `Get(prototype, callbackName)` for each lifecycle callback.

Do that, and also add the support for observedAttributes.
Comment 1 Ryosuke Niwa 2016-08-11 20:40:29 PDT
Created attachment 285886 [details]
Fixes the behavior
Comment 2 Ryosuke Niwa 2016-08-11 20:42:10 PDT
Created attachment 285887 [details]
Fixes the behavior
Comment 3 Build Bot 2016-08-11 21:21:48 PDT
Comment on attachment 285887 [details]
Fixes the behavior

Attachment 285887 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/1855682

Number of test failures exceeded the failure limit.
Comment 4 Build Bot 2016-08-11 21:21:51 PDT
Created attachment 285889 [details]
Archive of layout-test-results from ews102 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 5 Build Bot 2016-08-11 21:32:22 PDT
Comment on attachment 285887 [details]
Fixes the behavior

Attachment 285887 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1855720

Number of test failures exceeded the failure limit.
Comment 6 Build Bot 2016-08-11 21:32:25 PDT
Created attachment 285890 [details]
Archive of layout-test-results from ews104 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 7 Build Bot 2016-08-11 21:41:55 PDT
Comment on attachment 285887 [details]
Fixes the behavior

Attachment 285887 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1855724

Number of test failures exceeded the failure limit.
Comment 8 Build Bot 2016-08-11 21:41:58 PDT
Created attachment 285891 [details]
Archive of layout-test-results from ews114 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 9 Build Bot 2016-08-11 21:56:53 PDT
Comment on attachment 285887 [details]
Fixes the behavior

Attachment 285887 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/1855750

Number of test failures exceeded the failure limit.
Comment 10 Build Bot 2016-08-11 21:56:56 PDT
Created attachment 285892 [details]
Archive of layout-test-results from ews122 for ios-simulator-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews122  Port: ios-simulator-elcapitan-wk2  Platform: Mac OS X 10.11.5
Comment 11 Ryosuke Niwa 2016-08-11 23:30:29 PDT
Comment on attachment 285887 [details]
Fixes the behavior

I need to fix the sequence<T> support for iterators first.
Comment 12 Ryosuke Niwa 2016-08-16 00:25:08 PDT
Created attachment 286160 [details]
Patch
Comment 13 Ryosuke Niwa 2016-08-16 00:51:45 PDT
Created attachment 286163 [details]
Added one more test case
Comment 14 Chris Dumez 2016-08-16 15:26:39 PDT
Comment on attachment 286163 [details]
Added one more test case

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

r=me with comments

> Source/WebCore/bindings/js/JSCustomElementsRegistryCustom.cpp:42
> +static JSObject* getLifecycleCallback(ExecState& state, JSValue prototype, const Identifier& id)

At the call sites, you already check that prototype is a JSObject, therefore, could we take a JSObject& here instead of a JSValue?

> Source/WebCore/bindings/js/JSCustomElementsRegistryCustom.cpp:47
> +    if (callback.isUndefined())

Seems redundant given the isFunction() check below?

> Source/WebCore/bindings/js/JSCustomElementsRegistryCustom.cpp:85
> +    // FIXME: Check re-entracy here.

typo

> Source/WebCore/bindings/js/JSCustomElementsRegistryCustom.cpp:127
> +    if (attributeChangedCallback) {

Can this really be null if there was no exception thrown? Could this simply be an assertion?

> Source/WebCore/dom/LifecycleCallbackQueue.cpp:113
> +    RELEASE_ASSERT(elementInterface);

Is this useful? I mean, it will crash on the next line anyway.

> Source/WebCore/dom/LifecycleCallbackQueue.h:30
> +#include "Element.h"

Hmm, why do we need to include Element.h here now ? :(
We should try and avoid this for the sake of my build time.
Comment 15 Ryosuke Niwa 2016-08-16 16:57:25 PDT
Committed r204540: <http://trac.webkit.org/changeset/204540>
Comment 16 Myles C. Maxfield 2016-08-16 20:12:54 PDT
I think this broke the Windows build. https://build.webkit.org/builders/Apple%20Win%20Debug%20%28Build%29/builds/96729/steps/compile-webkit/logs/stdio/text

C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(123): error C2236: unexpected token 'struct'. Did you forget a ';'? [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(123): error C2332: 'struct': missing tag name [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(123): error C2513: '': no variable declared before '=' [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(133): error C2332: 'struct': missing tag name [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(133): warning C4094: untagged 'struct' declared no symbols [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(133): error C2143: syntax error: missing ';' before '->' [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(133): error C2059: syntax error: '->' [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(139): error C2332: 'struct': missing tag name [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
C:\cygwin\home\buildbot\slave\win-debug\build\Source\WebCore\bindings\js\JSCustomElementsRegistryCustom.cpp(139): error C2062: type '' unexpected [C:\cygwin\home\buildbot\slave\win-debug\build\WebKitBuild\Debug\Source\WebCore\WebCore.vcxproj]
Comment 17 WebKit Commit Bot 2016-08-16 20:15:41 PDT
Re-opened since this is blocked by bug 160932
Comment 18 Myles C. Maxfield 2016-08-16 20:17:21 PDT
(In reply to comment #16)
> I think this broke the Windows build.

Oh, it looks like you're already working on this at https://trac.webkit.org/changeset/204547
Comment 19 Ryosuke Niwa 2016-08-16 20:17:39 PDT
I've landed two speculative fixes but didn't work. The build failure error makes zero sense to me. There is no keyword "struct" at line 123.
Comment 20 Ryosuke Niwa 2016-08-16 20:31:59 PDT
Created attachment 286261 [details]
Patch for landing
Comment 21 Ryosuke Niwa 2016-08-16 20:39:02 PDT
Created attachment 286262 [details]
Patch for landing
Comment 22 Ryosuke Niwa 2016-08-16 21:44:29 PDT
Committed r204553: <http://trac.webkit.org/changeset/204553>
Comment 23 Ryosuke Niwa 2016-09-01 16:16:47 PDT
<rdar://problem/28090374