Closed Bug 1873196 Opened 9 months ago Closed 4 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

(firefox129 fixed)

RESOLVED FIXED
129 Branch
Tracking Status
firefox129 --- fixed

People

(Reporter: alexrudenko, Assigned: whimboo)

References

Details

(Whiteboard: [webdriver:m11][webdriver:relnote])

Attachments

(2 files)

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]
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Pushed by hskupin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/065a840047f6 [webdriver-bidi] Close all open tabs by skipping beforeunload prompts when running "browser.close" command. r=webdriver-reviewers,Sasha https://hg.mozilla.org/integration/autoland/rev/94263d5ebf02 [wdspec] Add bidi-only test for "browser.close" with skipping beforeunload prompt. r=webdriver-reviewers,Sasha
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch
Whiteboard: [webdriver:m11] → [webdriver:m11][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: