Behaviour SwRS-MDOKFSTUDIO-TOOLBAR-079
Links in view are looked up in bounded batches
When a link with a navigation request scrolls into view, the extension SHALL ask the host once for the target of its request, in previewLinkDiscover messages of at most 64 requests, and the host answers with previewLinkTargets that lists, for each request in order, its kind and its path or reason; the host accepts a previewLinkDiscover message only when its requests are an array of at most 64 strings of at most 4096 characters each.
Step 1 of path 1 in StRS-MDOKFSTUDIO-TOOLBAR-011: from “A link comes into view” to “The target of the link is known”.
Scenarios 12
The situations the tests check; open one to read it.
nominalLink scrolls in
Givena long document with a link below the fold
Whenthe link intersects the viewport
Thenits request is sent once in a previewLinkDiscover message and the link is no longer observed
boundarySame request twice
Giventwo links with the same request
Whenboth come into view
Thenthe request is sent once
boundaryBatches of at most 64
| Requests waiting | Outcome |
|---|---|
| 130 distinct requests in view | three messages carry 64, 64 and 2 requests |
| three requests | one message carries three requests |
refusalRequests that are not looked up
| Link request or page | Outcome |
|---|---|
| #section | no previewLinkDiscover is sent for it |
| okf-link:... | no previewLinkDiscover is sent for it |
| https://x and http://x | no previewLinkDiscover is sent for them |
| mailto:a@b | no previewLinkDiscover is sent for it |
| other.md (relative link) | its request is sent when it comes into view |
| a page whose window has no IntersectionObserver | no discovery message is sent and clicks still reach the host (see SwRS-MDOKFSTUDIO-TOOLBAR-077) |
| a page with the observer, a link that intersects | its request is sent |
boundarySearch by name
| Given | Outcome |
|---|---|
| a target named in a request that exists only below node_modules, .git, _build, .venv or venv | not found |
| a target hidden by the files.exclude setting | found |
| a name matching more than 50 files under one root | the search stops at 50 files; the answer may differ from the full set |
boundaryContent replaced
| Input | Outcome |
|---|---|
| The page content is replaced and the rescan finds new links | The new links are observed; a link still in the content is not observed twice |
| Links of the old content are gone from the page | The observer releases them, so they are not kept alive |
nominalThe host answers each request
Givenrequests for an existing file, a missing file and a javascript: link
Whenthe host answers
ThenpreviewLinkTargets lists a local target with the real path and two blocked targets with their reasons, in the order of the requests
refusalNo answer for another render
| Given | Outcome |
|---|---|
| a discovery of an older request id, or of another document or revision than the host's render | no previewLinkTargets is sent |
| a discovery in flight when a new render is shown | no answer is sent when the resolution ends |
refusalA failed discovery
| Given | Outcome |
|---|---|
| a request whose resolution raises an error | the warning "Preview link discovery failed: {error}" is shown and nothing is answered for the batch |
| a preview closed meanwhile, when the error is raised | no warning is shown |
nominalLinks are asked again when the reader returns
| Given | When | Then |
|---|---|---|
| a link already looked up and a file created or deleted since | the preview window regains focus or the preview becomes visible again | the requests of the links in view are sent again and the tooltip and the warning icon follow the answer |
nominalRequests within the bounds
| Input | Outcome |
|---|---|
| 64 requests of 4096 characters | the message is accepted (the limit) |
| an empty array | accepted |
refusalRequests over the bounds or of the wrong kind
| Input | Outcome |
|---|---|
| 65 requests | refused |
| a request of 4097 characters | refused |
| a number among the requests | refused |
| a value that is not an array | refused |
Implemented in 3
Tested by 5
Known limits (2)
- a link name matching more than 50 files under one root is resolved from the first 50 found, not from all of them.
- while the preview stays focused and visible, a file created or deleted meanwhile is not noticed; the links are asked again only when the focus or the visibility comes back, or when the page is replaced.
Replaces
SwRS-MDOKFSTUDIO-TOOLBAR-083The host accepts discovery messages of bounded size superseded superseded by SwRS-MDOKFSTUDIO-TOOLBAR-079 Markdown file