Skip to content

Commit 96abd28

Browse files
authored
chore(bidi): add support for emulation.setNetworkConditions (#39456)
1 parent 6fd3cb4 commit 96abd28

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

packages/playwright-core/src/server/bidi/bidiBrowser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ export class BidiBrowserContext extends BrowserContext {
247247
promises.push(this.doUpdateExtraHTTPHeaders());
248248
if (this._options.permissions)
249249
promises.push(this.doGrantPermissions('*', this._options.permissions));
250+
if (this._options.offline)
251+
promises.push(this.doUpdateOffline());
250252
await Promise.all(promises);
251253
}
252254

@@ -380,6 +382,10 @@ export class BidiBrowserContext extends BrowserContext {
380382
}
381383

382384
async doUpdateOffline(): Promise<void> {
385+
await this._browser._browserSession.send('emulation.setNetworkConditions', {
386+
networkConditions: this._options.offline ? { type: 'offline' } : null,
387+
userContexts: [this._userContextId()],
388+
});
383389
}
384390

385391
async doSetHTTPCredentials(httpCredentials?: types.Credentials): Promise<void> {

packages/playwright-core/src/server/bidi/third_party/bidiCommands.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ export interface Commands {
142142
params: Bidi.Emulation.SetLocaleOverrideParameters;
143143
returnType: Bidi.EmptyResult;
144144
};
145+
'emulation.setNetworkConditions': {
146+
params: Bidi.Emulation.SetNetworkConditionsParameters;
147+
returnType: Bidi.Emulation.SetNetworkConditionsResult;
148+
};
145149

146150
'permissions.setPermission': {
147151
params: Bidi.Permissions.SetPermissionParameters;

tests/bidi/expectations/moz-firefox-nightly-library.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ library/browsercontext-basic.spec.ts › should close all belonging pages once c
55
library/browsercontext-basic.spec.ts › should disable javascript [fail]
66
library/browsercontext-basic.spec.ts › should emulate media in cross-process iframe [fail]
77
library/browsercontext-basic.spec.ts › should emulate media in popup [fail]
8-
library/browsercontext-basic.spec.ts › should emulate navigator.onLine [fail]
9-
library/browsercontext-basic.spec.ts › should emulate offline event [fail]
10-
library/browsercontext-basic.spec.ts › should work with offline option [fail]
118
library/browsercontext-cookies-third-party.spec.ts › same origin third party 'Partitioned;' cookie with different origin intermediate iframe [fail]
129
library/browsercontext-cookies-third-party.spec.ts › save/load third party non-partitioned cookies [fail]
1310
library/browsercontext-cookies-third-party.spec.ts › save/load third party 'Partitioned;' cookies [fail]
@@ -57,11 +54,13 @@ library/browsercontext-viewport.spec.ts › should drag with high dpi [fail]
5754
library/browsercontext-viewport.spec.ts › should support touch with null viewport [fail]
5855
library/browsertype-connect.spec.ts › launchServer › should be able to connect 20 times to a single server without warnings [timeout]
5956
library/browsertype-connect.spec.ts › launchServer › should save download [fail]
57+
library/browsertype-connect.spec.ts › launchServer › should save videos to artifactsDir [fail]
6058
library/browsertype-connect.spec.ts › launchServer › should saveAs videos from remote browser [timeout]
6159
library/browsertype-connect.spec.ts › launchServer › should upload a folder [fail]
6260
library/browsertype-connect.spec.ts › run-server › should be able to connect 20 times to a single server without warnings [timeout]
6361
library/browsertype-connect.spec.ts › run-server › should save download [fail]
6462
library/browsertype-connect.spec.ts › run-server › should saveAs videos from remote browser [timeout]
63+
library/browsertype-connect.spec.ts › run-server › should save videos to artifactsDir [fail]
6564
library/browsertype-connect.spec.ts › run-server › should upload a folder [fail]
6665
library/browsertype-launch.spec.ts › should reject if launched browser fails immediately [fail]
6766
library/capabilities.spec.ts › should play video @smoke [timeout]
@@ -135,6 +134,7 @@ library/inspector/cli-codegen-3.spec.ts › cli codegen › should generate fram
135134
library/launcher.spec.ts › should throw a friendly error if its headed and there is no xserver on linux running [fail]
136135
library/locator-dispatchevent-touch.spec.ts › should support touch points in touch event arguments [fail]
137136
library/multiclient.spec.ts › last emulateMedia wins [fail]
137+
library/multiclient.spec.ts › should unroute websockets [timeout]
138138
library/page-clock.spec.ts › popup › should tick after popup [flaky]
139139
library/page-event-crash.spec.ts › should be able to close context when page crashes [timeout]
140140
library/page-event-crash.spec.ts › should cancel navigation when page crashes [timeout]
@@ -149,13 +149,13 @@ library/permissions.spec.ts › permissions › should trigger permission onchan
149149
library/permissions.spec.ts › should support clipboard read [fail]
150150
library/popup.spec.ts › BrowserContext.addInitScript should apply to a cross-process popup [flaky]
151151
library/popup.spec.ts › should expose function from browser context [fail]
152-
library/popup.spec.ts › should inherit offline from browser context [fail]
153152
library/popup.spec.ts › should inherit touch support from browser context [fail]
154153
library/popup.spec.ts › should not dispatch binding on a closed page [fail]
155154
library/popup.spec.ts › should not throw when click closes popup [timeout]
156155
library/popup.spec.ts › should use viewport size from window features [timeout]
157156
library/role-utils.spec.ts › axe-core accessible-text [timeout]
158157
library/role-utils.spec.ts › wpt accname #2 [timeout]
158+
library/route-web-socket.spec.ts › should emit close upon frame detach [timeout]
159159
library/screenshot.spec.ts › page screenshot › should work with device scale factor and scale:css [fail]
160160
library/screenshot.spec.ts › page screenshot › should work with device scale factor, clip and scale:css [fail]
161161
library/selector-generator.spec.ts › selector generator › should work in dynamic iframes without navigation [fail]
@@ -178,6 +178,7 @@ library/trace-viewer.spec.ts › should highlight locator in iframe while typing
178178
library/trace-viewer.spec.ts › should open console errors on click [fail]
179179
library/trace-viewer.spec.ts › should pick locator in iframe [fail]
180180
library/trace-viewer.spec.ts › should render console [fail]
181+
library/trace-viewer.spec.ts › should show only one pointer with multilevel iframes [fail]
181182
library/tracing.spec.ts › should collect trace with resources, but no js [fail]
182183
library/tracing.spec.ts › should produce screencast frames crop [fail]
183184
library/tracing.spec.ts › should produce screencast frames fit [fail]

tests/bidi/expectations/moz-firefox-nightly-page.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ page/elementhandle-scroll-into-view.spec.ts › should work @smoke [fail]
1313
page/expect-misc.spec.ts › strict mode violation error format [fail]
1414
page/frame-evaluate.spec.ts › should allow cross-frame element handles [fail]
1515
page/frame-evaluate.spec.ts › should not allow cross-frame element handles when frames do not script each other [fail]
16+
page/frame-evaluate.spec.ts › should dispose context on cross-origin navigation [fail]
17+
page/frame-evaluate.spec.ts › should dispose context on navigation [fail]
1618
page/frame-goto.spec.ts › should continue after client redirect [flaky]
1719
page/frame-hierarchy.spec.ts › should support framesets [fail]
1820
page/interception.spec.ts › should disable memory cache when intercepting [timeout]
@@ -54,6 +56,7 @@ page/page-accessibility.spec.ts › should work when there is a title [fail]
5456
page/page-accessibility.spec.ts › should work with aria-invalid accessibility tree [fail]
5557
page/page-accessibility.spec.ts › should work with regular text [fail]
5658
page/page-add-init-script.spec.ts › init script should run only once in popup [timeout]
59+
page/page-add-init-script.spec.ts › init script should run only once in iframe [fail]
5760
page/page-add-script-tag.spec.ts › should throw when added with content to the CSP page [fail]
5861
page/page-add-style-tag.spec.ts › should throw when added with content to the CSP page [timeout]
5962
page/page-aria-snapshot-ai.spec.ts › return empty snapshot when iframe is not loaded [flaky]

0 commit comments

Comments
 (0)