Skip to content

Avoid prefetching and prerendering while offline - #506

Open
shobhit26-09 wants to merge 4 commits into
GoogleChromeLabs:mainfrom
shobhit26-09:fix/offline-prefetch
Open

shobhit26-09 wants to merge 4 commits into
GoogleChromeLabs:mainfrom
shobhit26-09:fix/offline-prefetch

Conversation

@shobhit26-09

Copy link
Copy Markdown

Fixes #402.

Check navigator.onLine === false before the Network Information API checks. Both prefetch() and prerender() now reject while offline, before caching a URL or inserting prefetch links/speculation rules. Browsers without navigator.connection still receive this check. Existing Save-Data and slow-connection checks are unchanged.

Adds five Chromium regression tests covering both APIs with and without Network Information, plus prefetching the same URL after reconnecting. The tests use Puppeteer's offline emulation and restore online mode in finally.

Validation on Linux, Node 22.23.4, Chrome for Testing 149.0.7827.55:

  • Five new tests fail before the fix and pass after it.
  • Full repository suite: 24 passing, 1 existing skipped.
  • npm run build-all, npm run lint, npm run size, and git diff --check pass.
  • Used the installed Chrome with a no-sandbox launcher and a separate local server port. External test requests remain mocked by the existing harness. No Firefox/Safari runtime claim.

This is an AI-assisted contribution. The earlier #411 was closed for inactivity with an invitation to open a new tested PR; this change adds the missing regression coverage.

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.

Avoid Triggering Requests while offline

1 participant