大网数据广告活动
Web 标准与前端开发

WindowSharedStorage: run() method

· 52CE 我爱测

The **`run()`** method of the WindowSharedStorage interface executes a run operation that is registered in a module added to the current origin's SharedStorageWorklet.

Shared Storage API

The run() method of the WindowSharedStorage interface executes a run operation that is registered in a module added to the current origin's SharedStorageWorklet.

[!NOTE] The Run output gate is intended as a generic way to process some shared storage data.

Syntax

run(name)
run(name, options)

Parameters

  • name
    • : A string representing the registered operation's name within the shared storage worklet module. It must match the name given to the operation when it is registered with SharedStorageWorkletGlobalScope.register().
  • options
    • : An options object that can contain the following properties:
      • data
        • : An object representing any data required for executing the operation.
      • keepAlive
        • : A boolean value. If set to true, the SharedStorageWorkletGlobalScope of the associated worklet is kept alive, and the operation can be run again. Therefore, you need to set keepAlive to true for each operation that is not intended to be the last one. The default value, false, means that the SharedStorageWorkletGlobalScope is terminated after the operation is run and cannot be run again.

Return value

A Promise that fulfills with undefined.

Exceptions

  • TypeError
    • : Thrown if:
      • The worklet module has not yet been added with Worklet.addModule.
      • Shared storage is disabled (for example via a browser setting).
      • The calling site does not have the Shared Storage API included in a successful privacy sandbox enrollment process.

Examples

async function measureUniqueReach() {
  // Load the Shared Storage worklet
  await window.sharedStorage.worklet.addModule("reach-measurement-worklet.js");

  // Run the reach measurement operation
  await window.sharedStorage.run("reach-measurement", {
    data: { contentId: "1234" },
  });
}

measureUniqueReach();

See Unique reach measurement for a full explanation of this example. See Shared Storage API for more examples.

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。