Closed Bug 1462806 Opened 7 years ago Closed 7 years ago

The [is] attribute is not passed if element is created by nsXMLContentSink (and maybe elsewhere)

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: timdream, Assigned: timdream)

References

Details

Attachments

(1 file, 1 obsolete file)

We will need to be able to insert element from a mark-up string, possible from the document fragment created by the function in bug 1462798. The test cases in bug 1460962 covered all the other element creation cases and they all work, but not this one, which have the element created from here. https://searchfox.org/mozilla-central/rev/9769f2300a17d3dfbebcfb457b1244bd624275e3/dom/xml/nsXMLContentSink.cpp#478 There are other problems in the code too in which element created by DOMParser won't even pick up autonomous custom element, but it works in the browser console. I had to figure out that too to properly test this.
Summary: The [is] attribute is not passed if element is created by nsXMLContentSink (any maybe elsewhere) → The [is] attribute is not passed if element is created by nsXMLContentSink (and maybe elsewhere)
Attached patch diff.patch (obsolete) (deleted) — Splinter Review
The nsXMLContentSink case has been fixed. Still, need to fix the test part. For some reasons, the document created by the DOMParser does not have custom element enabled. This however only happens in the test file?
Attachment #8978049 - Attachment is obsolete: true
Attachment #8978475 - Flags: review?(bugs)
(bug 1402796 was tracking this work)
We really need wpt tests for this, assuming [is] isn't handled properly on xhtml documents.
Comment on attachment 8978475 [details] Bug 1462806 - Extract is value from nsXMLContentSink https://reviewboard.mozilla.org/r/245266/#review251270 ::: dom/xml/nsXMLContentSink.cpp:482 (Diff revision 1) > RefPtr<Element> content; > - rv = NS_NewElement(getter_AddRefs(content), ni.forget(), aFromParser); > + > + const nsAString* is = nullptr; > + if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML) || > + aNodeInfo->NamespaceEquals(kNameSpaceID_XUL)) { > + RefPtr<nsAtom> prefix, localName; Maybe I should move `nsXBLContentSink::FindValue()` to `nsXMLContentSink` and use it here? https://searchfox.org/mozilla-central/rev/9769f2300a17d3dfbebcfb457b1244bd624275e3/dom/xbl/nsXBLContentSink.cpp#576
(In reply to Olli Pettay [:smaug] from comment #5) > We really need wpt tests for this, assuming [is] isn't handled properly on > xhtml documents. Is this the test? https://raw.githubusercontent.com/w3c/web-platform-tests/master/custom-elements/parser/parser-uses-create-an-element-for-a-token-svg.svg We disable it currently. https://searchfox.org/mozilla-central/rev/0e80033a10ca4f9940c083a33d175c99ab3568e5/testing/web-platform/meta/custom-elements/parser/parser-uses-create-an-element-for-a-token-svg.svg.ini I can run the test in my local build later to see if my patch fixes this.
Yeah, it passes with my patch locally.
Comment on attachment 8978475 [details] Bug 1462806 - Extract is value from nsXMLContentSink https://reviewboard.mozilla.org/r/245266/#review251218 ::: dom/base/CustomElementRegistry.cpp:303 (Diff revision 1) > return true; > } > > - return XRE_IsParentProcess() && nsContentUtils::AllowXULXBLForPrincipal(aDoc->NodePrincipal()); > + return XRE_IsParentProcess() && > + (nsContentUtils::AllowXULXBLForPrincipal(aDoc->NodePrincipal()) || > + aDoc->AllowXULXBL()); extra space before aDoc ::: dom/xml/nsXMLContentSink.cpp:490 (Diff revision 2) > + nsContentUtils::SplitExpatName(aAtts[0], getter_AddRefs(prefix), > + getter_AddRefs(localName), &nameSpaceID); > + > + if (localName == nsGkAtoms::is) { > + nsDependentString val(aAtts[1]); > + is = &val; So, val is a valid object while it is on stack, and it is on stack only until the end of the block. So /is/ ends up pointing to a deleted object once we're out of the scope.
Attachment #8978475 - Flags: review?(bugs) → review-
thanks for looking into wpt results and I guess that existing test is good enough for now.
Comment on attachment 8978475 [details] Bug 1462806 - Extract is value from nsXMLContentSink https://reviewboard.mozilla.org/r/245266/#review251364 ::: dom/base/CustomElementRegistry.cpp:305 (Diff revision 3) > return true; > } > > - return XRE_IsParentProcess() && nsContentUtils::AllowXULXBLForPrincipal(aDoc->NodePrincipal()); > + return XRE_IsParentProcess() && > + (nsContentUtils::AllowXULXBLForPrincipal(aDoc->NodePrincipal()) || > + aDoc->AllowXULXBL());; You don't need these both. aDoc->AllowXULXBL() should be enough. AllowXULXBL calls the contentutils method internally https://searchfox.org/mozilla-central/rev/8affe6e83188787eb61fe0528eeb6eef6081ba06/dom/base/nsDocument.cpp#4958 ::: dom/xml/nsXMLContentSink.cpp:465 (Diff revision 3) > mParser = aParser; > return NS_OK; > } > > +static bool > +FindIsAttrValue(const char16_t **aAtts, const char16_t **aResult) ** should go with the type, not with the argument name. So, const char16_t** aAtts and same with aResult
Attachment #8978475 - Flags: review?(bugs) → review+
Pushed by timdream@gmail.com: https://hg.mozilla.org/integration/autoland/rev/2c00eeb83675 Extract is value from nsXMLContentSink r=smaug
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: