api(dotnet): normalize enums, remove browser channel enum (#6738)
This commit is contained in:
parent
15bf6a0a1b
commit
f7f08c9c02
|
|
@ -960,17 +960,33 @@ await page.EvaluateAsync("matchMedia('(prefers-color-scheme: no-preference)').ma
|
|||
```
|
||||
|
||||
### option: Page.emulateMedia.media
|
||||
* langs: js, python, java
|
||||
- `media` <null|[Media]<"screen"|"print">>
|
||||
|
||||
Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`.
|
||||
Passing `null` disables CSS media emulation.
|
||||
|
||||
### option: Page.emulateMedia.media
|
||||
* langs: csharp
|
||||
- `media` <[Media]<"screen"|"print"|"null">>
|
||||
|
||||
Changes the CSS media type of the page. The only allowed values are `'Screen'`, `'Print'` and `'Null'`.
|
||||
Passing `'Null'` disables CSS media emulation.
|
||||
|
||||
### option: Page.emulateMedia.colorScheme
|
||||
* langs: js, python, java
|
||||
- `colorScheme` <null|[ColorScheme]<"light"|"dark"|"no-preference">>
|
||||
|
||||
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
|
||||
`null` disables color scheme emulation.
|
||||
|
||||
### option: Page.emulateMedia.colorScheme
|
||||
* langs: csharp
|
||||
- `colorScheme` <[ColorScheme]<"light"|"dark"|"no-preference"|"null">>
|
||||
|
||||
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
|
||||
`'Null'` disables color scheme emulation.
|
||||
|
||||
### option: Page.emulateMedia.reducedMotion
|
||||
* langs: js, python, java
|
||||
- `reducedMotion` <null|[ReducedMotion]<"reduce"|"no-preference">>
|
||||
|
|
|
|||
|
|
@ -603,7 +603,9 @@ Additional arguments to pass to the browser instance. The list of Chromium flags
|
|||
[here](http://peter.sh/experiments/chromium-command-line-switches/).
|
||||
|
||||
## browser-option-channel
|
||||
- `channel` <[BrowserChannel]<"chrome"|"chrome-beta"|"chrome-dev"|"chrome-canary"|"msedge"|"msedge-beta"|"msedge-dev"|"msedge-canary">>
|
||||
- `channel` <[string]>
|
||||
|
||||
Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", "msedge-canary".
|
||||
|
||||
Browser distribution channel. Read more about using [Google Chrome and Microsoft Edge](./browsers.md#google-chrome--microsoft-edge).
|
||||
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ export interface BrowserTypeChannel extends Channel {
|
|||
connectOverCDP(params: BrowserTypeConnectOverCDPParams, metadata?: Metadata): Promise<BrowserTypeConnectOverCDPResult>;
|
||||
}
|
||||
export type BrowserTypeLaunchParams = {
|
||||
channel?: 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary' | 'firefox-stable',
|
||||
channel?: string,
|
||||
executablePath?: string,
|
||||
args?: string[],
|
||||
ignoreAllDefaultArgs?: boolean,
|
||||
|
|
@ -244,7 +244,7 @@ export type BrowserTypeLaunchParams = {
|
|||
slowMo?: number,
|
||||
};
|
||||
export type BrowserTypeLaunchOptions = {
|
||||
channel?: 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary' | 'firefox-stable',
|
||||
channel?: string,
|
||||
executablePath?: string,
|
||||
args?: string[],
|
||||
ignoreAllDefaultArgs?: boolean,
|
||||
|
|
@ -272,7 +272,7 @@ export type BrowserTypeLaunchResult = {
|
|||
browser: BrowserChannel,
|
||||
};
|
||||
export type BrowserTypeLaunchPersistentContextParams = {
|
||||
channel?: 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary' | 'firefox-stable',
|
||||
channel?: string,
|
||||
executablePath?: string,
|
||||
args?: string[],
|
||||
ignoreAllDefaultArgs?: boolean,
|
||||
|
|
@ -343,7 +343,7 @@ export type BrowserTypeLaunchPersistentContextParams = {
|
|||
slowMo?: number,
|
||||
};
|
||||
export type BrowserTypeLaunchPersistentContextOptions = {
|
||||
channel?: 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary' | 'firefox-stable',
|
||||
channel?: string,
|
||||
executablePath?: string,
|
||||
args?: string[],
|
||||
ignoreAllDefaultArgs?: boolean,
|
||||
|
|
|
|||
|
|
@ -223,18 +223,7 @@ SerializedError:
|
|||
LaunchOptions:
|
||||
type: mixin
|
||||
properties:
|
||||
channel:
|
||||
type: enum?
|
||||
literals:
|
||||
- chrome
|
||||
- chrome-beta
|
||||
- chrome-dev
|
||||
- chrome-canary
|
||||
- msedge
|
||||
- msedge-beta
|
||||
- msedge-dev
|
||||
- msedge-canary
|
||||
- firefox-stable
|
||||
channel: string?
|
||||
executablePath: string?
|
||||
args:
|
||||
type: array?
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
|||
contentScript: tOptional(tBoolean),
|
||||
});
|
||||
scheme.BrowserTypeLaunchParams = tObject({
|
||||
channel: tOptional(tEnum(['chrome', 'chrome-beta', 'chrome-dev', 'chrome-canary', 'msedge', 'msedge-beta', 'msedge-dev', 'msedge-canary', 'firefox-stable'])),
|
||||
channel: tOptional(tString),
|
||||
executablePath: tOptional(tString),
|
||||
args: tOptional(tArray(tString)),
|
||||
ignoreAllDefaultArgs: tOptional(tBoolean),
|
||||
|
|
@ -181,7 +181,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
|||
slowMo: tOptional(tNumber),
|
||||
});
|
||||
scheme.BrowserTypeLaunchPersistentContextParams = tObject({
|
||||
channel: tOptional(tEnum(['chrome', 'chrome-beta', 'chrome-dev', 'chrome-canary', 'msedge', 'msedge-beta', 'msedge-dev', 'msedge-canary', 'firefox-stable'])),
|
||||
channel: tOptional(tString),
|
||||
executablePath: tOptional(tString),
|
||||
args: tOptional(tArray(tString)),
|
||||
ignoreAllDefaultArgs: tOptional(tBoolean),
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export type PlaywrightOptions = {
|
|||
export type BrowserOptions = PlaywrightOptions & {
|
||||
name: string,
|
||||
isChromium: boolean,
|
||||
channel?: types.BrowserChannel,
|
||||
channel?: string,
|
||||
downloadsPath?: string,
|
||||
traceDir?: string,
|
||||
headful?: boolean,
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export abstract class BrowserType extends SdkObject {
|
|||
this._registry = playwrightOptions.registry;
|
||||
}
|
||||
|
||||
executablePath(channel?: types.BrowserChannel): string {
|
||||
executablePath(channel?: string): string {
|
||||
return this._registry.executablePath(this._name) || '';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export class Chromium extends BrowserType {
|
|||
this._devtools = this._createDevTools();
|
||||
}
|
||||
|
||||
executablePath(channel?: types.BrowserChannel): string {
|
||||
executablePath(channel?: string): string {
|
||||
if (channel)
|
||||
return findChromiumChannel(channel);
|
||||
return super.executablePath(channel);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export class Firefox extends BrowserType {
|
|||
super('firefox', playwrightOptions);
|
||||
}
|
||||
|
||||
executablePath(channel?: types.BrowserChannel): string {
|
||||
executablePath(channel?: string): string {
|
||||
if (channel) {
|
||||
let executablePath = undefined;
|
||||
if ((channel as any) === 'firefox-stable')
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import { internalCallMetadata } from '../../instrumentation';
|
|||
import type { CallLog, EventData, Mode, Source } from './recorderTypes';
|
||||
import { BrowserContext } from '../../browserContext';
|
||||
import { isUnderTest } from '../../../utils/utils';
|
||||
import * as types from '../../types';
|
||||
|
||||
const readFileAsync = util.promisify(fs.readFile);
|
||||
const existsAsync = (path: string): Promise<boolean> => new Promise(resolve => fs.stat(path, err => resolve(!err)));
|
||||
|
|
@ -102,7 +101,7 @@ export class RecorderApp extends EventEmitter {
|
|||
];
|
||||
if (process.env.PWTEST_RECORDER_PORT)
|
||||
args.push(`--remote-debugging-port=${process.env.PWTEST_RECORDER_PORT}`);
|
||||
let channel: types.BrowserChannel | undefined;
|
||||
let channel: string | undefined;
|
||||
let executablePath: string | undefined;
|
||||
if (inspectedContext._browser.options.isChromium) {
|
||||
channel = inspectedContext._browser.options.channel;
|
||||
|
|
|
|||
|
|
@ -256,10 +256,8 @@ export type BrowserContextOptions = {
|
|||
|
||||
export type EnvArray = { name: string, value: string }[];
|
||||
|
||||
export type BrowserChannel = 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary' | 'firefox-stable';
|
||||
|
||||
type LaunchOptionsBase = {
|
||||
channel?: BrowserChannel,
|
||||
channel?: string,
|
||||
executablePath?: string,
|
||||
args?: string[],
|
||||
ignoreDefaultArgs?: string[],
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export class WebKit extends BrowserType {
|
|||
super('webkit', playwrightOptions);
|
||||
}
|
||||
|
||||
executablePath(channel?: types.BrowserChannel): string {
|
||||
executablePath(channel?: string): string {
|
||||
if (channel) {
|
||||
let executablePath = undefined;
|
||||
if ((channel as any) === 'technology-preview')
|
||||
|
|
|
|||
15
types/types.d.ts
vendored
15
types/types.d.ts
vendored
|
|
@ -6969,10 +6969,13 @@ export interface BrowserType<Unused = {}> {
|
|||
bypassCSP?: boolean;
|
||||
|
||||
/**
|
||||
* Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev",
|
||||
* "msedge-canary".
|
||||
*
|
||||
* Browser distribution channel. Read more about using
|
||||
* [Google Chrome and Microsoft Edge](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge).
|
||||
*/
|
||||
channel?: "chrome"|"chrome-beta"|"chrome-dev"|"chrome-canary"|"msedge"|"msedge-beta"|"msedge-dev"|"msedge-canary";
|
||||
channel?: string;
|
||||
|
||||
/**
|
||||
* Enable Chromium sandboxing. Defaults to `false`.
|
||||
|
|
@ -7310,10 +7313,13 @@ export interface BrowserType<Unused = {}> {
|
|||
args?: Array<string>;
|
||||
|
||||
/**
|
||||
* Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev",
|
||||
* "msedge-canary".
|
||||
*
|
||||
* Browser distribution channel. Read more about using
|
||||
* [Google Chrome and Microsoft Edge](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge).
|
||||
*/
|
||||
channel?: "chrome"|"chrome-beta"|"chrome-dev"|"chrome-canary"|"msedge"|"msedge-beta"|"msedge-dev"|"msedge-canary";
|
||||
channel?: string;
|
||||
|
||||
/**
|
||||
* Enable Chromium sandboxing. Defaults to `false`.
|
||||
|
|
@ -11229,10 +11235,13 @@ export interface LaunchOptions {
|
|||
args?: Array<string>;
|
||||
|
||||
/**
|
||||
* Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev",
|
||||
* "msedge-canary".
|
||||
*
|
||||
* Browser distribution channel. Read more about using
|
||||
* [Google Chrome and Microsoft Edge](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge).
|
||||
*/
|
||||
channel?: "chrome"|"chrome-beta"|"chrome-dev"|"chrome-canary"|"msedge"|"msedge-beta"|"msedge-dev"|"msedge-canary";
|
||||
channel?: string;
|
||||
|
||||
/**
|
||||
* Enable Chromium sandboxing. Defaults to `false`.
|
||||
|
|
|
|||
|
|
@ -217,7 +217,6 @@ function renderModelType(name, type) {
|
|||
*/
|
||||
function renderEnum(name, literals) {
|
||||
const body = [];
|
||||
body.push('Undefined = 0,');
|
||||
for (let literal of literals) {
|
||||
// strip out the quotes
|
||||
literal = literal.replace(/[\"]/g, ``)
|
||||
|
|
@ -789,6 +788,7 @@ function translateType(type, parent, generateNameCallback = t => t.name, optiona
|
|||
// Regular primitive enums are named in the markdown.
|
||||
if (type.name) {
|
||||
enumTypes.set(type.name, type.union.map(t => t.name));
|
||||
nullableTypes.push(type.name);
|
||||
return optional ? type.name + '?' : type.name;
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue