Open Bug 1873196 Opened 5 months ago Updated 2 months ago

"browser.close" has to close all top-level browsing contexts by discarding any "beforeunload" handlers

Categories

(Remote Protocol :: WebDriver BiDi, defect, P2)

defect
Points:
2

Tracking

(Not tracked)

People

(Reporter: alexrudenko, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Whiteboard: [webdriver:m11])

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Steps to reproduce:

Run the following script

import puppeteer from "puppeteer";

const browser = await puppeteer.launch({
  product: 'firefox',
  protocol: 'webDriverBiDi',
});

const page = await browser.newPage();

await page.goto('http://127.0.0.1:8080/test/assets/beforeunload.html');

await page.click('body');

await browser.connection.send('browser.close', {});

The content of beforeunload.html is

<div>beforeunload demo.</div>
<script>
window.addEventListener('beforeunload', event => {
  // Chrome way.
  event.returnValue = 'Leave?';
  // Firefox way.
  event.preventDefault();
});
</script>

Adjust the page URL according to the path on your server.

Actual results:

The browser is not closed. The page shows the dialog to confirm unload.

Expected results:

According to https://w3c.github.io/webdriver-bidi/#command-browser-close the implementation should "Close any top-level browsing contexts without prompting to unload."

Right now we do not support beforeunload events and completely turn those off via the preference dom.disable_beforeunload. So maybe Puppeteer needs to set it on its own for the Firefox preferences for now.

Also before we can close top-level browsing contexts without prompting we need bug 1862380 fixed.

Blocks: 1829332
Status: UNCONFIRMED → NEW
Depends on: 1862380
Ever confirmed: true
Summary: browser.close runs before unload handlers → "browser.close" runs before unload handlers
Version: Firefox 123 → Trunk
Summary: "browser.close" runs before unload handlers → "browser.close" has to close all top-level browsing contexts by discarding any "beforeunload" handlers
Points: --- → 2
Priority: -- → P2
Whiteboard: [webdriver:m10]

The severity field is not set for this bug.
:whimboo, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(hskupin)
Severity: -- → S3
Flags: needinfo?(hskupin)
Whiteboard: [webdriver:m10] → [webdriver:m11]
You need to log in before you can comment on or make changes to this bug.