Bug 1880262 - Try to avoid YSOD when loading to XUL prototype fails and also if YSOD has been stored in the startup cache, r=Gijs,peterv,emilio

Differential Revision: https://phabricator.services.mozilla.com/D201820
This commit is contained in:
Olli Pettay 2024-02-14 17:18:29 +00:00
parent 001fa322b6
commit 3d03f7ad0a
3 changed files with 16 additions and 1 deletions

View file

@ -669,7 +669,15 @@ nsresult PrototypeDocumentContentSink::DoneWalking() {
nsXULPrototypeCache::GetInstance()->HasPrototype(mDocumentURI,
&isCachedOnDisk);
if (!isCachedOnDisk) {
nsXULPrototypeCache::GetInstance()->WritePrototype(mCurrentPrototype);
if (!mDocument->GetDocumentElement() ||
(mDocument->GetDocumentElement()->NodeInfo()->Equals(
nsGkAtoms::parsererror) &&
mDocument->GetDocumentElement()->NodeInfo()->NamespaceEquals(
nsDependentAtomString(nsGkAtoms::nsuri_parsererror)))) {
nsXULPrototypeCache::GetInstance()->RemovePrototype(mDocumentURI);
} else {
nsXULPrototypeCache::GetInstance()->WritePrototype(mCurrentPrototype);
}
}
}

View file

@ -1283,6 +1283,12 @@ nsresult nsXULPrototypeElement::Deserialize(
return NS_ERROR_UNEXPECTED;
}
if (mNodeInfo->Equals(nsGkAtoms::parsererror) &&
mNodeInfo->NamespaceEquals(
nsDependentAtomString(nsGkAtoms::nsuri_parsererror))) {
return NS_ERROR_UNEXPECTED;
}
// Read Attributes
rv = aStream->Read32(&number);
if (NS_WARN_IF(NS_FAILED(rv))) return rv;

View file

@ -59,6 +59,7 @@ class nsXULPrototypeCache : public nsIObserver {
nsXULPrototypeDocument* GetPrototype(nsIURI* aURI);
nsresult PutPrototype(nsXULPrototypeDocument* aDocument);
void RemovePrototype(nsIURI* aURI) { mPrototypeTable.Remove(aURI); }
JS::Stencil* GetStencil(nsIURI* aURI);
nsresult PutStencil(nsIURI* aURI, JS::Stencil* aStencil);