From e31a0e9014a95d876a4e166587cd1ac02027fe07 Mon Sep 17 00:00:00 2001 From: Jiewei Qian Date: Fri, 20 Sep 2024 14:16:53 +1000 Subject: [PATCH 1/5] WIP: spec: update in parallel steps to resolve or reject in enqueued tasks --- spec.bs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/spec.bs b/spec.bs index 4fe4ffd..fa7b2b2 100644 --- a/spec.bs +++ b/spec.bs @@ -639,14 +639,19 @@ If the handwriting recognizer wasn't able to recognize anything, {{HandwritingDr
When {{HandwritingDrawing/getPrediction()}} is invoked: + 1. If `this`.[=HandwritingDrawing/recognizer=].[=HandwritingRecognizer/active=] isn't true, return a [=/a promise rejected with=] {{"InvalidStateError"}} {{DOMException}}. + 1. If `this`.[=HandwritingDrawing/strokes=] is empty, return a [=a promise resolved with=] a new empty [=list=]. + 1. Convert `this` drawing into a format suitable for [=handwriting recognizer=]. 1. Let |p| be a new Promise, run the following step [=in parallel=] - 1. If `this`.[=HandwritingDrawing/recognizer=].[=HandwritingRecognizer/active=] isn't true, reject |p| with a new {{DOMException}} whose name is {{"InvalidStateError"}} and abort. - 1. If `this`.[=HandwritingDrawing/strokes=] is empty, resolve |p| with a new empty [=list=]. - 1. Let |result| be a list. - 1. Convert `this` drawing into a format suitable for [=handwriting recognizer=]. - 1. Send the converted drawing to [=handwriting recognizer=], and retrieves its prediction. - 1. Convert the retrieved predictions into {{HandwritingPrediction}}, then [=list/append=] the converted predictions to |result|. - 1. Resolve |p| with |result|. + 1. Send the converted drawing to [=handwriting recognizer=]. + 1. Wait for [=handwriting recognizer=] to return its predictions. + 1. Queue a global task, perform the following steps: + 1. Let |result| be a list. + 1. [=list/For each=] returned prediction |pred|: + 1. Convert |pred| it into {{HandwritingPrediction}} |idl_pred|. + 1. [=list/Append=] |idl_pred| to |result|. + 1. Resolve |p| with |result|. + 1. Return |p|

{{HandwritingPrediction}} attributes

@@ -795,4 +800,4 @@ Below are some types of recognizer implementations, and their associated risks: 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. -**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. \ No newline at end of file +**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. From eb3e89e8b6fceaf9fc799bb424e3660d6099cd3b Mon Sep 17 00:00:00 2001 From: Jiewei Qian Date: Tue, 24 Sep 2024 18:23:10 +1000 Subject: [PATCH 2/5] wip realm --- spec.bs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec.bs b/spec.bs index fa7b2b2..efaee80 100644 --- a/spec.bs +++ b/spec.bs @@ -116,6 +116,15 @@ Take the handwritten text "int" for example: If the application wants to delete character "t", it can remove stroke 3 and 4 from the drawing. +

API Idioms

