Behaviour SwRS-MDOKFSTUDIO-LIFE-125
The reading state of recent documents is saved within bounds
When the page reports its reading state while the reader scrolls, the extension SHALL write the state and post previewState at most once per 100 ms with the last state always reaching the host, record each valid report for the preview's document, and remember the reading state of at most the 200 most recent documents.
Another outcome at step 1 of path 2 in StRS-MDOKFSTUDIO-LIFE-010, in the state “The preview is scrolled to a reading line”.
Part of StRS-MDOKFSTUDIO-LIFE-014, outside the paths drawn on its map.
Scenarios 6
The situations the tests check; open one to read it.
nominalScroll burst
Givenforty scroll frames in 100 ms
Whenthe state is written
Thenthe first write goes through at once, one more follows with the last state, and previewScroll messages are never delayed
boundaryHidden page
Givena held-back state and the page becoming hidden
Whenthe visibility changes
Thenthe held-back state is written and posted at once
nominalThe host records the state of a report
Givena previewState with line 4 and scroll 88 for the current render
Whenthe host receives it
Thenthe preview's state holds sourceLine 4 and scrollTop 88; a previewScroll, a previewReveal and a previewRefresh also carry the state and record it the same way
refusalInvalid state report
| Input | Outcome |
|---|---|
| a report whose state does not parse, or names another document | the recorded state is unchanged |
| a report with a line below 1 or not a safe integer, or a negative or non-finite scrollTop | the envelope check drops the message without a visible change (see SwRS-MDOKFSTUDIO-TRUST-052) |
| a sourceLine or scrollTop that fails the host's own parse | that field is left out of the recorded state |
| focusedBlockId longer than 200 characters, or selectedText longer than 4096 characters | that field is left out of the recorded state |
| openDisclosures | only safe integers from 0 to 9999 are kept, at most the first 100 |
| descriptionsCollapsed not a boolean | the previous Description state is kept |
nominalSwitching back to a document restores its state
| Input | Outcome |
|---|---|
| a preview scrolled to line 80 of A, with a focused block and open sections, then switched to B (which reported no scroll anchor) and back to A | A renders again with its scroll line 80 through the stored anchor and with the focused block, the selection, the open sections and the Description state it had |
| a document never shown in this preview | it starts fresh, with no remembered state |
| the same sequence, but B's page reported its own scroll anchor | the scroll line of A is not kept; with a following preview the render starts at the editor's first visible line |
boundaryThe 200 most recent documents
| Input | Outcome |
|---|---|
| 200 remembered documents and a state stored for a 201st | the least recently used entry is gone |
| the oldest entry is read before the 201st is stored | the entry that was read is kept and the next oldest is evicted; a peek does not protect an entry |
| a state stored again for a remembered document | the entry becomes the most recent and the map does not grow |
| a capacity that is not valid | rejected; the default capacity is 200 |
Implemented in 4
Tested by 4
Known limits (1)
- a previewReady whose descriptionsCollapsed is not a boolean leaves the workspace choice unchanged, but the recorded state of the session loses that field (undefined) instead of keeping the previous Description state.