From f3bcaf9f88aad2c423ebcd61121562f9834187d4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Apr 2024 17:11:27 +0200 Subject: Merging upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- dom/ipc/WindowGlobalParent.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'dom/ipc/WindowGlobalParent.cpp') diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 0e345e9107..c1fc607634 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -609,6 +609,23 @@ bool WindowGlobalParent::IsCurrentGlobal() { return CanSend() && BrowsingContext()->GetCurrentWindowGlobal() == this; } +bool WindowGlobalParent::IsActiveInTab() { + if (!CanSend()) { + return false; + } + + CanonicalBrowsingContext* bc = BrowsingContext(); + if (!bc || bc->GetCurrentWindowGlobal() != this) { + return false; + } + + // We check the top BC so we don't need to worry about getting a stale value. + // That may not be necessary. + MOZ_ASSERT(bc->Top()->IsInBFCache() == bc->IsInBFCache(), + "BFCache bit out of sync?"); + return bc->AncestorsAreCurrent() && !bc->Top()->IsInBFCache(); +} + namespace { class ShareHandler final : public PromiseNativeHandler { -- cgit v1.2.3