Skip to content

fix: clear storages when Chrome rejects the '*' origin in native automation - #8574

Open
sam-yh wants to merge 1 commit into
DevExpress:masterfrom
sam-yh:chrome-158-clear-storages
Open

sam-yh wants to merge 1 commit into
DevExpress:masterfrom
sam-yh:chrome-158-clear-storages

Conversation

@sam-yh

@sam-yh sam-yh commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Purpose

Chrome 158 rejects Storage.clearDataForOrigin({ origin: '*', storageTypes: 'all' }) with * is not a valid URL. In native automation, TestCafe makes this call before every test (CdpStoragesProvider.clearStorages). The rejection propagates out of TestRun.initialize(), the browser's /browser/status request is never answered, and the run hangs on the idle page.

The only comment on the issue suggests that '*' was already a no-op on Chrome 157 and earlier, so the call could simply be skipped. That is not what I see. On Chromium 156.0.8078.4, clearDataForOrigin('*') removes localStorage, IndexedDB and cookies, including those of a cross-site iframe. Skipping the call would drop storage isolation between tests.

Approach

  • clearStorages still tries the wildcard first, so browsers that accept it behave as before.
  • Only the is not a valid URL rejection triggers the fallback. Any other error is rethrown. The rejection is remembered per browser connection, so the wildcard is not retried before every test.
  • The fallback clears storage in parallel for:
    • every http(s) origin seen in the request pipeline's Fetch.requestPaused handler, with Storage.clearDataForOrigin;
    • the storage key of every iframe target, with Storage.clearDataForStorageKey. The key is read with Storage.getStorageKey on Target.attachedToTarget and again on Target.targetInfoChanged, because at attach time Chrome can still report the parent's key.
  • Storage keys are needed because Chrome partitions the storage of a cross-site iframe by the top-level site. On Chrome 158.0.8127.36, clearDataForOrigin(<iframe origin>) leaves that partition in place, and clearDataForStorageKey(<key reported by Chrome>) clears it.
  • Cookies are not handled here. cookieProvider.initialize() already runs Network.clearBrowserCookies right before.
  • The visited origins and storage keys are tracked in a new module, src/native-automation/visited-storages.ts.

Known limits of the fallback:

  • Storage of an origin that never sent a request through Fetch interception is not cleared.
  • Iframes nested inside a cross-site iframe are not covered.

Tests:

  • test/server/cdp-storages-provider-test.js: unit tests for the wildcard path, the fallback, not retrying the wildcard after a rejection, and rethrowing other errors.
  • test/functional/fixtures/driver: a native automation test that writes localStorage in a top page on localhost:3000 and in a cross-site iframe on 127.0.0.1:3001, then checks that both are empty in the next test. It reuses the existing driver test pages and ports. It only exercises the fallback on Chrome 158 or later. On older Chrome it goes through the wildcard path and acts as a regression guard. On Chrome 158 it fails if only per-origin clearing is used.

Checked manually with a three-test fixture (write localStorage in the top page and in a cross-site iframe; assert the top page is clean; assert the iframe is clean). It passes with this change on Chrome 158 headless and headed and on Chromium 156. With per-origin clearing only, the iframe test fails on Chrome 158.

Cypress fixed the same Chrome change with per-origin clearing: cypress-io/cypress#35198

References

Closes #8573

Co-authored with @TAkbay, who wrote the original fix.

Pre-Merge TODO

  • Write tests for your proposed changes
  • Make sure that existing tests do not fail

…mation

Chrome 158 rejects Storage.clearDataForOrigin with the '*' origin, so
TestRun.initialize() failed and the run hung on the idle page. Keep the
wildcard for browsers that accept it; otherwise clear every origin seen
by the request pipeline and the storage key of every iframe target.

Co-authored-by: Tansu Akbay <28011463+TAkbay@users.noreply.github.com>
@testcafe-need-response-bot testcafe-need-response-bot Bot added the STATE: Need response An issue that requires a response or attention from the team. label Nov 19, 2026
@sam-yh
sam-yh force-pushed the chrome-158-clear-storages branch from d152c48 to 8be9f11 Compare November 19, 2026 07:41
@Aleksey28 Aleksey28 added the STATE: PR Review Pending A note that this PR will be reviewed. label Nov 20, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your contribution to TestCafe. When a member of the TestCafe team becomes available, they will review this PR.

@github-actions github-actions Bot removed STATE: Need response An issue that requires a response or attention from the team. STATE: PR Review Pending A note that this PR will be reviewed. labels Nov 20, 2026

This branch was successfully deployed

1 active deployment
CI — 8be9f11b Deployed Nov 19, 2026 by sam-yh via request-deploy #5083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chrome 158: test never starts, browser stays on "Connected" loader; /browser/status request never gets a response (Chrome 157 works)

2 participants