Closed Bug 2011721 Opened 6 months ago Closed 6 months ago

CanonicalURLChild does not detect pageshow after back button on some sites

Categories

(Firefox :: Tabbed Browser, defect, P1)

Firefox 149
defect
Points:
1

Tracking

()

RESOLVED FIXED
149 Branch
Tracking Status
firefox149 --- fixed

People

(Reporter: sthompson, Assigned: sthompson)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fidefe-tabgrps])

Attachments

(1 file)

Tab notes requires that we detect page content canonical URLs when URLs change. On history navigation, we leave the existing canonicalUrl in place on the tab based on the expectation that the page will emit pageshow when the history navigation is complete. https://searchfox.org/firefox-main/rev/131497bb1b747587b2b21b1abf14f44ecffad805/browser/components/tabnotes/TabNotesController.sys.mjs#208-221 However, on a number of sites, we've observed cases where the back/forward buttons do not yield pageshow:

  • x.com
  • github.com
  • facebook.com
  • instagram.com
  • reddit.com

Entry #6 in the list https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent describes how pageshow should be emitted during history navigations on sites like these that use history.pushState, so it's not clear what is happening on these sites.

We need to investigate the problem and, hopefully, implement a way to ensure that we always re-detect the canonical URL after a history navigation.

Points: 2 → 1
Assignee: nobody → sthompson

When using the browser history/back/forward to navigate on sites that use history.pushState, pageshow won't be fired, so we weren't re-parsing the page when we got there.

Listening for popstate helps because it is emitted at the end of the history navigation. However, re-parsing the document immediately on popstate always yields the "previous" page's content. Re-parsing after an immediate timeout worked on some sites (reddit.com, x.com) but not other sites (github.com). I think this patch is good enough to mitigate problems on single page app web sites, but we may need follow up(s) that give web sites more time after popstate to update their document contents.

Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
See Also: → 2012053
See Also: → 2011919
QA Whiteboard: [qa-triage-done-c150/b149]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: