Closed Bug 1779808 Opened 2 years ago Closed 2 years ago

Add a JS helper to check if a document is the current active document of a browsing context

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: smaug, Assigned: smaug)

References

Details

Attachments

(1 file)

and BC shouldn't be in bfcache or anything like that

What should happen if one plays with document.implementation.createHTMLDocument().body ?
Should that body element be treated as being in an active document/window?

Flags: needinfo?(james)
Severity: -- → N/A
Type: defect → enhancement
Priority: -- → P3

This should get tested as part of bug 1692468 and others.

This is exposing https://searchfox.org/mozilla-central/rev/99c3ccc2f02c5fff7c9850f7a0770ee92cc693f6/dom/base/Document.cpp#12730 to privileged JS.

If one wants to check if an element in a data document (document.implementation.createHTMLDocument().body for example) is in a window which is active,
something like element.ownerGlobal?.document.isActive() should work.

Pushed by opettay@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/aabd7350134e Add a JS helper to check if a document is the current active document of a browsing context, r=emilio
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch

Assuming I've reverse engineered the context correctly, yes the question is really "is the node's ownerGlobal's current document active". The point is to exclude things in bfcache or that are otherwise unreachable, not to require that the node is connected to the root node of an active document.

Flags: needinfo?(james)
No longer blocks: 1692468
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: