Skip to content

Commit 1588579

Browse files
wacky6tidoust
andauthored
spec: update in parallel steps to resolve or reject in tasks (#36)
Updates in parallel steps for getPrediction() to follow recommendataions in #35 Co-authored-by: François Daoust <[email protected]>
1 parent 5fc08e8 commit 1588579

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

spec.bs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ Take the handwritten text "int" for example:
116116
If the application wants to delete character "t", it can remove stroke 3 and 4 from the drawing.
117117
</div>
118118

119+
<h2 id="api-idioms">API Idioms</h2>
120+
121+
The [=task source=] mentioned in this specification is the <dfn data-export id="handwriting-recognition-task-source">handwriting recognition task source</dfn>.
122+
123+
When an algorithm <dfn data-export lt="queues a Handwriting Recognition API task">queues a Handwriting Recognition API task</dfn> |T|, the user agent *MUST* [=queue a global task=] |T| on the [=handwriting recognition task source=] using the [=/global object=] of [=ECMAScript/the current realm record=].
124+
125+
Unless specified, the [=ECMAScript/realm=] for JavaScript objects constructed by algorithm steps is [=ECMAScript/the current realm record=].
126+
127+
119128
<h2 id="api-query" data-dfn-for="Navigator">Feature Query</h2>
120129

121130
Feature query interface provides allows web applications to query implementation-specific capabilities, so they can decide whether to use its feature.
@@ -638,14 +647,19 @@ If the handwriting recognizer wasn't able to recognize anything, {{HandwritingDr
638647
<div algorithm="handwriting-drawing-get-prediction">
639648
When {{HandwritingDrawing/getPrediction()}} is invoked:
640649

650+
1. If `this`.[=HandwritingDrawing/recognizer=].[=HandwritingRecognizer/active=] isn't true, return a [=a promise rejected with=] {{"InvalidStateError"}} {{DOMException}}.
651+
1. If `this`.[=HandwritingDrawing/strokes=] is empty, return a [=a promise resolved with=] a new empty [=list=].
652+
1. <a lt="convert">Convert `this` drawing into a format suitable</a> for [=handwriting recognizer=].
641653
1. Let |p| be a new Promise, run the following step [=in parallel=]
642-
1. If `this`.[=HandwritingDrawing/recognizer=].[=HandwritingRecognizer/active=] isn't true, reject |p| with a new {{DOMException}} whose name is {{"InvalidStateError"}} and abort.
643-
1. If `this`.[=HandwritingDrawing/strokes=] is empty, resolve |p| with a new empty [=list=].
644-
1. Let |result| be a list.
645-
1. <a lt="convert">Convert `this` drawing into a format suitable</a> for [=handwriting recognizer=].
646-
1. Send the converted drawing to [=handwriting recognizer=], and retrieves its prediction.
647-
1. <a lt="convert">Convert the retrieved predictions into </a> {{HandwritingPrediction}}, then [=list/append=] the converted predictions to |result|.
648-
1. Resolve |p| with |result|.
654+
1. Send the converted drawing to [=handwriting recognizer=].
655+
1. Wait for [=handwriting recognizer=] to return its predictions.
656+
1. [=Queue a Handwriting Recognition API task=] to perform the following steps:
657+
1. Let |result| be a list.
658+
1. [=list/For each=] returned prediction |pred|:
659+
1. <a lt="convert">Convert |pred| into</a> {{HandwritingPrediction}} |idl_pred|.
660+
1. [=list/Append=] |idl_pred| to |result|.
661+
1. Resolve |p| with |result|.
662+
1. Return |p|
649663
</div>
650664

651665
<h3 id="handwriting-prediction">{{HandwritingPrediction}} attributes</h3>
@@ -794,4 +808,4 @@ Below are some types of recognizer implementations, and their associated risks:
794808
795809
However, we aren't aware of any recognizer implementations that falls within this type. But we recommend using privacy protection for these models, or use a fresh / clean state for each session.
796810
797-
**Cost of fingerprinting**: the fingerprinting solution need to craft and curate a set of handwriting drawings (adversarial samples) to exploit differences across models. The cost of generating these samples may be high, but it's safe to assume a motivated party can obtain such samples.
811+
**Cost of fingerprinting**: the fingerprinting solution need to craft and curate a set of handwriting drawings (adversarial samples) to exploit differences across models. The cost of generating these samples may be high, but it's safe to assume a motivated party can obtain such samples.

0 commit comments

Comments
 (0)