Bug 993423 - Don't hoist <svg:use> content into the XBL scope. r=smaug

This commit is contained in:
Bobby Holley 2014-04-14 20:38:54 -07:00
parent f223b1107f
commit db7038119f
4 changed files with 61 additions and 1 deletions

View File

@ -415,7 +415,7 @@ protected:
mozilla::dom::ParentObject p(aNativeParent);
// Note that mUseXBLScope is a no-op for chrome, and other places where we
// don't use XBL scopes.
p.mUseXBLScope = IsInAnonymousSubtree();
p.mUseXBLScope = IsInAnonymousSubtree() && !IsAnonymousContentInSVGUseSubtree();
return p;
}
@ -1012,6 +1012,9 @@ public:
bool IsInAnonymousSubtree() const;
// Note: This asserts |IsInAnonymousSubtree()|.
bool IsAnonymousContentInSVGUseSubtree() const;
// True for native anonymous content and for XBL content if the binging
// has chromeOnlyContent="true".
bool ChromeOnlyAccess() const

View File

@ -375,6 +375,15 @@ nsINode::IsInAnonymousSubtree() const
return AsContent()->IsInAnonymousSubtree();
}
bool
nsINode::IsAnonymousContentInSVGUseSubtree() const
{
MOZ_ASSERT(IsInAnonymousSubtree());
nsIContent* parent = AsContent()->GetBindingParent();
// Watch out for parentless native-anonymous subtrees.
return parent && parent->IsSVG(nsGkAtoms::use);
}
nsresult
nsINode::GetParentNode(nsIDOMNode** aParentNode)
{

View File

@ -89,6 +89,7 @@ support-files =
[test_bug965082.html]
[test_bug960820.html]
[test_bug986542.html]
[test_bug993423.html]
[test_crosscompartment_weakmap.html]
[test_frameWrapping.html]
# The JS test component we use below is only available in debug builds.

View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=993423
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 993423</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 993423 **/
SimpleTest.waitForExplicitFinish();
var sCallbackInvocations = 0;
function callback(handlerIsInXBLScope) {
ok(!handlerIsInXBLScope, "Event handler should not be in XBL scope");
if (++sCallbackInvocations == 2)
SimpleTest.finish();
}
function go() {
document.querySelector('use').setAttributeNS('http://www.w3.org/1999/xlink',
'href', location.href + '#a');
}
</script>
</head>
<body onload="go()";>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=993423">Mozilla Bug 993423</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<svg>
<symbol id="a">
<foreignObject>
<img src="about:logo" onload="var isInXBL = (function() { return this; })() != window; if (isInXBL) callback = window.wrappedJSObject.callback; callback(isInXBL);">
</foreignObject>
</symbol>
<use />
</svg>
</body>
</html>