Bug 259861. Warn when an XBL binding has no id attribute. r=bzbarsky

This commit is contained in:
Gleb M. Borisov 2011-03-23 10:45:20 -04:00
parent 68f964b8bb
commit e7ff531b74
3 changed files with 12 additions and 3 deletions

View File

@ -291,7 +291,7 @@ nsXBLContentSink::HandleStartElement(const PRUnichar *aName,
return rv;
if (mState == eXBL_InBinding && !mBinding) {
rv = ConstructBinding();
rv = ConstructBinding(aLineNumber);
if (NS_FAILED(rv))
return rv;
@ -555,7 +555,7 @@ nsXBLContentSink::OnOpenContainer(const PRUnichar **aAtts,
#undef ENSURE_XBL_STATE
nsresult
nsXBLContentSink::ConstructBinding()
nsXBLContentSink::ConstructBinding(PRUint32 aLineNumber)
{
nsCOMPtr<nsIContent> binding = GetCurrentContent();
nsAutoString id;
@ -581,6 +581,14 @@ nsXBLContentSink::ConstructBinding()
delete mBinding;
mBinding = nsnull;
}
} else {
nsContentUtils::ReportToConsole(nsContentUtils::eXBL_PROPERTIES,
"MissingIdAttr", nsnull, 0,
mDocumentURI,
EmptyString(),
aLineNumber, 0,
nsIScriptError::errorFlag,
"XBL Content Sink");
}
return rv;

View File

@ -136,7 +136,7 @@ protected:
#endif
// Our own helpers for constructing XBL prototype objects.
nsresult ConstructBinding();
nsresult ConstructBinding(PRUint32 aLineNumber);
void ConstructHandler(const PRUnichar **aAtts, PRUint32 aLineNumber);
void ConstructResource(const PRUnichar **aAtts, nsIAtom* aResourceType);
void ConstructImplementation(const PRUnichar **aAtts);

View File

@ -43,3 +43,4 @@ CircularExtendsBinding=Extending the XBL binding "%S" with "%S" would lead to it
CommandNotInChrome=Use of <handler command="…"> not allowed outside chrome.
MalformedXBL = An XBL file is malformed. Did you forget the XBL namespace on the bindings tag?
InvalidExtendsBinding=Extending "%S" is invalid. In general, do not extend tag names.
MissingIdAttr = An "id" attribute missing on the binding tag.