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

`browser` module

· 52CE 我爱测

The **`browser`** module contains commands for managing the browser, including client windows, user contexts, and download behavior.

The browser module contains commands for managing the browser, including client windows, user contexts, and download behavior.

Client windows

A client window is an OS-level browser window, which includes the viewport (the area where web content is displayed) and browser UI elements such as the address bar and toolbars.

Each client window has the following properties:

  • A unique string identifier (clientWindow).
  • A state (state) indicating whether the window is normal, maximized, minimized, or fullscreen.
  • An active state (active) indicating whether the window can receive keyboard input from the operating system.
  • A position expressed as x and y coordinates in CSS pixel from the left and top edges of the screen, respectively.
  • A size expressed as width and height in CSS pixel.

A list of client windows can be obtained using browser.getClientWindows and their state can be changed using browser.setClientWindowState.

User contexts

A user context is a collection of zero or more top-level contexts (tabs) within the browser. Tabs within the same user context share the same browser storage (such as cookies and session data), while tabs in different user contexts are completely isolated from one another and do not share any browser data. A user context with no tabs is called an empty user context.

Each user context has a unique string identifier (user context ID). The browser always has a default user context with the ID "default", which cannot be removed.

Multiple tabs from different user contexts can share the same client window.

For example, a regular browser tab lives in the "default" user context. A tab opened in a separate container lives in a different user context. Both tabs can appear in the same client window, but their cookies and session data are completely isolated from each other.

User contexts can be created using browser.createUserContext and removed using browser.removeUserContext.

Commands

Events

The browser module has no associated events.

Specifications

Browser compatibility

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

资料来源与适用范围

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

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

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