Markdown OKF-Schema Studio

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
InputOutcome
a report whose state does not parse, or names another documentthe recorded state is unchanged
a report with a line below 1 or not a safe integer, or a negative or non-finite scrollTopthe envelope check drops the message without a visible change (see SwRS-MDOKFSTUDIO-TRUST-052)
a sourceLine or scrollTop that fails the host's own parsethat field is left out of the recorded state
focusedBlockId longer than 200 characters, or selectedText longer than 4096 charactersthat field is left out of the recorded state
openDisclosuresonly safe integers from 0 to 9999 are kept, at most the first 100
descriptionsCollapsed not a booleanthe previous Description state is kept
nominalSwitching back to a document restores its state
InputOutcome
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 AA 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 previewit starts fresh, with no remembered state
the same sequence, but B's page reported its own scroll anchorthe 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
InputOutcome
200 remembered documents and a state stored for a 201stthe least recently used entry is gone
the oldest entry is read before the 201st is storedthe 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 documentthe entry becomes the most recent and the map does not grow
a capacity that is not validrejected; the default capacity is 200

Implemented in 4

Tested by 4

Known limits (1)