Closed Bug 1769189 Opened 3 years ago Closed 2 years ago

replaceState does not work in beforeunload listener

Categories

(Core :: DOM: Navigation, defect, P3)

Firefox 100
defect

Tracking

()

RESOLVED FIXED
108 Branch
Tracking Status
firefox108 --- fixed

People

(Reporter: sam9072000, Assigned: smaug)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:100.0) Gecko/20100101 Firefox/100.0

Steps to reproduce:

  • Include this script into a simple html page
console.log(window.history.state);
window.addEventListener('beforeunload', () => {
  window.history.replaceState({ data: true }, '');
});
  • Visit page
  • Press refresh button to refresh page

Actual results:

  • After refreshing the page with the refresh button, the console prints null.

Expected results:

  • After refreshing the page with the refresh button, the console should print {data: true}

The Bugbug bot thinks this bug should belong to the 'Core::Printing: Output' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Printing: Output
Product: Firefox → Core
Component: Printing: Output → DOM: Navigation

Is this a regression? In other words, did this work before?

(I'm not even sure this is a bug.)

The bug title isn't quite right though. beforeunload is triggered, it is just that calling replaceState so late doesn't do anything.

Flags: needinfo?(sam9072000)

Ok, this is a SHIP regression.

Flags: needinfo?(sam9072000)
Summary: beforeunload listener not triggered when refresh button is pressed → replaceState does not work in beforeunload listener
Severity: -- → S3
Priority: -- → P3
Assignee: nobody → smaug
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Pushed by opettay@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7111ffbafc64 ensure history state is updated if beforeunload listener calls replaceState, r=peterv
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 108 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: