Bug 1772032 - Use DOM document node for getting SessionAcc instance. r=Jamie

Differential Revision: https://phabricator.services.mozilla.com/D148045
This commit is contained in:
Eitan Isaacson 2022-06-02 19:01:14 +00:00
parent 8fa17f2e94
commit c6fb2fffb7

View File

@ -263,11 +263,15 @@ RefPtr<SessionAccessibility> SessionAccessibility::GetInstanceFor(
MOZ_ASSERT(NS_IsMainThread());
PresShell* presShell = nullptr;
if (LocalAccessible* localAcc = aAccessible->AsLocal()) {
DocAccessible* doc = localAcc->Document();
if (doc && !doc->HasShutdown() &&
doc->DocumentNode()->IsContentDocument()) {
DocAccessible* docAcc = localAcc->Document();
// If the accessible is being shutdown from the doc's shutdown
// the doc accessible won't have a ref to a presshell anymore,
// but we should have a ref to the DOM document node, and the DOM doc
// has a ref to the presshell.
dom::Document* doc = docAcc ? docAcc->DocumentNode() : nullptr;
if (doc && doc->IsContentDocument()) {
// Only content accessibles should have an associated SessionAccessible.
presShell = doc->PresShellPtr();
presShell = doc->GetPresShell();
}
} else {
dom::CanonicalBrowsingContext* cbc =