Bug 154944

Summary: Disallow custom elements inside a window-less documents
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: DOMAssignee: Ryosuke Niwa <rniwa>
Severity: Normal CC: cdumez, commit-queue, esprehn+autocc, gyuyoung.kim, kangil.han, kling, koivisto, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 154907    
Description Flags
Fixes the bug
Fixed debug builds
Updated the bug title
Address Darin's comment and updated per recent discussion on Github koivisto: review+

Description Ryosuke Niwa 2016-03-02 17:32:41 PST
I accidentally uploaded and landed my patch for the bug 148850 in the bug 154936,
so here's a new bug to actually fix the bug 154936 was intended to fix.
Comment 1 Radar WebKit Bug Importer 2016-03-02 17:37:34 PST
Comment 2 Ryosuke Niwa 2016-03-02 23:22:18 PST
Created attachment 272734 [details]
Fixes the bug
Comment 3 Ryosuke Niwa 2016-03-02 23:53:51 PST
Created attachment 272736 [details]
Fixed debug builds
Comment 4 Ryosuke Niwa 2016-03-03 00:06:11 PST
Created attachment 272738 [details]
Updated the bug title
Comment 5 Ryosuke Niwa 2016-03-03 01:25:49 PST
I don't think the Windows EWS failure is related to this patch.
Comment 6 Darin Adler 2016-03-03 09:30:21 PST
Comment on attachment 272738 [details]
Updated the bug title

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

> Source/WebCore/bindings/js/JSDocumentCustom.cpp:155
> +        ExceptionCodeWithMessage ec;
> +        ec.code = NOT_SUPPORTED_ERR;
> +        ec.message = "Cannot define a custom element in template content's document";
> +        setDOMException(&state, ec);
> +        return jsUndefined();

Isn’t here a helper function that does more of this? If not, we should make one. The helper function should be written so that this code reads more like this:

    return throwNotSupportedException(state, "Cannot define a custom element in template content's document");

> Source/WebCore/dom/CustomElementDefinitions.h:51
> +    static Ref<CustomElementDefinitions> create() { return adoptRef(*new CustomElementDefinitions()); }

You can omit those parentheses.

> Source/WebCore/dom/Document.cpp:6359
> +    ASSERT(!m_customElementDefinitions);

Do we also want to assert document.m_customElementDefinitions is non-null?
Comment 7 Ryosuke Niwa 2016-03-03 16:17:20 PST
Created attachment 272789 [details]
Address Darin's comment and updated per recent discussion on Github
Comment 8 Ryosuke Niwa 2016-03-03 16:18:08 PST
We realized that we can't share the registry with window-less document either so we're forbidding that as well.
Comment 9 Ryosuke Niwa 2016-03-03 16:28:34 PST
Committed r197528: <http://trac.webkit.org/changeset/197528>