Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-BLOCK-205

Open editors are saved before the page hides or leaves the document

When the page hides, closes or leaves the document (a followed link, Back, another document) or the writer turns edit mode off, the extension SHALL post the text typed in every open editor as a save before the page goes away, bounded by a wait of at most 1.5 seconds for the page's answer and 1.5 seconds for the saves to reach the document.

Step 1 of path 2 in StRS-MDOKFSTUDIO-BLOCK-006: from “A block editor is open” to “The typed text is saved before the page leaves the document”.

Part of StRS-MDOKFSTUDIO-TABLE-001, outside the paths drawn on its map.

Step 1 of path 1 in StRS-MDOKFSTUDIO-TOOLBAR-009: from “The reader has typed in an open block editor and clicks a link” to “The typed text is saved”.

Scenarios 9

The situations the tests check; open one to read it.

nominalHiding the page posts the pending autosave
InputOutcome
A block editor with an autosave timer pending, and pagehide firesThe autosave is posted at once, without waiting for its 400 ms timer; no final save is posted and the editor stays open
The same, and visibilitychange to hidden firesThe same outcome
A cell editor with typed text waiting for its autosave, and the window pagehide event or visibilitychange to hidden firesOne non-final previewEditSave with the typed text is posted and the editor is not closed
No pending edit, or a page that stays visible, and a hide event firesNothing is posted
A cell editor whose last text is already posted, and the page is hiddenNo previewEditSave is posted
nominalThe host asks the page to save its editors before it switches document
Givenan open editor with typed text and a click on a link to another file
Whenthe host starts the switch
ThenpreviewFlushEdit is posted before the new document renders and the host waits for the answer

The same holds for Back and for a tab switch

nominalThe page saves its open editors and then answers the flush
Givenan open block editor with typed text, or an open cell editor with text in its text box that the table model has not yet received
WhenpreviewFlushEdit arrives
Thenthe extension copies the text of the cell text box into the table model, posts the final save of every open editor with flush true and then posts previewEditFlushed with the flush id and flushed true
boundaryAnswers and flags of the flush
InputOutcome
previewFlushEdit arrives and no editor is openpreviewEditFlushed with flushed false is posted
A block editor or no editor is open and a flush runsThe table branch (copy of the cell text) is skipped
A save by DoneThe previewEditSave has no flush field
A page that has not reported ready (or a disposed preview) and a switch startsNo flush is posted and the switch goes on
nominalLink and Back right after typing save first
InputOutcome
An editor with typed text and a click on a link to another fileThe final save is posted first, then previewLink
An editor with typed text and Back is pressedThe final save is posted first, then previewHistoryGo
A link to an anchor in the same page is clickedThe open editor is kept and no save is posted
An open editor without changes and Back is pressedOnly the navigation is posted
nominalThe host applies pending saves before it moves
Givena final save posted just before Back or just before a link to another file
Whenthe host handles previewHistoryGo or previewLink
Thenthe document holds the saved text before the other document or file opens

With no edit in flight the host moves or resolves the link at once

boundaryThe host never waits long
InputOutcome
A page that never answers the flushThe switch continues after 1.5 seconds (FLUSH_WAIT_MS is 1500)
A save that stays pending while the host waits for settlingThe switch continues after a further 1.5 seconds
refusalA save refused during a flush warns that the text was not saved
Givena flushed save of the block at lines 5-7 that the host refuses
Whenthe refusal is posted
Thena warning starts with "Markdown OKF-Schema Studio could not save the text you typed in the block at lines 5-7", gives the refusal reason and ends with "That text was not saved."

A refused save that is not a flush shows no warning; the editor shows the reason

nominalTurning edit mode off saves an open cell
InputOutcome
A cell edited and the edit mode button pressedA final previewEditSave with the edited table is posted
A cell editor unchanged, or still waiting for the host source, and edit mode turns offThe editor closes without a save

Implemented in 8

Tested by 7