From 44dac718961d0aae77160dbbc524507aac7e7a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E4=B8=9C=E5=8B=8B=20=7C=20=E9=87=91=E6=9D=B1?= =?UTF-8?q?=E5=8B=B3=20=7C=20=EA=B9=80=EB=8F=99=ED=9B=88=20=7C=20Jin=20Don?= =?UTF-8?q?gxun?= Date: Tue, 10 Nov 2026 20:44:29 +0800 Subject: [PATCH] =?UTF-8?q?Use=20the=20operation=E2=80=99s=20Window=20and?= =?UTF-8?q?=20enforce=20policy=20for=20static=20speech=20recognition=20met?= =?UTF-8?q?hods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.bs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/index.bs b/index.bs index d446255..a1488ee 100644 --- a/index.bs +++ b/index.bs @@ -479,6 +479,9 @@ See SpeechRecognition Methods +

The speech recognition task source is a [=task source=] used to settle promises for +{{SpeechRecognition/available()}} and {{SpeechRecognition/install()}}.

+
start() method
@@ -533,8 +536,9 @@ See [=default allowlist/'self'=]. When invoked, run these steps: + 1. Let global be the [=current global object=]. + 1. Let document be global's [=associated Document=]. 1. Let promise be a new promise. - 1. If the [=current settings object=]'s [=relevant global object=]'s [=associated Document=] is NOT [=fully active=], reject promise with an {{InvalidStateError}}, abort these steps, returning promise. + 1. If document is not [=fully active=], reject promise with an {{InvalidStateError}}, abort these steps, returning promise. 1. If {{SpeechRecognitionOptions/langs}} of options is an empty sequence, resolve promise with false, abort these steps, returning promise. 1. If any lang in {{SpeechRecognitionOptions/langs}} of options is not a valid [[!BCP47]] language tag, reject promise with a {{SyntaxError}}, abort these steps, returning promise. + 1. If document is not [=allowed to use=] the "on-device-speech-recognition" [=policy-controlled feature=], reject promise with a {{NotAllowedError}} and return promise. 1. If the on-device speech recognition language pack for any lang in {{SpeechRecognitionOptions/langs}} of options is unsupported, resolve promise with false, abort these steps, returning promise. 1. If {{SpeechRecognition/available()}} would resolve to {{"downloadable"}} for options (evaluated as if {{SpeechRecognitionOptions/processLocally}} of options were true), that is, if, as far as the calling web page can observe, this call would initiate a download, then: - 1. If the [=current settings object=]'s [=relevant global object=] does not have [=transient activation=], reject promise with a {{NotAllowedError}}, abort these steps, returning promise. - 1. [=Consume user activation=] given the [=current settings object=]'s [=relevant global object=]. + 1. If global does not have [=transient activation=], reject promise with a {{NotAllowedError}}, abort these steps, returning promise. + 1. [=Consume user activation=] given global.

Note: Because {{SpeechRecognition/available()}} is subject to [=download masking state=] rules, this check is based on the masked availability status rather than on the true download status. As a result, whether {{SpeechRecognition/install()}} requires [=transient activation=] does not reveal the true download status to a web page for which it is still masked.

1. [=In parallel=], run the following steps: - 1. The user agent MAY prompt the user for explicit permission to download the on-device speech recognition language pack(s), or MAY decline to initiate the download based on implicit signals (such as an observed pattern of abuse; see Installation-Time Friction) or storage pressure. In the event of storage pressure, user agents SHOULD balance the utility of on-device speech recognition with the disk space its language packs take up (possibly by declining new downloads or freeing up disk space in other ways, subject to the eviction requirements below; see Disk Space for Language Packs), and MAY involve the user in these decisions (e.g., via the download-time permission prompt or a browser UI for managing downloaded language packs). If the download is not permitted, [=queue a task=] on the [=relevant global object=]'s [=task queue=] to resolve promise with false, and abort these steps. + 1. The user agent MAY prompt the user for explicit permission to download the on-device speech recognition language pack(s), or MAY decline to initiate the download based on implicit signals (such as an observed pattern of abuse; see Installation-Time Friction) or storage pressure. In the event of storage pressure, user agents SHOULD balance the utility of on-device speech recognition with the disk space its language packs take up (possibly by declining new downloads or freeing up disk space in other ways, subject to the eviction requirements below; see Disk Space for Language Packs), and MAY involve the user in these decisions (e.g., via the download-time permission prompt or a browser UI for managing downloaded language packs). If the download is not permitted, [=queue a global task=] on the [=speech recognition task source=] given global to resolve promise with false, and abort these steps. 1. For each lang in {{SpeechRecognitionOptions/langs}} of options, initiate the download of the on-device speech recognition language pack for lang matching the requested {{SpeechRecognitionOptions/quality}} level floor (if not already installed or downloading). 1. If the download was successfully initiated (or the language pack is already installed or downloading) for every lang in {{SpeechRecognitionOptions/langs}} of options, set the [=download masking state=] for (options, [=storage key=]) to "unmasked". 1. Wait for the download of all languages specified by {{SpeechRecognitionOptions/langs}} of options to either succeed or fail. User agents MAY artificially fake a download (e.g., by adding a delay before resolving promise) if they believe it would be helpful for privacy reasons, instead of resolving instantly if the language pack is already present (see Sensitive Language Information). During such a fake download, the user agent MUST report the availability status for that [=storage key=] as {{"downloading"}} (and treat the language pack as not yet installed for other purposes observable by that [=storage key=], including in the [=start session algorithm=] and the {{SpeechRecognitionOptions/processLocally}} `false` branch of the [=availability algorithm=]) so that the web page cannot distinguish a fake delay from a real download. 1. If the download of all those languages succeeded, let result be true, otherwise let result be false. - 1. [=Queue a task=] on the [=relevant global object=]'s [=task queue=] to resolve promise with result. + 1. [=Queue a global task=] on the [=speech recognition task source=] given global to resolve promise with result.

Note: The false resolution of the Promise does not indicate the specific cause of failure. User agents are encouraged to provide more detailed information about the failure in developer tools console messages. However, this detailed error information is not exposed to the script.

@@ -619,10 +626,12 @@ See promise with {{SpeechRecognitionAvailabilityStatus/unavailable}} and abort these steps. 1. If {{SpeechRecognitionOptions/processLocally}} of options is `false`: 1. If langs is an empty sequence, let status be {{SpeechRecognitionAvailabilityStatus/unavailable}}. 1. Else if speech recognition (which may be remote, or on-device if its [=download masking state=] is "unmasked" for the caller's [=storage key=]) is available for all language in langs, let status be {{SpeechRecognitionAvailabilityStatus/available}}. @@ -648,7 +657,7 @@ See