Closed Bug 2051908 Opened 13 days ago Closed 8 days ago

ProgressListener prematurely stops navigation on subframe location changes

Categories

(Remote Protocol :: Agent, defect, P3)

defect
Points:
2

Tracking

(firefox154 fixed)

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: whimboo, Assigned: whimboo)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [webdriver:m21], [wptsync upstream])

Attachments

(1 file)

Noticed this bug while updating my patch on bug 1664165, and some web-platform tests still failing.

The ProgressListener class in remote/shared/Navigate.sys.mjs registers with NOTIFY_LOCATION on the top-level WebProgress. With this flag, onLocationChange receives location-change events from all frames — including subframes — not just the monitored top-level document.

When a subframe performs a same-document navigation (hash change, history.pushState, or history.replaceState), onLocationChange fires with LOCATION_CHANGE_SAME_DOCUMENT. The current code unconditionally calls stop() in that case, causing the navigation promise to resolve before the top-level document has finished loading.

To reproduce navigate to a page that loads an iframe which calls history.replaceState (e.g. /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-history-replaceState.html in WPT). The navigation command (WebDriver:Navigate / browsingContext.navigate) returns before the page is ready, so any script the test runner injects immediately after (window.__wptrunner_process_next_event) does not exist yet, resulting in a TypeError.

To fix this we should update onLocationChange and skip the LOCATION_CHANGE_SAME_DOCUMENT handling when progress.browsingContext !== this.#webProgress.browsingContext — i.e. when the event originates from a subframe rather than the monitored top-level context.

Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Attachment #9603370 - Attachment description: Bug 2051908 - [remote] Ignore subframe same-document navigations in ProgressListener. → Bug 2051908 - [remote] Fix ProgressListener to ignore subframe location changes.

Actually the test /html/cross-origin-embedder-policy/require-corp.https.html shows a similar failure when using the ProgressListener. The page loads fine, but CORP blocks a subframe resource, causing a LOCATION_CHANGE_ERROR_PAGE event for the subframe's webProgress. The ProgressListener's onLocationChange picks this up as well without any subframe check and incorrectly aborts the navigation with "Reached error page: Address rejected".

Summary: ProgressListener incorrectly stops navigation on subframe same-document navigations (hash/pushState/replaceState) → ProgressListener prematurely stops navigation on subframe location changes
Severity: -- → S3
Points: --- → 2
Priority: -- → P3
Whiteboard: [webdriver:m20]

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/61086 for changes under testing/web-platform/tests

Whiteboard: [webdriver:m20] → [webdriver:m20], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 8 days ago
Resolution: --- → FIXED
Target Milestone: --- → 154 Branch

Upstream PR merged by moz-wptsync-bot

Whiteboard: [webdriver:m20], [wptsync upstream] → [webdriver:m21], [wptsync upstream]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: