Bug 673853 - Fix "ASSERTION: Form control should have a parent". r=bz

This commit is contained in:
Mounir Lamouri 2012-03-21 15:47:04 +01:00
Родитель 38755ca32d
Коммит 972d90ca7e
3 изменённых файлов: 26 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<script>
function boom()
{
var otherDoc = document.implementation.createDocument('', '', null);
var input = otherDoc.createElementNS("http://www.w3.org/1999/xhtml", "input");
var form = otherDoc.createElementNS("http://www.w3.org/1999/xhtml", "form");
input.setAttributeNS(null, "form", "x");
form.setAttributeNS(null, "id", "x");
input.appendChild(form);
otherDoc.appendChild(input);
}
</script>
</head>
<body onload="boom();"></body>
</html>

Просмотреть файл

@ -32,3 +32,4 @@ load 620078-2.html
load 680922-1.xul
load 682058.xhtml
load 682460.html
load 673853.html

Просмотреть файл

@ -1104,7 +1104,11 @@ nsresult
nsHTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild,
bool aUpdateValidity, bool aNotify)
{
NS_ASSERTION(aChild->GetParent(), "Form control should have a parent");
// If an element has a @form, we can assume it *might* be able to not have
// a parent and still be in the form.
NS_ASSERTION(aChild->HasAttr(kNameSpaceID_None, nsGkAtoms::form) ||
aChild->GetParent(),
"Form control should have a parent");
// Determine whether to add the new element to the elements or
// the not-in-elements list.