Backed out changeset c15e59678a60 (bug 1017896) for reftest failures

This commit is contained in:
Carsten "Tomcat" Book 2014-06-04 08:55:59 +02:00
parent bb57f1b6e5
commit f2dd9cf6c6
5 changed files with 28 additions and 49 deletions

View File

@ -4513,11 +4513,6 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
// doing the initial document load and don't want to fire the event for this
// change.
mVisibilityState = GetVisibilityState();
// The global in the template contents owner document should be the same.
if (mTemplateContentsOwner && mTemplateContentsOwner != this) {
mTemplateContentsOwner->SetScriptGlobalObject(aScriptGlobalObject);
}
}
nsIScriptGlobalObject*
@ -9448,6 +9443,7 @@ nsDocument::GetTemplateContentsOwner()
bool hasHadScriptObject = true;
nsIScriptGlobalObject* scriptObject =
GetScriptHandlingObject(hasHadScriptObject);
NS_ENSURE_TRUE(scriptObject || !hasHadScriptObject, nullptr);
nsCOMPtr<nsIDOMDocument> domDocument;
nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDocument),
@ -9465,16 +9461,12 @@ nsDocument::GetTemplateContentsOwner()
mTemplateContentsOwner = do_QueryInterface(domDocument);
NS_ENSURE_TRUE(mTemplateContentsOwner, nullptr);
nsDocument* doc = static_cast<nsDocument*>(mTemplateContentsOwner.get());
doc->mHasHadScriptHandlingObject = hasHadScriptObject;
if (!scriptObject) {
mTemplateContentsOwner->SetScopeObject(GetScopeObject());
}
mTemplateContentsOwner->SetScriptHandlingObject(scriptObject);
// Set |doc| as the template contents owner of itself so that
// |doc| is the template contents owner of template elements created
// by |doc|.
nsDocument* doc = static_cast<nsDocument*>(mTemplateContentsOwner.get());
doc->mTemplateContentsOwner = doc;
}

View File

@ -11,7 +11,21 @@
#include "nsIAtom.h"
#include "nsRuleData.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Template)
using namespace mozilla::dom;
nsGenericHTMLElement*
NS_NewHTMLTemplateElement(already_AddRefed<nsINodeInfo>&& aNodeInfo,
FromParser aFromParser)
{
HTMLTemplateElement* it = new HTMLTemplateElement(aNodeInfo);
nsresult rv = it->Init();
if (NS_FAILED(rv)) {
delete it;
return nullptr;
}
return it;
}
namespace mozilla {
namespace dom {
@ -20,14 +34,18 @@ HTMLTemplateElement::HTMLTemplateElement(already_AddRefed<nsINodeInfo>& aNodeInf
: nsGenericHTMLElement(aNodeInfo)
{
SetHasWeirdParserInsertionMode();
}
nsresult
HTMLTemplateElement::Init()
{
nsIDocument* contentsOwner = OwnerDoc()->GetTemplateContentsOwner();
if (!contentsOwner) {
MOZ_CRASH("There should always be a template contents owner.");
}
NS_ENSURE_TRUE(contentsOwner, NS_ERROR_UNEXPECTED);
mContent = contentsOwner->CreateDocumentFragment();
mContent->SetHost(this);
return NS_OK;
}
HTMLTemplateElement::~HTMLTemplateElement()
@ -59,7 +77,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLTemplateElement)
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
NS_IMPL_ELEMENT_CLONE(HTMLTemplateElement)
NS_IMPL_ELEMENT_CLONE_WITH_INIT(HTMLTemplateElement)
JSObject*
HTMLTemplateElement::WrapNode(JSContext *aCx)

View File

@ -28,6 +28,8 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
nsresult Init();
DocumentFragment* Content()
{
return mContent;

View File

@ -3,7 +3,6 @@ support-files =
inert_style.css
[test_bug900724.html]
[test_bug1017896.html]
[test_content_element.html]
[test_nested_content_element.html]
[test_dest_insertion_points.html]

View File

@ -1,32 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1017896
-->
<head>
<title>Test template element in stale document.</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1017896">Bug 1017896</a>
<div id="container"></div>
<script>
SimpleTest.waitForExplicitFinish();
var frame = document.createElement("iframe");
document.getElementById("container").appendChild(frame);
var staleFrameDoc = frame.contentDocument;
setTimeout(function() {
var v = staleFrameDoc.createElement("div");
v.innerHTML = "<template>Content</template>";
is(v.firstChild.content.childNodes.length, 1, "Template should have one child in template content.");
SimpleTest.finish();
}, 0);
</script>
</body>
</html>