Behaviour SwRS-MDOKFSTUDIO-TRUST-052
Every page message has a registered type and a valid envelope before any handler runs
When the host receives a value from the page, it SHALL hand it to a handler only if it is an object whose type is an own key of the table of registered message types and whose envelope fields (documentId, revision, requestId and the shared optional fields) are of their kind and within their bounds, ignoring any other value without a visible change.
Step 1 of path 1 in StRS-MDOKFSTUDIO-TRUST-009: from “The page sends a message to the host” to “The message is a registered one”.
Scenarios 6
The situations the tests check; open one to read it.
nominalRegistered type with a valid envelope
Givena previewCopyText message with a valid envelope
Whenit is checked
Thenit is accepted as a message and the host acts on it
refusalValue that is not a registered message
Givennull, a string, an array, a message of an unregistered type, and messages whose type is __proto__, constructor or toString
Wheneach is checked
Thennone is accepted, it is ignored and nothing changes on screen
boundaryIdentity fields and size bound of the envelope
| Input | Outcome |
|---|---|
| previewCopyText with a documentId of 4096 characters | accepted (longest accepted identifier) |
| the same message with a documentId of 4097 characters | refused |
| previewScroll (a page-state message) with a documentId of 5000 characters | accepted (a page-state message may carry a string of any length) |
| a message with a missing documentId or a documentId that is not a string | refused |
| a valid message with revision 7 and requestId 3 | accepted (revision and requestId are safe integers) |
| the same message with revision 1.5 | refused |
| the same message with requestId the string 3 | refused |
| the same message with a revision beyond the largest safe integer | refused |
boundaryShared optional fields of a page-state message
| Input | Outcome |
|---|---|
| previewScroll with line 2, anchorLine 3.5, scrollTop 120 and request a string | accepted |
| the same message with line 0 | refused (line, endLine, sourceLine and selectionLine are safe integers of at least 1) |
| the same message with anchorLine below 1 | refused (anchorLine is a finite number of at least 1) |
| the same message with scrollTop negative | refused (scrollTop is a finite number of at least 0) |
| the same message with editMode the string yes | refused (editMode and anchorToEditor are booleans) |
| a previewThemeMode that is not a known mode | refused (the theme mode is a known one) |
| a request that is not a string | refused (request is a string) |
boundaryFields accepted only on the type that owns them
| Input | Outcome |
|---|---|
| previewFrontmatterSave with pinLine 3 and pinViewportTop 120 | accepted |
| previewEditSave with final true and both pin fields | accepted (a pin is owned by previewFrontmatterSave and by a final previewEditSave) |
| previewEditCancel with a pin | refused |
| previewFrontmatterSave with pinViewportTop 100001 | refused (pinViewportTop is a finite number of at most 100000 in absolute value) |
| a pin with only one of pinLine and pinViewportTop | refused (the pair is complete or absent; pinLine is a source line) |
| previewReady with blockEditOpen true | accepted (blockEditOpen is a boolean only on previewReady) |
| previewEditSave with final false | accepted (final is a boolean only on previewEditSave) |
| previewScroll with blockEditOpen true | refused |
| previewEditCancel with flush true | refused (flush is true only on previewEditSave or previewFrontmatterSave) |
boundaryBlock edit and checkbox request names its editor and its lines
| Input | Outcome |
|---|---|
| previewEditOpen with editId e1, line 3 and endLine 5 | accepted |
| the same message with endLine 2 | refused (endLine is not before line) |
| the same message without editId | refused (editId is non-empty) |
| previewEditSave, previewEditCancel or previewCheckboxToggle with the same shape | the same outcome (see SwRS-MDOKFSTUDIO-GFM-021 for the extra checkbox fields) |
Implemented in 2
Tested by 2
Replaces
SwRS-MDOKFSTUDIO-CORE-066Ignore invalid page messages superseded superseded by SwRS-MDOKFSTUDIO-TRUST-052 Markdown file