From 0064f788f1efd04c87a9663c3d79ae42bcf0ccaa Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 4 Oct 2024 12:08:28 +0100 Subject: [PATCH] chore: clear `pendingDocument()` for the same-document navigation WebKit notifies about a pending same-document navigation through `Page.frameScheduledNavigation`, and committing it should clear the `pendingDocument()`. --- packages/playwright-core/src/server/frames.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/playwright-core/src/server/frames.ts b/packages/playwright-core/src/server/frames.ts index 7dc992813b..d107a7f981 100644 --- a/packages/playwright-core/src/server/frames.ts +++ b/packages/playwright-core/src/server/frames.ts @@ -248,6 +248,11 @@ export class FrameManager { const frame = this._frames.get(frameId); if (!frame) return; + const pending = frame.pendingDocument(); + if (pending && pending.documentId === undefined && pending.request === undefined) { + // WebKit has notified about the same-document navigation being requested, so clear it. + frame.setPendingDocument(undefined); + } frame._url = url; const navigationEvent: NavigationEvent = { url, name: frame._name, isPublic: true }; this._fireInternalFrameNavigation(frame, navigationEvent);