Bug 553808, assertion setting template datasources, r=smaug, a=blocking

This commit is contained in:
Neil Deakin 2010-10-26 11:17:00 -04:00
parent 65f2786c41
commit 7c2f5f4252
3 changed files with 22 additions and 12 deletions

View File

@ -1139,13 +1139,8 @@ nsXULTemplateBuilder::AttributeChanged(nsIDocument* aDocument,
// Check for a change to the 'datasources' attribute. If so, setup
// mDB by parsing the new value and rebuild.
else if (aAttribute == nsGkAtoms::datasources) {
Uninit(PR_FALSE); // Reset results
PRBool shouldDelay;
LoadDataSources(aDocument, &shouldDelay);
if (!shouldDelay)
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableRebuild));
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableLoadAndRebuild));
}
}
}
@ -1163,8 +1158,9 @@ nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument,
if (mQueryProcessor)
mQueryProcessor->Done();
// use false since content is going away anyway
Uninit(PR_FALSE);
// Pass false to Uninit since content is going away anyway
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsXULTemplateBuilder::UninitFalse));
aDocument->RemoveObserver(this);
@ -1201,7 +1197,8 @@ nsXULTemplateBuilder::NodeWillBeDestroyed(const nsINode* aNode)
mCompDB = nsnull;
mRoot = nsnull;
Uninit(PR_TRUE);
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &nsXULTemplateBuilder::UninitTrue));
}

View File

@ -152,6 +152,20 @@ public:
RebuildAll() = 0; // must be implemented by subclasses
void RunnableRebuild() { Rebuild(); }
void RunnableLoadAndRebuild() {
Uninit(PR_FALSE); // Reset results
nsCOMPtr<nsIDocument> doc = mRoot ? mRoot->GetDocument() : nsnull;
if (doc) {
PRBool shouldDelay;
LoadDataSources(doc, &shouldDelay);
if (!shouldDelay) {
Rebuild();
}
}
}
void UninitFalse() { Uninit(PR_FALSE); }
void UninitTrue() { Uninit(PR_TRUE); }
/**
* Find the <template> tag that applies for this builder

View File

@ -27,8 +27,7 @@ function checkConsole(expectedError)
{
var out = {};
consoleService.getMessageArray(out, {});
var messages = out.value || [];
is(messages[0].message, expectedError, "logged message " + expectedError);
is(out.value[0].message, expectedError, "logged message " + expectedError);
}
// each test consists of a pre function executed before the template build, an