whatwg / whatwg/html

Question: non-obvious steps in document loading algorithms

Open
#11,645 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

clarification topic: document lifecycle topic: navigation
Dominant language
HTML
Stars
9.4k
Forks
3.2k
PR merge metrics
PR metrics pending

Description

What is the issue with the HTML Standard?

In https://github.com/servo/servo/pull/39052#discussion_r2333195140 (the PR that implements link header processing for documents), the remark was made that for about:blank we shouldn't be scheduling a task on the network queue to process link headers. I was surprised as that wasn't my understanding of the spec text (nor behavior I would have expected), but I understand how they came to this conclusion.

In https://html.spec.whatwg.org/multipage/document-lifecycle.html#navigate-html (and other document load specifications), sometimes there are steps with paragraphs. This makes it difficult to understand whether a paragraph is a substep of a step or a new step.

The way I read the algorithm was "if about:blank, then populate body, otherwise create HTML parser. In both cases, preload link headers". That's because of the paragraph that makes this seem like a new step. I overlooked the fact that there is no step number to the left.

Can we either make these an explicit substep of step 3, to make it clear we should only be doing this in the "otherwise" branch, or make it an explicit step 4 if the expectation is that we should always run it.

Normally I resort to WPT coverage to see what browsers are doing, but no test in /preload/ contain a reference to about:blank. Therefore, I don't think we have an explicit expectation. That said, I haven't actually checked the behavior of browsers atm, as I am not sure what is "correct behavior" here, similar to my recent discovery in #11626

As a side-note, https://html.spec.whatwg.org/multipage/document-lifecycle.html#read-xml does not have any steps at all. It would be great if we could add steps, since now it is a big wall of text and it is tricky to reference back to the specification via code comments, as we sometimes scatter around implementation in various methods.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the navigate-html and read-xml sections of the HTML Standard, then review the linked Servo discussion and the existing tests under /preload/. Clarify the intended nesting or numbering of the document-loading steps, and add explicit steps to read-xml so the algorithms are easier to reference from implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.