mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 22:07:41 +00:00
Bug 976318 - Template element contents owner document should be an inert template document. r=mrbkap
This commit is contained in:
parent
4e89716e1a
commit
c739e15afa
@ -9367,6 +9367,12 @@ nsDocument::GetTemplateContentsOwner()
|
||||
NS_ENSURE_TRUE(mTemplateContentsOwner, nullptr);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return mTemplateContentsOwner;
|
||||
|
@ -39,16 +39,8 @@ HTMLTemplateElement::HTMLTemplateElement(already_AddRefed<nsINodeInfo> aNodeInfo
|
||||
nsresult
|
||||
HTMLTemplateElement::Init()
|
||||
{
|
||||
nsIDocument* doc = OwnerDoc();
|
||||
nsIDocument* contentsOwner = doc;
|
||||
|
||||
// Used to test if the document "has a browsing context".
|
||||
nsCOMPtr<nsISupports> container = doc->GetContainer();
|
||||
if (container) {
|
||||
// GetTemplateContentsOwner lazily creates a document.
|
||||
contentsOwner = doc->GetTemplateContentsOwner();
|
||||
NS_ENSURE_TRUE(contentsOwner, NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
nsIDocument* contentsOwner = OwnerDoc()->GetTemplateContentsOwner();
|
||||
NS_ENSURE_TRUE(contentsOwner, NS_ERROR_UNEXPECTED);
|
||||
|
||||
mContent = contentsOwner->CreateDocumentFragment();
|
||||
mContent->SetHost(this);
|
||||
|
@ -50,6 +50,14 @@ ok(templateEl.content.ownerDocument != templateEl.ownerDocument, "Template shoul
|
||||
var otherTemplateEl = document.getElementById("first");
|
||||
is(templateEl.content.ownerDocument, otherTemplateEl.content.ownerDocument, "Template contents within the same document should be owned by the same template contents owner.");
|
||||
|
||||
var htmlDoc = document.implementation.createHTMLDocument();
|
||||
var otherDocTemplateEl = htmlDoc.createElement("template");
|
||||
isnot(otherDocTemplateEl.content.ownerDocument, htmlDoc, "Template content owner should be a new document.");
|
||||
|
||||
var templateOwnerDoc = otherDocTemplateEl.content.ownerDocument;
|
||||
var docCreatedTemplateEl = templateOwnerDoc.createElement("template");
|
||||
is(docCreatedTemplateEl.content.ownerDocument, templateOwnerDoc, "Template content owner of template elements created by a template document should be the template document.");
|
||||
|
||||
// Tests for XMLSerializer
|
||||
templateEl = document.getElementById("justtemplate");
|
||||
var serializer = new XMLSerializer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user