+ +The [=task source=] mentioned in this specification is the handwriting recognition task source. + +When an algorithm queues a Handwriting Recognition API task |T|, the user agent *MUST* [=queue a global task=] |T| on the [=handwriting recognition task source=] using the [=global object=] of the [[ecma-262#current-realm|current realm]]. + +Unless specified, the [[ecma-262#realm|realm]] for JavaScript objects constructed by algorithm steps is the [[ecma-262#current-realm|current realm]]. + +

Feature Query

Feature query interface provides allows web applications to query implementation-specific capabilities, so they can decide whether to use its feature. @@ -645,7 +654,7 @@ If the handwriting recognizer wasn't able to recognize anything, {{HandwritingDr 1. Let |p| be a new Promise, run the following step [=in parallel=] 1. Send the converted drawing to [=handwriting recognizer=]. 1. Wait for [=handwriting recognizer=] to return its predictions. - 1. Queue a global task, perform the following steps: + 1. [=Queues a Handwriting Recognition API task=], perform the following steps: 1. Let |result| be a list. 1. [=list/For each=] returned prediction |pred|: 1. Convert |pred| it into {{HandwritingPrediction}} |idl_pred|. From 10fcdc2025fdc0de623563f97d964687de2bfd00 Mon Sep 17 00:00:00 2001 From: Jiewei Qian Date: Thu, 7 Nov 2024 13:55:16 +1100 Subject: [PATCH 3/5] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Daoust --- spec.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.bs b/spec.bs index efaee80..5cffbc7 100644 --- a/spec.bs +++ b/spec.bs @@ -120,9 +120,9 @@ Take the handwritten text "int" for example: The [=task source=] mentioned in this specification is the handwriting recognition task source. -When an algorithm queues a Handwriting Recognition API task |T|, the user agent *MUST* [=queue a global task=] |T| on the [=handwriting recognition task source=] using the [=global object=] of the [[ecma-262#current-realm|current realm]]. +When an algorithm queues a Handwriting Recognition API task |T|, the user agent *MUST* [=queue a global task=] |T| on the [=handwriting recognition task source=] using the [=/global object=] of [=the current realm record=]. -Unless specified, the [[ecma-262#realm|realm]] for JavaScript objects constructed by algorithm steps is the [[ecma-262#current-realm|current realm]]. +Unless specified, the [=ECMAScript/realm=] for JavaScript objects constructed by algorithm steps is [=the current realm record=].

Feature Query

@@ -654,7 +654,7 @@ If the handwriting recognizer wasn't able to recognize anything, {{HandwritingDr 1. Let |p| be a new Promise, run the following step [=in parallel=] 1. Send the converted drawing to [=handwriting recognizer=]. 1. Wait for [=handwriting recognizer=] to return its predictions. - 1. [=Queues a Handwriting Recognition API task=], perform the following steps: + 1. [=Queue a Handwriting Recognition API task=] to perform the following steps: 1. Let |result| be a list. 1. [=list/For each=] returned prediction |pred|: 1. Convert |pred| it into {{HandwritingPrediction}} |idl_pred|. From d140c8637f8245f11171fbe87c207c2a52f4c681 Mon Sep 17 00:00:00 2001 From: Jiewei Qian Date: Thu, 7 Nov 2024 14:25:26 +1100 Subject: [PATCH 4/5] fix references --- spec.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.bs b/spec.bs index 5cffbc7..02ef457 100644 --- a/spec.bs +++ b/spec.bs @@ -120,9 +120,9 @@ Take the handwritten text "int" for example: The [=task source=] mentioned in this specification is the handwriting recognition task source. -When an algorithm queues a Handwriting Recognition API task |T|, the user agent *MUST* [=queue a global task=] |T| on the [=handwriting recognition task source=] using the [=/global object=] of [=the current realm record=]. +When an algorithm queues a Handwriting Recognition API task |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=]. -Unless specified, the [=ECMAScript/realm=] for JavaScript objects constructed by algorithm steps is [=the current realm record=]. +Unless specified, the [=ECMAScript/realm=] for JavaScript objects constructed by algorithm steps is [=ECMAScript/the current realm record=].

Feature Query

@@ -648,7 +648,7 @@ If the handwriting recognizer wasn't able to recognize anything, {{HandwritingDr
When {{HandwritingDrawing/getPrediction()}} is invoked: - 1. If `this`.[=HandwritingDrawing/recognizer=].[=HandwritingRecognizer/active=] isn't true, return a [=/a promise rejected with=] {{"InvalidStateError"}} {{DOMException}}. + 1. If `this`.[=HandwritingDrawing/recognizer=].[=HandwritingRecognizer/active=] isn't true, return a [=a promise rejected with=] {{"InvalidStateError"}} {{DOMException}}. 1. If `this`.[=HandwritingDrawing/strokes=] is empty, return a [=a promise resolved with=] a new empty [=list=]. 1. Convert `this` drawing into a format suitable for [=handwriting recognizer=]. 1. Let |p| be a new Promise, run the following step [=in parallel=] From cac60eb221f43b3b63944ea60efff408b0cf2d90 Mon Sep 17 00:00:00 2001 From: Jiewei Qian Date: Fri, 8 Nov 2024 12:04:42 +1100 Subject: [PATCH 5/5] Update spec.bs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Daoust --- spec.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.bs b/spec.bs index 02ef457..529dcbb 100644 --- a/spec.bs +++ b/spec.bs @@ -657,7 +657,7 @@ If the handwriting recognizer wasn't able to recognize anything, {{HandwritingDr 1. [=Queue a Handwriting Recognition API task=] to perform the following steps: 1. Let |result| be a list. 1. [=list/For each=] returned prediction |pred|: - 1. Convert |pred| it into {{HandwritingPrediction}} |idl_pred|. + 1. Convert |pred| into {{HandwritingPrediction}} |idl_pred|. 1. [=list/Append=] |idl_pred| to |result|. 1. Resolve |p| with |result|. 1. Return |p|