Bug 1324463. Fix crash when xbl:children is stuck into shadow DOM. r=smaug

MozReview-Commit-ID: C602pPbIfih
This commit is contained in:
Boris Zbarsky 2017-10-11 22:19:10 -04:00
parent 320337bba3
commit 3fc7b4c919
3 changed files with 20 additions and 3 deletions

View File

@ -508,7 +508,7 @@ ShadowRoot::ContentAppended(nsIDocument* aDocument,
// Add insertion point to destination insertion points of fallback content.
if (nsContentUtils::IsContentInsertionPoint(aContainer)) {
HTMLContentElement* content = HTMLContentElement::FromContent(aContainer);
if (content->MatchedNodes().IsEmpty()) {
if (content && content->MatchedNodes().IsEmpty()) {
currentChild->DestInsertionPoints().AppendElement(aContainer);
}
}
@ -538,7 +538,7 @@ ShadowRoot::ContentInserted(nsIDocument* aDocument,
// Add insertion point to destination insertion points of fallback content.
if (nsContentUtils::IsContentInsertionPoint(aContainer)) {
HTMLContentElement* content = HTMLContentElement::FromContent(aContainer);
if (content->MatchedNodes().IsEmpty()) {
if (content && content->MatchedNodes().IsEmpty()) {
aChild->DestInsertionPoints().AppendElement(aContainer);
}
}
@ -563,7 +563,7 @@ ShadowRoot::ContentRemoved(nsIDocument* aDocument,
// fallback content.
if (nsContentUtils::IsContentInsertionPoint(aContainer)) {
HTMLContentElement* content = HTMLContentElement::FromContent(aContainer);
if (content->MatchedNodes().IsEmpty()) {
if (content && content->MatchedNodes().IsEmpty()) {
aChild->DestInsertionPoints().Clear();
}
}

View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<script>
// requires: user_pref("dom.webcomponents.enabled", true);
addEventListener("DOMContentLoaded", function(){
let o_0 = document.createElement("span").createShadowRoot();
let o_1 = document.createElementNS("http://www.mozilla.org/xbl", "binding");
let o_2 = document.createElementNS("http://www.mozilla.org/xbl", "children");
let o_3 = document.createTextNode("");
o_0.appendChild(o_1);
o_1.appendChild(o_2);
o_2.appendChild(o_3);
o_2.removeChild(o_3);
});
</script>
</html>

View File

@ -231,3 +231,4 @@ load 1400701.html
load 1403377.html
load 1405771.html
load 1406109-1.html
pref(dom.webcomponents.enabled,true) load 1324463.html