mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 12:13:22 +00:00
Bug 1022869 - Reparent template contents owner document. r=peterv
This commit is contained in:
parent
6c7038956c
commit
a349dc56ec
@ -1715,7 +1715,7 @@ private:
|
||||
nsRefPtr<mozilla::dom::ImportManager> mImportManager;
|
||||
|
||||
#ifdef DEBUG
|
||||
protected:
|
||||
public:
|
||||
bool mWillReparent;
|
||||
#endif
|
||||
};
|
||||
|
@ -1576,6 +1576,13 @@ nsHTMLDocument::Open(JSContext* cx,
|
||||
#ifdef DEBUG
|
||||
bool willReparent = mWillReparent;
|
||||
mWillReparent = true;
|
||||
|
||||
nsDocument* templateContentsOwner =
|
||||
static_cast<nsDocument*>(mTemplateContentsOwner.get());
|
||||
|
||||
if (templateContentsOwner) {
|
||||
templateContentsOwner->mWillReparent = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Should this pass true for aForceReuseInnerWindow?
|
||||
@ -1585,6 +1592,10 @@ nsHTMLDocument::Open(JSContext* cx,
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (templateContentsOwner) {
|
||||
templateContentsOwner->mWillReparent = willReparent;
|
||||
}
|
||||
|
||||
mWillReparent = willReparent;
|
||||
#endif
|
||||
|
||||
@ -1601,6 +1612,20 @@ nsHTMLDocument::Open(JSContext* cx,
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Also reparent the template contents owner document
|
||||
// because its global is set to the same as this document.
|
||||
if (mTemplateContentsOwner) {
|
||||
JS::Rooted<JSObject*> contentsOwnerWrapper(cx,
|
||||
mTemplateContentsOwner->GetWrapper());
|
||||
if (contentsOwnerWrapper) {
|
||||
rv = mozilla::dom::ReparentWrapper(cx, contentsOwnerWrapper);
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
rv = xpc->RescueOrphansInScope(cx, oldScope->GetGlobalJSObject());
|
||||
if (rv.Failed()) {
|
||||
|
@ -164,3 +164,4 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #Windows can't chang
|
||||
[test_toJSON.html]
|
||||
[test_window_bar.html]
|
||||
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s
|
||||
[test_bug1022869.html]
|
||||
|
39
dom/tests/mochitest/bugs/test_bug1022869.html
Normal file
39
dom/tests/mochitest/bugs/test_bug1022869.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1022869
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1022869</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<iframe src="data:text/html,<html><body>"></iframe>
|
||||
<script type="application/javascript">
|
||||
|
||||
var f = document.getElementsByTagName("iframe")[0];
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
/** Test for Bug 1022869 **/
|
||||
function startTest() {
|
||||
var div = f.contentDocument.createElement("div");
|
||||
div.innerHTML = "<template>x";
|
||||
is(div.firstChild.content.ownerDocument.parentNode, null, "Should be able to access property on document.");
|
||||
f.contentDocument.open();
|
||||
is(div.firstChild.content.ownerDocument.parentNode, null, "Should be able to access property on document after document.open().");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="startTest()">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1022869">Mozilla Bug 1022869</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user