Skip to content

Commit

Permalink
Bug 1419799 - Fix nsContentUtils::IsInSameAnonymousTree in Shadow DOM…
Browse files Browse the repository at this point in the history
…. r=smaug

No need to consider multiple shadow roots as it is only supported in Shadow DOM
v0, which is deprecated now.

MozReview-Commit-ID: BKemIBiMx1Q
  • Loading branch information
Jessica Jong committed Dec 8, 2017
1 parent 9fcaf90 commit 765510c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
17 changes: 17 additions & 0 deletions dom/base/crashtests/1419799.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<head>
<script>
try { o1 = document.createElement('textarea') } catch(e) { }
try { o2 = document.createElement('div') } catch(e) { }
try { o3 = document.createElement('map') } catch(e) { }
try { document.documentElement.appendChild(o2) } catch(e) { }
try { o2.appendChild(o1) } catch(e) { }
try { document.documentElement.getClientRects() } catch(e) { }
try { o4 = o2.attachShadow({ mode: "open" }); } catch(e) { }
try { o1.appendChild(o3) } catch(e) { }
try { o5 = o3.parentElement } catch(e) { }
try { o3.outerHTML = "\n" } catch(e) { }
try { o4.prepend("", o5, "") } catch(e) { }
</script>
</head>
</html>
1 change: 1 addition & 0 deletions dom/base/crashtests/crashtests.list
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,4 @@ load 1406109-1.html
pref(dom.webcomponents.enabled,true) load 1324463.html
pref(dom.webcomponents.customelements.enabled,true) load 1413815.html
load 1411473.html
pref(dom.webcomponents.enabled,true) load 1419799.html
12 changes: 1 addition & 11 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5450,17 +5450,7 @@ nsContentUtils::IsInSameAnonymousTree(const nsINode* aNode,
return aContent->GetBindingParent() == nullptr;
}

const nsIContent* nodeAsContent = static_cast<const nsIContent*>(aNode);

// For nodes in a shadow tree, it is insufficient to simply compare
// the binding parent because a node may host multiple ShadowRoots,
// thus nodes in different shadow tree may have the same binding parent.
if (aNode->IsInShadowTree()) {
return nodeAsContent->GetContainingShadow() ==
aContent->GetContainingShadow();
}

return nodeAsContent->GetBindingParent() == aContent->GetBindingParent();
return aNode->AsContent()->GetBindingParent() == aContent->GetBindingParent();
}

/* static */
Expand Down

0 comments on commit 765510c

Please sign in to comment.