From 096938f2d31036cff64e30fd256c61b367680cfb Mon Sep 17 00:00:00 2001 From: Yao Xiao Date: Wed, 12 Feb 2025 16:27:46 -0500 Subject: [PATCH 1/2] [spec] During addModule(), switch to allow `navigator` but disallow `navigator.locks` Currently, `navigator.locks` is the only available attribute on `navigator` (i.e., a SharedStorageWorkletNavigator), and we want to prevent Web Locks functionality during addModule(). This change avoids unintentionally breaking existing code that might legitimately read the navigator object (e.g., expects no Exception thrown) during module loading for purposes unrelated to Web Locks. --- spec.bs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/spec.bs b/spec.bs index 66d7ec6..a2e45a7 100644 --- a/spec.bs +++ b/spec.bs @@ -103,6 +103,7 @@ spec: web-locks; urlPrefix: https://w3c.github.io/web-locks/ text: lock manager; url: lock-manager text: obtain a lock manager; url: obtain-a-lock-manager text: request a lock; url: request-a-lock + text: locks getter steps; url: dom-navigatorlocks-locks spec: ecma; urlPrefix: https://tc39.es/ecma262/ type: dfn text: call; url: sec-call @@ -925,8 +926,7 @@ Moreover, each {{SharedStorageWorklet}}'s [=global scopes|list of global scopes=
The navigator [=getter steps=] are: - 1. If [=this=]'s [=addModule success=] is true, return [=this=]'s [=SharedStorageWorkletGlobalScope/navigator instance=]. - 1. Otherwise, throw a {{TypeError}}. + 1. Return [=this=]'s [=SharedStorageWorkletGlobalScope/navigator instance=].
@@ -2371,6 +2371,20 @@ interface Lock {}; Add the following sentence at the end of the paragraph that defines [=lock manager=]: "Additionally, each user agent includes one [=shared storage lock managers map=] for Web Locks API's integration with the Shared Storage API." + +## Monkey Patch for locks getter steps ## {#monkey-patch-for-locks-getter-steps} + +The [=locks getter steps=] should be updated to the following setps: + +
+ 1. Let |environment| be [=/this=]'s [=/relevant settings object=]. + 1. If |environment|'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then throw a {{TypeError}}. + 1. Let |globalObject| be the [=current realm=]'s [=global object=]. + 1. If |globalObject| is a {{SharedStorageWorkletGlobalScope}}: + 1. If the |globalObject|'s [=SharedStorageWorkletGlobalScope/addModule success=] is false, then throw a {{TypeError}}. + 1. Return [=/this=]'s [=/relevant settings object=]'s {{LockManager}} object +
+ ## Monkey Patch for the "obtain a lock manager" algorithm ## {#monkey-patch-for-the-obtain-a-lock-manager-algorithm} The [=obtain a lock manager=] algorithm should be prepended with the following steps: From 1cb8bcbf00d786e82bea9ff15e796699bddc4cb3 Mon Sep 17 00:00:00 2001 From: Yao Xiao Date: Wed, 12 Feb 2025 18:56:44 -0500 Subject: [PATCH 2/2] remove the check for active document --- spec.bs | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec.bs b/spec.bs index a2e45a7..fab9746 100644 --- a/spec.bs +++ b/spec.bs @@ -2377,8 +2377,6 @@ Add the following sentence at the end of the paragraph that defines [=lock manag The [=locks getter steps=] should be updated to the following setps:
- 1. Let |environment| be [=/this=]'s [=/relevant settings object=]. - 1. If |environment|'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then throw a {{TypeError}}. 1. Let |globalObject| be the [=current realm=]'s [=global object=]. 1. If |globalObject| is a {{SharedStorageWorkletGlobalScope}}: 1. If the |globalObject|'s [=SharedStorageWorkletGlobalScope/addModule success=] is false, then throw a {{TypeError}}.