Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(bidi): fix fragment navigations (#39263)

Holger Benle956d6e27b5d
diff --git a/packages/playwright-core/src/server/bidi/bidiPage.ts b/packages/playwright-core/src/server/bidi/bidiPage.ts
index 509d0e7b2c..990c41fc2e 100644
--- a/packages/playwright-core/src/server/bidi/bidiPage.ts
+++ b/packages/playwright-core/src/server/bidi/bidiPage.ts
@@ -53,6 +53,7 @@ export class BidiPage implements PageDelegate {
readonly _networkManager: BidiNetworkManager;
private readonly _pdf: BidiPDF;
private _initScriptIds = new Map<InitScript, string>();
+ private readonly _fragmentNavigations = new Set<string>();
constructor(browserContext: BidiBrowserContext, bidiSession: BidiSession, opener: BidiPage | null) {
this._session = bidiSession;
@@ -220,6 +221,8 @@ export class BidiPage implements PageDelegate {
}
private _onFragmentNavigated(params: bidi.BrowsingContext.NavigationInfo) {
+ if (params.navigation)
+ this._fragmentNavigations.add(params.navigation);
this._page.frameManager.frameCommittedSameDocumentNavigation(params.context, params.url);
}
@@ -310,6 +313,10 @@ export class BidiPage implements PageDelegate {
context: frame._id,
url,
});
+ if (navigation && this._fragmentNavigations.has(navigation)) {
+ this._fragmentNavigations.delete(navigation);
+ return {};
+ }
return { newDocumentId: navigation || undefined };
}
diff --git a/tests/bidi/expectations/moz-firefox-nightly-library.txt b/tests/bidi/expectations/moz-firefox-nightly-library.txt
index 98b9aff914..7e9c386290 100644
--- a/tests/bidi/expectations/moz-firefox-nightly-library.txt
+++ b/tests/bidi/expectations/moz-firefox-nightly-library.txt
@@ -43,6 +43,7 @@ library/browsercontext-reuse.spec.ts › reuse connect › should not cache reso
library/browsercontext-reuse.spec.ts › reuse connect › should update viewport and media [fail]
library/browsercontext-reuse.spec.ts › reuse launch › should not cache resources [fail]
library/browsercontext-reuse.spec.ts › reuse launch › should update viewport and media [fail]
+library/browsercontext-service-worker-policy.spec.ts › block › should not throw error on about:blank [fail]
library/browsercontext-storage-state.spec.ts › should roundtrip local storage in third-party context [fail]
library/browsercontext-storage-state.spec.ts › should set local storage in third-party context [fail]
library/browsercontext-viewport-mobile.spec.ts › mobile viewport › default mobile viewports to 980 width [fail]
@@ -133,6 +134,7 @@ library/emulation-focus.spec.ts › should focus with more than one page/context
library/emulation-focus.spec.ts › should think that all pages are focused @smoke [fail]
library/fetch-proxy.spec.ts › context request should pick up proxy credentials [timeout]
library/firefox/launcher.spec.ts › should support custom firefox policies [fail]
+library/geolocation.spec.ts › should use context options for popup [timeout]
library/har.spec.ts › should have connection details [fail]
library/har.spec.ts › should have connection details for failed requests [fail]
library/har.spec.ts › should have connection details for redirects [fail]
@@ -179,6 +181,7 @@ library/popup.spec.ts › should inherit user agent from browser context @smoke
library/popup.spec.ts › should inherit viewport size from browser context [fail]
library/popup.spec.ts › should not dispatch binding on a closed page [fail]
library/popup.spec.ts › should not throw when click closes popup [timeout]
+library/popup.spec.ts › should use viewport size from window features [timeout]
library/role-utils.spec.ts › axe-core accessible-text [timeout]
library/role-utils.spec.ts › wpt accname #2 [timeout]
library/screenshot.spec.ts › page screenshot › should work with device scale factor and scale:css [fail]
diff --git a/tests/bidi/expectations/moz-firefox-nightly-page.txt b/tests/bidi/expectations/moz-firefox-nightly-page.txt
index 38d6e54299..354aff25a2 100644
--- a/tests/bidi/expectations/moz-firefox-nightly-page.txt
+++ b/tests/bidi/expectations/moz-firefox-nightly-page.txt
@@ -16,7 +16,6 @@ page/frame-evaluate.spec.ts › should dispose context on cross-origin navigatio
page/frame-evaluate.spec.ts › should dispose context on navigation [fail]
page/frame-evaluate.spec.ts › should not allow cross-frame element handles when frames do not script each other [fail]
page/frame-goto.spec.ts › should continue after client redirect [flaky]
-page/frame-hierarchy.spec.ts › should send "framenavigated" when navigating on anchor URLs [timeout]
page/frame-hierarchy.spec.ts › should support framesets [fail]
page/interception.spec.ts › should disable memory cache when intercepting [timeout]
page/interception.spec.ts › should intercept worker requests when enabled after worker creation [timeout]
@@ -106,7 +105,6 @@ page/page-fill.spec.ts › should throw nice error without injected script stack
page/page-goto.spec.ts › should override referrer-policy [fail]
page/page-goto.spec.ts › should send referer [fail]
page/page-goto.spec.ts › should send referer of cross-origin URL [fail]
-page/page-goto.spec.ts › should work with anchor navigation [timeout]
page/page-goto.spec.ts › should work with subframes return 204 with domcontentloaded [flaky]
page/page-history.spec.ts › goBack/goForward should work with bfcache-able pages [timeout]
page/page-history.spec.ts › page.goBack should work for file urls [timeout]