Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions pkg/lib/cockpit/_internal/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,22 @@ export class Location {
return;
const hash = '#' + this.#href_for_go_or_replace(path, options);

// At least Firefox 146 and 147 will (sometimes) trigger a
// full force reload of the page when setting
// window.location.hash, even if it hasn't actually
// changed. If a page accidentally navigates to the current
// location on initial render, this can lead to a loop. Even
// if that is a bug in that page, let's protect us against
// this. Firefox 148 does not do that anymore.
//
// See https://bugzilla.redhat.com/show_bug.cgi?id=2422331
//
if (window.location.hash != hash)
if (navigator.userAgent.includes("Firefox")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test. Details

// At least Firefox 146 and 147 will (sometimes) trigger a
// full force reload of the page when setting
// window.location.hash. We can work around that by
// clicking on a link.
//
// https://bugzilla.mozilla.org/show_bug.cgi?id=2018546

const a = document.createElement('a');
a.href = hash;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
Comment on lines +175 to +179
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 5 added lines are not executed by any test. Details

} else {
window.location.hash = hash;
}
}

invalidate() {
Expand Down