Skip to content

[Regression]: exposeBinding call from a pagehide handler is dropped when navigating away (since 1.62, RenderDocument) #43064

Closed as not planned

Description

Last Good Version

1.61.0

First Bad Version

1.62.0 (still reproduces in 1.63.0)

Steps to reproduce

A binding exposed with context.exposeBinding() is never called when the page calls it from a pagehide handler while navigating away (clicking a link to another document). It works in 1.61.0.

server.js:

const http = require('http');
const pages = {
  '/a.html': '<!doctype html><a id="next" href="/b.html">next</a><script>addEventListener("pagehide", () => window.reportFromPage("pagehide of " + location.pathname));</script>',
  '/b.html': '<!doctype html><p>b</p><script>addEventListener("pagehide", () => window.reportFromPage("pagehide of " + location.pathname));</script>'
};
http.createServer((req, res) => {
  res.writeHead(200, {'content-type': 'text/html'});
  res.end(pages[req.url] ?? '');
}).listen(8080);

tests/repro.spec.ts:

import { test, expect } from '@playwright/test';

test('binding called from pagehide reaches Node', async ({ context, page }) => {
  const calls: string[] = [];
  await context.exposeBinding('reportFromPage', (_source, message: string) => { calls.push(message); });

  await page.goto('http://localhost:8080/a.html');
  await page.click('#next');                       // navigates a.html -> b.html, fires pagehide on a.html
  await page.waitForURL('**/b.html');
  await page.waitForTimeout(500);

  expect(calls).toContain('pagehide of /a.html');
});

playwright.config.ts:

import { defineConfig, devices } from '@playwright/test';
export default defineConfig({ testDir: './tests', reporter: 'line', projects: [{ name: 'chromium', use: devices['Desktop Chrome'] }] });

Run node server.js & then npx playwright test:

Version Result
1.61.0 passed
1.62.0 failed: calls is empty
1.63.0 failed: calls is empty

Expected behavior

The binding receives pagehide of /a.html, as in 1.61.0.

Actual behavior

The call is silently dropped: no error in the page, nothing on the Node side. The page itself does run the handler: a navigator.sendBeacon() issued from the same pagehide handler reaches the server in every version.

Additional context

The regression matches #41303 (chore(chromium): reenable RenderDocument again), which removed RenderDocument from the features Playwright disables. Launching 1.63.0 with launchOptions: {args: ['--disable-features=RenderDocument']} makes the test above pass again.

That workaround is not safe though: the extra --disable-features switch replaces the list Playwright passes instead of adding to it. With it, ThirdPartyStoragePartitioning is enabled again (a localStorage value written by a b.test iframe embedded in a.test is no longer visible to b.test opened top-level), and presumably every other feature of Playwright's default list is too. A user cannot append a feature to Playwright's --disable-features without copying the whole list.

Real-world impact: the web-vitals library reports the final INP (and CLS) of a page from pagehide / visibilitychange. A tool that collects Core Web Vitals through an exposed binding loses the INP of every interaction that navigates away (link clicks, form submits) since 1.62.0.

Environment

System:
  OS: Linux 6.17 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
  CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
  Memory: 25.02 GB / 62.72 GB
Binaries:
  Node: 20.19.6
  npm: 11.19.0
npmPackages:
  @playwright/test: 1.63.0

Also reproduced with @playwright/test 1.63.0 on Node 24.21.0 in a Docker image (Ubuntu, Chromium 1243).

Activity

  1. dgozman commented on Oct 19, 2026

    @dgozman
    Collaborator

    Unfortunately, this is a fundamental behavior of the Chrome DevTools Protocol, and it will not be fixed in the foreseeable future.

    Investigation notes

    Chromium never sends Runtime.bindingCalled from pagehide at all, and Runtime.consoleAPICalled is lost too. A console.log in pagehide is invisible to Chrome DevTools as well.

    The cause is in content/browser/devtools/render_frame_devtools_agent_host.cc. At ReadyToCommitNavigation the agent host calls UpdateFrameHost with the new RenderFrameHost. That rebinds every session's renderer pipe to the new frame, and the old renderer session is detached on pipe disconnect. With RenderDocument every cross-document navigation swaps RenderFrameHosts, so this now hits same-site navigations as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions