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
| Input | Outcome |
|---|---|
| A block editor with an autosave timer pending, and pagehide fires | The 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 fires | The same outcome |
| A cell editor with typed text waiting for its autosave, and the window pagehide event or visibilitychange to hidden fires | One 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 fires | Nothing is posted |
| A cell editor whose last text is already posted, and the page is hidden | No previewEditSave is posted |
nominalThe host asks the page to save its editors before it switches document
The same holds for Back and for a tab switch
nominalThe page saves its open editors and then answers the flush
boundaryAnswers and flags of the flush
| Input | Outcome |
|---|---|
| previewFlushEdit arrives and no editor is open | previewEditFlushed with flushed false is posted |
| A block editor or no editor is open and a flush runs | The table branch (copy of the cell text) is skipped |
| A save by Done | The previewEditSave has no flush field |
| A page that has not reported ready (or a disposed preview) and a switch starts | No flush is posted and the switch goes on |
nominalLink and Back right after typing save first
| Input | Outcome |
|---|---|
| An editor with typed text and a click on a link to another file | The final save is posted first, then previewLink |
| An editor with typed text and Back is pressed | The final save is posted first, then previewHistoryGo |
| A link to an anchor in the same page is clicked | The open editor is kept and no save is posted |
| An open editor without changes and Back is pressed | Only the navigation is posted |
nominalThe host applies pending saves before it moves
With no edit in flight the host moves or resolves the link at once
boundaryThe host never waits long
| Input | Outcome |
|---|---|
| A page that never answers the flush | The switch continues after 1.5 seconds (FLUSH_WAIT_MS is 1500) |
| A save that stays pending while the host waits for settling | The switch continues after a further 1.5 seconds |
refusalA save refused during a flush warns that the 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
| Input | Outcome |
|---|---|
| A cell edited and the edit mode button pressed | A final previewEditSave with the edited table is posted |
| A cell editor unchanged, or still waiting for the host source, and edit mode turns off | The editor closes without a save |
Implemented in 8
Tested by 7
- test/core/preview/flushWait.test.tsunit
- test/integration/previewHistory.test.tsintegration
- test/integration/realInput/flushBeforeNavigate.tsintegration
- test/page/fmtableReqTable.requirements.test.tsunit
- test/page/runtimeBlockEditor.test.tsunit
- test/page/runtimeEditorFlush.test.tsunit
- test/session/toolbarReq.requirements.test.tsunit