script: Check for render-blocking documents before continuing (#43150)

The spec expects us to check for render blocking (among some other
state) before we start procesing a document. Therefore, add those checks
and also check in the
stylesheet loader that we should only do so when we are allowed to do
so.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
Tim van der Lippe
2026-03-13 10:54:03 +01:00
committed by GitHub
parent 5fec1395c9
commit af256bd6e5
13 changed files with 190 additions and 40 deletions

View File

@@ -1135,10 +1135,6 @@ impl ScriptThread {
return false;
}
// TODO: The specification says to filter out non-renderable documents,
// as well as those for which a rendering update would be unnecessary,
// but this isn't happening here.
// TODO(#31242): the filtering of docs is extended to not exclude the ones that
// has pending initial observation targets
// https://w3c.github.io/IntersectionObserver/#pending-initial-observation
@@ -1179,6 +1175,25 @@ impl ScriptThread {
continue;
}
// Step 3. Filter non-renderable documents:
// Remove from docs any Document object doc for which any of the following are true:
if
// doc is render-blocked;
document.is_render_blocked()
// doc's visibility state is "hidden";
// TODO: Currently, this would mean that the script thread does nothing, since
// documents aren't currently correctly set to the visible state when navigating
// doc's rendering is suppressed for view transitions; or
// TODO
// doc's node navigable doesn't currently have a rendering opportunity.
//
// This is implicitly the case when we call this method
{
continue;
}
// Clear this as early as possible so that any callbacks that
// trigger new reasons for updating the rendering don't get lost.
document.clear_rendering_update_reasons();