How to check if a document is fully active in Blink?

85 views
Skip to first unread message

Raphael Kubo da Costa

unread,
Feb 22, 2022, 7:29:49 AM2/22/22
to blin...@chromium.org
Hi Blinkers,

https://html.spec.whatwg.org/multipage/browsers.html#fully-active specifies what a fully active document is, and several specs check whether a document is fully active in their algorithms.

WebKit has Document::isFullyActive(), which essentially implements HTML's definition: https://github.com/WebKit/WebKit/blob/ee5042294047abd231e9f86f623d48924cbc2309/Source/WebCore/dom/Document.cpp#L2976

We don't seem to have anything similar in Blink though, and as far as I can see different parts of the code implement that check differently. Some examples I've encountered so far:
- Check ExecutionContext::IsContextDestroyed()
- Check Document::IsActive()
- Check Document::IsActive() and Document::GetFrame()
- Check
ExecutionContextLifecycleObserver::DomWindow() or ExecutionContextClient::DomWindow() (and optionally check DomWindow()->GetFrame too)

Is there a recommendation here?

Stefan Zager

unread,
Feb 22, 2022, 2:35:13 PM2/22/22
to Raphael Kubo da Costa, blin...@chromium.org
I *think* (document->domWindow() != nullptr) is the right check for that. It's more typical to see (document->GetFrame() != nullptr) in the code, and that should also work; they should be interchangeable.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/c8141c56-158e-fe2d-e5b3-a72201e63327%40intel.com.

Daniel Cheng

unread,
Feb 22, 2022, 2:51:57 PM2/22/22
to Stefan Zager, Raphael Kubo da Costa, blin...@chromium.org
I would be supportive of adding Document::IsFullyActive(), even if the underlying implementation simply checks if Document::GetFrame() or Document::domWindow() is null. That makes the intent more explicit rather than a null test of a random pointer getter/field.

Daniel

Rakina Zata Amni

unread,
Feb 25, 2022, 7:03:02 AM2/25/22
to Daniel Cheng, Stefan Zager, Raphael Kubo da Costa, blin...@chromium.org, Domenic Denicola
One particular part that might differ a bit than the currently specified definition of "fully active" is the check for whether the page's lifecycle state is "active" or not, as we should also categorize BFCached documents (and maybe prerendered documents as well?) as not "fully active" (see this section of TAG's design principles guideline). This is important because in Chrome's implementation we just keep a BFCached document as is without resetting the frame/window, so checking only those won't be enough.

(+Domenic Denicola and others are currently working on updating the spec to include the "lifecycle state" check too, probably by checking the browsing context status?)

Reply all
Reply to author
Forward
0 new messages