Bug 1888649: Tweak the assertion when we can't get the parent DocAccessible in CreateDocOrRootAccessible to allow background extension pages. r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D207497
This commit is contained in:
James Teh 2024-04-17 22:53:27 +00:00
parent 16234c277e
commit ef39891ee4

View File

@ -17,6 +17,7 @@
# include "Logging.h"
#endif
#include "mozilla/BasePrincipal.h"
#include "mozilla/Components.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/PresShell.h"
@ -464,7 +465,18 @@ DocAccessible* DocManager::CreateDocOrRootAccessible(Document* aDocument) {
// XXXaaronl: ideally we would traverse the presshell chain. Since there's
// no easy way to do that, we cheat and use the document hierarchy.
parentDocAcc = GetDocAccessible(aDocument->GetInProcessParentDocument());
NS_ASSERTION(parentDocAcc, "Can't create an accessible for the document!");
// We should always get parentDocAcc except sometimes for background
// extension pages, where the parent has an invisible DocShell but the child
// does not. See bug 1888649.
NS_ASSERTION(
parentDocAcc ||
(BasePrincipal::Cast(aDocument->GetPrincipal())->AddonPolicy() &&
aDocument->GetInProcessParentDocument() &&
aDocument->GetInProcessParentDocument()->GetDocShell() &&
aDocument->GetInProcessParentDocument()
->GetDocShell()
->IsInvisible()),
"Can't create an accessible for the document!");
if (!parentDocAcc) return nullptr;
}