WebKit Bugzilla
Attachment 341117 Details for
Bug 183586
: connectedCallback is invoked during the removal of the element inside another element's connectedCallback
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-183586-20180523213831.patch (text/plain), 8.08 KB, created by
Rob Buis
on 2018-05-23 12:38:33 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2018-05-23 12:38:33 PDT
Size:
8.08 KB
patch
obsolete
>Subversion Revision: 232119 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c91c63967200b235101990150cb1b4ec44f9746b..d050eb572839b73bb01238df26dbf837d774445c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2018-05-23 Rob Buis <rbuis@igalia.com> >+ >+ Custom Elements: connectedCallback is invoked at unexpected timing >+ https://bugs.webkit.org/show_bug.cgi?id=183586 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When creating an element [1] the steps are different for HTML fragment >+ parsing and custom elements. Particularly in HTML fragment parsing mode >+ synchronous custom elements flag should be unset. So in this case [2] >+ follow step 6.2. >+ >+ [1] https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token >+ [2] https://dom.spec.whatwg.org/#concept-create-element >+ >+ Test: imported/w3c/web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing.html >+ >+ * dom/Element.cpp: >+ (WebCore::Element::insertedIntoAncestor): >+ (WebCore::Element::enqueueToUpgrade): >+ * html/parser/HTMLDocumentParser.cpp: >+ (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): >+ > 2018-05-23 Michael Catanzaro <mcatanzaro@igalia.com> > > [GTK] Silence GCC 8 warnings >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index 06c4a06302984513da02fdad0b49da7348fb39da..739edab6ad43df06f77444a8353fcd217bfc3cfc 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -1977,10 +1977,10 @@ void Element::enqueueToUpgrade(JSCustomElementInterface& elementInterface) > InspectorInstrumentation::didChangeCustomElementState(*this); > > auto& data = ensureElementRareData(); >- ASSERT(!data.customElementReactionQueue()); >- >- data.setCustomElementReactionQueue(std::make_unique<CustomElementReactionQueue>(elementInterface)); >- data.customElementReactionQueue()->enqueueElementUpgrade(*this); >+ if (!data.customElementReactionQueue()) { >+ data.setCustomElementReactionQueue(std::make_unique<CustomElementReactionQueue>(elementInterface)); >+ data.customElementReactionQueue()->enqueueElementUpgrade(*this); >+ } > } > > CustomElementReactionQueue* Element::reactionQueue() const >diff --git a/Source/WebCore/html/parser/HTMLDocumentParser.cpp b/Source/WebCore/html/parser/HTMLDocumentParser.cpp >index dcf49e9031cf37deb391b85e6d1ba976bfd6aa16..721d44e981ea7b1d80beaaf1e7c8b223be4fe5b1 100644 >--- a/Source/WebCore/html/parser/HTMLDocumentParser.cpp >+++ b/Source/WebCore/html/parser/HTMLDocumentParser.cpp >@@ -31,6 +31,7 @@ > #include "DocumentLoader.h" > #include "Frame.h" > #include "HTMLDocument.h" >+#include "HTMLElement.h" > #include "HTMLParserScheduler.h" > #include "HTMLPreloadScanner.h" > #include "HTMLScriptRunner.h" >@@ -199,8 +200,15 @@ void HTMLDocumentParser::runScriptsForPausedTreeBuilder() > > // https://html.spec.whatwg.org/#create-an-element-for-the-token > auto& elementInterface = constructionData->elementInterface.get(); >- auto newElement = elementInterface.constructElementWithFallback(*document(), constructionData->name); >- m_treeBuilder->didCreateCustomOrCallbackElement(WTFMove(newElement), *constructionData); >+ if (isParsingFragment()) { >+ ASSERT(Document::validateCustomElementName(constructionData->name)); >+ auto newElement = HTMLElement::create(QualifiedName(nullAtom(), constructionData->name, HTMLNames::xhtmlNamespaceURI), *document()); >+ newElement->enqueueToUpgrade(elementInterface); >+ m_treeBuilder->didCreateCustomOrCallbackElement(WTFMove(newElement), *constructionData); >+ } else { >+ auto newElement = elementInterface.constructElementWithFallback(*document(), constructionData->name); >+ m_treeBuilder->didCreateCustomOrCallbackElement(WTFMove(newElement), *constructionData); >+ } > return; > } > >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index cd78e6af9ef6dcf3961def9f7fc0a7cefafce1f4..feb5018e65b08dcdcb4c10353fc20b2db84b79f2 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,12 @@ >+2018-05-23 Rob Buis <rbuis@igalia.com> >+ >+ Custom Elements: connectedCallback is invoked at unexpected timing >+ https://bugs.webkit.org/show_bug.cgi?id=183586 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing.html: Added. >+ > 2018-05-22 Manuel Rego Casasnovas <rego@igalia.com> > > [css-text] Import WPT test suite >diff --git a/LayoutTests/imported/w3c/web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..a25bbe10dac1d6d0946241939df03de991601055 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing-expected.txt >@@ -0,0 +1,10 @@ >+ >+PASS Inserting a custom element into the document using HTML fragment parsing must not call connectedCallback. >+PASS Inserting a custom element into the document of the template elements using HTML fragment parsing must not call connectedCallback. >+PASS Inserting a custom element into a new document using HTML fragment parsing must not call connectedCallback. >+PASS Inserting a custom element into a cloned document using HTML fragment parsing must not call connectedCallback. >+PASS Inserting a custom element into a document created by createHTMLDocument using HTML fragment parsing must not call connectedCallback. >+PASS Inserting a custom element into an HTML document created by createDocument using HTML fragment parsing must not call connectedCallback. >+PASS Inserting a custom element into the document of an iframe using HTML fragment parsing must not call connectedCallback. >+PASS Inserting a custom element into an HTML document fetched by XHR using HTML fragment parsing must not call connectedCallback. >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing.html b/LayoutTests/imported/w3c/web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing.html >new file mode 100644 >index 0000000000000000000000000000000000000000..70fcc14d2b28e6ed3d1e4fd8f8492ab56a575094 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing.html >@@ -0,0 +1,45 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<title>Custom Elements: connectedCallback not called during HTML fragment parsing</title> >+<meta name="author" title="Rob Buis" href="mailto:rbuis@igalia.com"> >+<meta name="assert" content="connectedCallback must not be called during HTML fragment parsing"> >+<link rel="help" href="https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token"> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script src="resources/custom-elements-helpers.js"></script> >+</head> >+<body> >+<div id="log"></div> >+<script> >+ >+var calls = 0; >+class Parenter extends HTMLElement { >+ connectedCallback() { >+ const child = this.firstChild; >+ this.removeChild(child); >+ this.appendChild(child); >+ } >+} >+customElements.define('x-parenter', Parenter); >+class Child extends HTMLElement { >+ connectedCallback() { calls++; } >+} >+customElements.define('x-child', Child); >+ >+document_types().forEach(function (entry) { >+ var documentName = entry.name; >+ var getDocument = entry.create; >+ >+ promise_test(function () { >+ return getDocument().then(function (doc) { >+ calls = 0; >+ document.body.innerHTML = '<x-parenter><x-child></x-child></x-parenter>'; >+ assert_equals(calls, 1); >+ }); >+ }, 'Inserting a custom element into ' + documentName + ' using HTML fragment parsing must not call connectedCallback.'); >+}); >+ >+</script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 183586
:
335672
|
340977
|
340981
|
341004
|
341117
|
341135
|
341186
|
341211
|
341272
|
341278
|
345570
|
345834
|
346614
|
347145
|
357032