Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/playwright-core/src/server/bidi/bidiBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export class BidiBrowserContext extends BrowserContext {
userContexts: [this._userContextId()],
}));
promises.push(this.doUpdateDefaultViewport());
promises.push(this.doUpdateDefaultEmulatedMedia());
if (this._options.geolocation)
promises.push(this.setGeolocation(this._options.geolocation));
if (this._options.locale) {
Expand Down Expand Up @@ -493,6 +494,17 @@ export class BidiBrowserContext extends BrowserContext {
}

override async doUpdateDefaultEmulatedMedia() {
const features = this._options;
const colorScheme =
features.colorScheme === 'no-override'
? null
: features.colorScheme === 'no-preference'
? undefined
: features.colorScheme;
await this._browser._browserSession.send('emulation.setMediaFeaturesOverride', {
features: { 'prefers-color-scheme': colorScheme },
userContexts: [this._userContextId()],
});
}

override async doExposePlaywrightBinding() {
Expand Down
11 changes: 11 additions & 0 deletions packages/playwright-core/src/server/bidi/bidiPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,17 @@ export class BidiPage implements PageDelegate {
}

async updateEmulateMedia(): Promise<void> {
const features = this._page.emulatedMedia();
const colorScheme =
features.colorScheme === 'no-override'
? null
: features.colorScheme === 'no-preference'
? undefined
: features.colorScheme;
await this._session.send('emulation.setMediaFeaturesOverride', {
features: { 'prefers-color-scheme': colorScheme },
contexts: [this._session.sessionId, ...this._session._browsingContexts],
});
}

async updateUserAgent(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export interface Commands {
params: Bidi.Emulation.SetLocaleOverrideParameters;
returnType: Bidi.EmptyResult;
};
'emulation.setMediaFeaturesOverride': {
params: Bidi.Emulation.SetMediaFeaturesOverrideParameters;
returnType: Bidi.Emulation.SetMediaFeaturesOverrideResult;
};
'emulation.setNetworkConditions': {
params: Bidi.Emulation.SetNetworkConditionsParameters;
returnType: Bidi.Emulation.SetNetworkConditionsResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ export type EmulationCommand =
| Emulation.SetForcedColorsModeThemeOverride
| Emulation.SetGeolocationOverride
| Emulation.SetLocaleOverride
| Emulation.SetMediaFeaturesOverride
| Emulation.SetNetworkConditions
| Emulation.SetScreenOrientationOverride
| Emulation.SetScreenSettingsOverride
Expand All @@ -1164,6 +1165,7 @@ export type EmulationResult =
| Emulation.SetForcedColorsModeThemeOverrideResult
| Emulation.SetGeolocationOverrideResult
| Emulation.SetLocaleOverrideResult
| Emulation.SetMediaFeaturesOverrideResult
| Emulation.SetScreenOrientationOverrideResult
| Emulation.SetScriptingEnabledResult
| Emulation.SetScrollbarTypeOverrideResult
Expand Down Expand Up @@ -1284,6 +1286,64 @@ export namespace Emulation {
export namespace Emulation {
export type SetLocaleOverrideResult = EmptyResult;
}
export namespace Emulation {
export type SetMediaFeaturesOverride = {
method: 'emulation.setMediaFeaturesOverride';
params: Emulation.SetMediaFeaturesOverrideParameters;
};
}
export namespace Emulation {
export type SetMediaFeaturesOverrideParameters = {
features: Emulation.MediaFeatures | null;
contexts?: [
BrowsingContext.BrowsingContext,
...BrowsingContext.BrowsingContext[],
];
userContexts?: [Browser.UserContext, ...Browser.UserContext[]];
};
}
export namespace Emulation {
export type MediaFeatures = {
'any-hover'?: 'none' | 'hover' | null;
'any-pointer'?: 'none' | 'coarse' | 'fine' | null;
color?: JsUint | null;
'color-gamut'?: 'srgb' | 'p3' | 'rec2020' | null;
'color-index'?: JsUint | null;
'display-mode'?:
| 'fullscreen'
| 'standalone'
| 'minimal-ui'
| 'browser'
| 'picture-in-picture'
| null;
'dynamic-range'?: 'standard' | 'high' | null;
'environment-blending'?: 'opaque' | 'additive' | 'subtractive' | null;
'forced-colors'?: 'none' | 'active' | null;
grid?: 0 | 1 | null;
'horizontal-viewport-segments'?: JsUint | null;
hover?: 'none' | 'hover' | null;
'inverted-colors'?: 'none' | 'inverted' | null;
monochrome?: JsUint | null;
'nav-controls'?: 'none' | 'back' | null;
'overflow-block'?: 'none' | 'scroll' | 'optional-paged' | 'paged' | null;
'overflow-inline'?: 'none' | 'scroll' | null;
pointer?: 'none' | 'coarse' | 'fine' | null;
'prefers-color-scheme'?: 'light' | 'dark' | null;
'prefers-contrast'?: 'no-preference' | 'more' | 'less' | 'custom' | null;
'prefers-reduced-data'?: 'no-preference' | 'reduce' | null;
'prefers-reduced-motion'?: 'no-preference' | 'reduce' | null;
'prefers-reduced-transparency'?: 'no-preference' | 'reduce' | null;
scan?: 'interlace' | 'progressive' | null;
scripting?: 'none' | 'initial-only' | 'enabled' | null;
update?: 'none' | 'slow' | 'fast' | null;
'vertical-viewport-segments'?: JsUint | null;
'video-color-gamut'?: 'srgb' | 'p3' | 'rec2020' | null;
'video-dynamic-range'?: 'standard' | 'high' | null;
};
}
export namespace Emulation {
export type SetMediaFeaturesOverrideResult = EmptyResult;
}
export namespace Emulation {
export type SetNetworkConditions = {
method: 'emulation.setNetworkConditions';
Expand Down
16 changes: 11 additions & 5 deletions tests/bidi/expectations/moz-firefox-nightly-library.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ library/agent-perform.spec.ts > retrieve a secret [fixme]
library/browsercontext-add-cookies.spec.ts > CO-040 should allow unnamed cookies [fixme]
library/browsercontext-basic.spec.ts > BC-024 fetch with keepalive should throw when offline [fixme]
library/browsercontext-basic.spec.ts > BC-018 should disable javascript [fixme]
library/browsercontext-basic.spec.ts > BC-029 should emulate media in cross-process iframe [fixme]
library/browsercontext-basic.spec.ts > BC-028 should emulate media in popup [fixme]
library/browsercontext-cookies-third-party.spec.ts > CO-057 same origin third party 'Partitioned;' cookie with different origin intermediate iframe [fixme]
library/browsercontext-cookies-third-party.spec.ts > CO-055 save/load third party 'Partitioned;' cookies [fixme]
library/browsercontext-cookies-third-party.spec.ts > CO-053 save/load third party non-partitioned cookies [fixme]
Expand All @@ -19,6 +17,7 @@ library/browsercontext-devtools.spec.ts > should close tab via close button [fix
library/browsercontext-devtools.spec.ts > should display screencast image [fixme]
library/browsercontext-devtools.spec.ts > should show no-pages placeholder when all tabs are closed [fixme]
library/browsercontext-events.spec.ts > BC-033 console event should work with element handles [fixme]
library/browsercontext-har.spec.ts > HA-081 should goBack to redirected navigation [fixme]
library/browsercontext-har.spec.ts > HA-082 should goForward to redirected navigation [fixme]
library/browsercontext-har.spec.ts > HA-089 should record overridden requests to har [fixme]
library/browsercontext-har.spec.ts > HA-088 should round-trip har with postData [fixme]
Expand All @@ -36,12 +35,14 @@ library/browsercontext-pages.spec.ts > BC-056 should click the button with devic
library/browsercontext-reuse.spec.ts > reuse connect > BC-076 should not cache resources [fixme]
library/browsercontext-reuse.spec.ts > reuse connect > BC-074 should reset serviceworker [fixme]
library/browsercontext-reuse.spec.ts > reuse connect > BC-075 should reset serviceworker that hangs in importScripts [fixme]
library/browsercontext-reuse.spec.ts > reuse connect > BC-083 should update viewport and media [fixme]
library/browsercontext-reuse.spec.ts > reuse launch > BC-076 should not cache resources [fixme]
library/browsercontext-reuse.spec.ts > reuse launch > BC-074 should reset serviceworker [fixme]
library/browsercontext-reuse.spec.ts > reuse launch > BC-075 should reset serviceworker that hangs in importScripts [fixme]
library/browsercontext-reuse.spec.ts > reuse launch > BC-083 should update viewport and media [fixme]
library/browsercontext-service-worker-policy.spec.ts > block > WO-030 should not throw error on about:blank [fixme]
library/browsercontext-service-worker-policy.spec.ts > WO-028 should allow cache-only service worker navigation while offline [fixme]
library/browsercontext-service-worker-policy.spec.ts > WO-028 should allow literal service worker navigation while offline [fixme]
library/browsercontext-service-worker-policy.spec.ts > WO-028 should allow network-fallback service worker navigation while offline [fixme]
library/browsercontext-service-worker-policy.spec.ts > WO-028 should allow preload-fallback service worker navigation while offline [fixme]
library/browsercontext-storage-state.spec.ts > ST-015 should roundtrip local storage in third-party context [fixme]
library/browsercontext-storage-state.spec.ts > ST-014 should set local storage in third-party context [fixme]
library/browsercontext-storage-state.spec.ts > ST-013 should work when service worker is intefering and the origin is not open [fixme]
Expand Down Expand Up @@ -97,7 +98,6 @@ library/debug-controller.spec.ts > should work with browser._launchServer [fixme
library/defaultbrowsercontext-1.spec.ts > DC-007 should support bypassCSP option [fixme]
library/defaultbrowsercontext-1.spec.ts > DC-008 should support javascriptEnabled option [fixme]
library/defaultbrowsercontext-2.spec.ts > DC-030 should have passed URL when launching with ignoreDefaultArgs: true [fixme]
library/defaultbrowsercontext-2.spec.ts > DC-014 should support colorScheme option [fixme]
library/defaultbrowsercontext-2.spec.ts > DC-017 should support contrast option [fixme]
library/defaultbrowsercontext-2.spec.ts > DC-016 should support forcedColors option [fixme]
library/defaultbrowsercontext-2.spec.ts > DC-012 should support hasTouch option [fixme]
Expand All @@ -106,11 +106,16 @@ library/defaultbrowsercontext-2.spec.ts > DC-013 should work in persistent conte
library/download.spec.ts > download event > DO-027 should be able to cancel pending downloads [fixme]
library/download.spec.ts > download event > DO-017 should report new window downloads [fixme]
library/download.spec.ts > download event > DO-025 should throw if browser dies [fixme]
library/emulation-coop.spec.ts > emulation with COOP > EM-025 should preserve context options [fixme]
library/emulation-coop.spec.ts > emulation with COOP > EM-026 should preserve page.emulateMedia [fixme]
library/emulation-coop.spec.ts > emulation with COOP > EM-027 should preserve mobile emulation [fixme]
library/emulation-focus.spec.ts > EM-015 should focus popups by default [fixme]
library/emulation-focus.spec.ts > EM-021 should focus with more than one page/context [fixme]
library/emulation-focus.spec.ts > EM-014 should think that all pages are focused @smoke [fixme]
library/emulation-focus.spec.ts > EM-023 should not blur iframe when interacting with another page/context [fixme]
library/fetch-proxy.spec.ts > PR-041 context request should pick up proxy credentials [fixme]
library/firefox/launcher.spec.ts > FF-003 should support custom firefox policies [fixme]
library/firefox/launcher.spec.ts > FF-004 should resize viewport with fractional device scale factor [fixme]
library/geolocation.spec.ts > GE-009 should use context options for popup [fixme]
library/har-websocket.spec.ts > HA-104 should attach websocket messages [fixme]
library/har-websocket.spec.ts > HA-105 should attach websocket messages for a still open websocket after stopping [fixme]
Expand All @@ -137,6 +142,7 @@ library/har.spec.ts > HA-056 should not hang on slow chunked response [fixme]
library/har.spec.ts > HA-032 should report the correct _transferSize with PNG files [fixme]
library/har.spec.ts > HA-046 should return security details directly from response [fixme]
library/har.spec.ts > HA-045 should return server address directly from response [fixme]
library/har.spec.ts > HA-113 should store binary content with a textual mime type as base64 [fixme]
library/headful.spec.ts > HE-014 should click bottom row w/ infobar in OOPIF [fixme]
library/headful.spec.ts > HE-013 should click in OOPIF [fixme]
library/heap.spec.ts > LE-014 cycle handles [fixme]
Expand Down
9 changes: 5 additions & 4 deletions tests/bidi/expectations/moz-firefox-nightly-page.conf
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,14 @@ page/page-drag.spec.ts > Drag and drop > DD-010 should work if the drag event is
page/page-drag.spec.ts > Drag and drop > DD-004 should work inside iframe [fixme]
page/page-drag.spec.ts > Drag and drop > DD-016 should work with locators [fixme]
page/page-drag.spec.ts > Drag and drop > DD-013 should work with the helper method [fixme]
page/page-drag.spec.ts > Drag and drop > DD-028 should report the default drop effect from effectAllowed [fixme]
page/page-drag.spec.ts > DD-019 should handle custom dataTransfer [fixme]
page/page-emulate-media.spec.ts > EM-007 should change the actual colors in css [fixme]
page/page-emulate-media.spec.ts > EM-004 should default to light [fixme]
page/page-emulate-media.spec.ts > EM-003 should emulate colorScheme should work @smoke [fixme]
page/page-emulate-media.spec.ts > EM-011 should emulate contrast [fixme]
page/page-emulate-media.spec.ts > EM-010 should emulate forcedColors [fixme]
page/page-emulate-media.spec.ts > EM-008 should emulate reduced motion [fixme]
page/page-emulate-media.spec.ts > EM-001 should emulate type @smoke [fixme]
page/page-emulate-media.spec.ts > EM-009 should keep reduced motion and color emulation after reload [fixme]
page/page-emulate-media.spec.ts > EM-012 should report hover and fine pointer for desktop [fixme]
page/page-emulate-media.spec.ts > EM-006 should work during navigation [fixme]
page/page-event-console.spec.ts > CM-008 should trigger correct Log [fixme]
page/page-event-console.spec.ts > CM-001 should work @smoke [fixme]
page/page-event-request.spec.ts > NE-095 should report requests and responses handled by service worker [fixme]
Expand All @@ -98,13 +95,16 @@ page/page-expose-function.spec.ts > EF-015 should work with setContent [fixme]
page/page-filechooser.spec.ts > FC-020 should be able to reset selected files with empty file list [fixme]
page/page-filechooser.spec.ts > FC-004 should emit event for iframe [fixme]
page/page-filechooser.spec.ts > FC-011 should respect timeout [fixme]
page/page-filechooser.spec.ts > user activation > FC-026 should not open file chooser without user activation [fixme]
page/page-goto.spec.ts > NA-055 should override referrer-policy [fixme]
page/page-goto.spec.ts > NA-052 should send referer [fixme]
page/page-goto.spec.ts > NA-053 should send referer of cross-origin URL [fixme]
page/page-history.spec.ts > NA-074 goBack/goForward should work with bfcache-able pages [fixme]
page/page-history.spec.ts > NA-073 page.goBack should work for file urls [fixme]
page/page-history.spec.ts > NA-085 regression test for issue 20791 [fixme]
page/page-keyboard.spec.ts > KB-026 should press audio and media control keys [fixme]
page/page-keyboard.spec.ts > KB-023 should press NumpadDecimal as Delete [fixme]
page/page-keyboard.spec.ts > KB-024 should type numpad digits with Shift [fixme]
page/page-mouse.spec.ts > MO-013 should always round down [fixme]
page/page-mouse.spec.ts > MO-002 should dblclick the div [fixme]
page/page-network-idle.spec.ts > NE-082 should not wait for an open EventSource connection [fixme]
Expand Down Expand Up @@ -139,6 +139,7 @@ page/page-screenshot.spec.ts > page screenshot animations > SS-054 should not ca
page/page-screenshot.spec.ts > page screenshot animations > SS-053 should not capture pseudo element css animation [fixme]
page/page-screenshot.spec.ts > page screenshot > SS-014 should allow transparency [fixme]
page/page-set-input-files.spec.ts > IF-002 should upload a folder [fixme]
page/page-set-input-files.spec.ts > IF-003 should upload a folder via label [fixme]
page/page-wait-for-load-state.spec.ts > WA-084 should wait for load state of about:blank popup [fixme]
page/page-wait-for-load-state.spec.ts > WA-085 should wait for load state of about:blank popup with noopener [fixme]
page/page-wait-for-load-state.spec.ts > WA-083 should wait for load state of empty url popup [fixme]
Expand Down
Loading