Skip to content

[Bug]: Page.onClose is not called with browser window is closed #1714

@davidnewcomb

Description

@davidnewcomb

Version

1.49.0

Steps to reproduce

git clone git@github.com:davidnewcomb/playright-bug-onclose.git
cd playright-bug-onclose
mvn clean install

Expected behavior

When I close the window then Page.onClose{} should fire.

Actual behavior

Page.onClose{} is only called when I call page.close() or browserContext.close().

Additional context

I created 2 tests that run consecutively one which uses BrowserContext and one which does not use BrowserContext. Both tests never first page.onClose when I close the window or close the tab.

Environment

-Operating System: MacOS Sequioa 15.2
-CPU: intel core i9
-Browser: Nightly
-Java version: Java version: 22.0.1, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/22.0.1/libexec/openjdk.jdk/Contents/Home
-Java compiled for v 1.8 and 21
-Tested on Nightly/firefox and Chromium
-Maven: 3.9.8
-Running in: Spring Tool Suite 4 - Version: 4.26.0.RELEASE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions