[PR #2244] [CLOSED] fix(browser): honor service worker allow policy in attached scenarios #5113

Closed
opened 2026-10-31 01:04:04 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2244
Author: @chqcjq
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: fix/browser-sw-policy-clean


📝 Commits (1)

  • 1581f53 fix(browser): honor service worker allow policy in attached scenarios

📊 Changes

2 files changed (+57 additions, -2 deletions)

View changed files

📝 src/browser/PlaywrightScenarioSession.test.ts (+51 -0)
📝 src/browser/PlaywrightScenarioSession.ts (+6 -2)

📄 Description

Fixes #2166.

Problem

An attached browser scenario that explicitly allows service workers (service_workers: "allow") cannot capture a page already controlled by one. The public CLI rejects the supported request before navigation. If the attached page is uncontrolled but its origin has a registration scoped elsewhere, the same request succeeds while removing that registration and disabling further registration.

Root cause

initializePage in PlaywrightScenarioSession.ts unconditionally calls blockAttachedServiceWorkers for connect-mode sessions, without checking the scenario's environment.service_workers policy. The policy is correctly forwarded to Playwright's browser launch options (PlaywrightScenarioBrowser.ts:506) but is ignored during page initialization.

Fix

blockAttachedServiceWorkers now returns immediately when scenario.environment.service_workers === "allow", skipping both the controller check and the registration-blocking init script injection.

Verification

  • New regression test: connect-mode scenario with service_workers: "allow" opens without calling page.evaluate for the controller probe or page.addInitScript for registration blocking.
  • All existing scenario session tests pass (3/3).
  • npm run check and docs:check pass.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2244 **Author:** [@chqcjq](https://github.com/chqcjq) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/browser-sw-policy-clean` --- ### 📝 Commits (1) - [`1581f53`](https://github.com/morluto/rea/commit/1581f5344d31040ecb69dd96dab9071fe14376d8) fix(browser): honor service worker allow policy in attached scenarios ### 📊 Changes **2 files changed** (+57 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/PlaywrightScenarioSession.test.ts` (+51 -0) 📝 `src/browser/PlaywrightScenarioSession.ts` (+6 -2) </details> ### 📄 Description Fixes #2166. ## Problem An attached browser scenario that explicitly allows service workers (`service_workers: "allow"`) cannot capture a page already controlled by one. The public CLI rejects the supported request before navigation. If the attached page is uncontrolled but its origin has a registration scoped elsewhere, the same request succeeds while removing that registration and disabling further registration. ## Root cause `initializePage` in `PlaywrightScenarioSession.ts` unconditionally calls `blockAttachedServiceWorkers` for connect-mode sessions, without checking the scenario's `environment.service_workers` policy. The policy is correctly forwarded to Playwright's browser launch options (`PlaywrightScenarioBrowser.ts:506`) but is ignored during page initialization. ## Fix `blockAttachedServiceWorkers` now returns immediately when `scenario.environment.service_workers === "allow"`, skipping both the controller check and the registration-blocking init script injection. ## Verification - New regression test: connect-mode scenario with `service_workers: "allow"` opens without calling `page.evaluate` for the controller probe or `page.addInitScript` for registration blocking. - All existing scenario session tests pass (3/3). - `npm run check` and `docs:check` pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:04:04 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5113
No description provided.