Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(rpc): more protocol nits (#3246)
Pavel Feldman93056ed8eff3
diff --git a/docs/api.md b/docs/api.mdindex 975ecf5ae5..0d8f3a3ec3 100644--- a/docs/api.md+++ b/docs/api.md@@ -217,7 +217,7 @@ Indicates that the browser is connected.- `httpCredentials` <[Object]> Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).- `username` <[string]>- `password` <[string]>- - `colorScheme` <"dark"|"light"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'.+ - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'.- `logger` <[Logger]> Logger sink for Playwright logging.- returns: <[Promise]<[BrowserContext]>>@@ -259,7 +259,7 @@ Creates a new browser context. It won't share cookies/cache with other browser c- `httpCredentials` <[Object]> Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).- `username` <[string]>- `password` <[string]>- - `colorScheme` <"dark"|"light"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'.+ - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'.- `logger` <[Logger]> Logger sink for Playwright logging.- returns: <[Promise]<[Page]>>@@ -1145,8 +1145,8 @@ await page.dispatchEvent('#source', 'dragstart', { dataTransfer });#### page.emulateMedia(options)- `options` <[Object]>- - `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. Omitting `media` or passing `undefined` does not change the emulated value.- - `colorScheme` <?"dark"|"light"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing `null` disables color scheme emulation. Omitting `colorScheme` or passing `undefined` does not change the emulated value.+ - `media` <null|"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. Omitting `media` or passing `undefined` does not change the emulated value.+ - `colorScheme` <null|"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing `null` disables color scheme emulation. Omitting `colorScheme` or passing `undefined` does not change the emulated value.- returns: <[Promise]>```js@@ -4074,7 +4074,7 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.- `httpCredentials` <[Object]> Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).- `username` <[string]>- `password` <[string]>- - `colorScheme` <"dark"|"light"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'.+ - `colorScheme` <"light"|"dark"|"no-preference"> Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See [page.emulateMedia(options)](#pageemulatemediaoptions) for more details. Defaults to '`light`'.- returns: <[Promise]<[BrowserContext]>> Promise that resolves to the persistent browser context instance.Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this context will automatically close the browser.diff --git a/src/rpc/channels.ts b/src/rpc/channels.tsindex f89cb117b7..431099e2e5 100644--- a/src/rpc/channels.ts+++ b/src/rpc/channels.ts@@ -317,7 +317,7 @@ export type BrowserTypeLaunchPersistentContextParams = {deviceScaleFactor?: number,isMobile?: boolean,hasTouch?: boolean,- colorScheme?: 'dark' | 'light' | 'no-preference',+ colorScheme?: 'light' | 'dark' | 'no-preference',acceptDownloads?: boolean,};export type BrowserTypeLaunchPersistentContextOptions = {@@ -372,7 +372,7 @@ export type BrowserTypeLaunchPersistentContextOptions = {deviceScaleFactor?: number,isMobile?: boolean,hasTouch?: boolean,- colorScheme?: 'dark' | 'light' | 'no-preference',+ colorScheme?: 'light' | 'dark' | 'no-preference',acceptDownloads?: boolean,};export type BrowserTypeLaunchPersistentContextResult = {diff --git a/src/rpc/protocol.yml b/src/rpc/protocol.ymlindex 6ed80a1fd8..cb0f517856 100644--- a/src/rpc/protocol.yml+++ b/src/rpc/protocol.yml@@ -329,8 +329,8 @@ BrowserType:colorScheme:type: enum?literals:- - dark- light+ - dark- no-preferenceacceptDownloads: boolean?returns:diff --git a/src/rpc/validator.ts b/src/rpc/validator.tsindex 254e746322..d760365666 100644--- a/src/rpc/validator.ts+++ b/src/rpc/validator.ts@@ -208,7 +208,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {deviceScaleFactor: tOptional(tNumber),isMobile: tOptional(tBoolean),hasTouch: tOptional(tBoolean),- colorScheme: tOptional(tEnum(['dark', 'light', 'no-preference'])),+ colorScheme: tOptional(tEnum(['light', 'dark', 'no-preference'])),acceptDownloads: tOptional(tBoolean),});scheme.BrowserServerCloseParams = tOptional(tObject({}));diff --git a/utils/doclint/dumpTypes.js b/utils/doclint/dumpTypes.jsnew file mode 100644index 0000000000..a967685612--- /dev/null+++ b/utils/doclint/dumpTypes.js@@ -0,0 +1,77 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++const playwright = require('../../');+const path = require('path');+const Source = require('./Source');+const mdBuilder = require('./check_public_api/MDBuilder');+const PROJECT_DIR = path.join(__dirname, '..', '..');++(async () => {+ const api = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'api.md'));+ const browser = await playwright.chromium.launch();+ const page = await browser.newPage();+ const { documentation } = await mdBuilder(page, [api]);+ const result = serialize(documentation);+ console.log(JSON.stringify(result, undefined, 2));+ await browser.close();+})()++function serialize(documentation) {+ const result = {};+ for (const clazz of documentation.classesArray)+ result[clazz.name] = serializeClass(clazz);+ return result;+}++function serializeClass(clazz) {+ const result = { name: clazz.name };+ result.members = {};+ for (const member of clazz.membersArray)+ result.members[member.name] = serializeMember(member);+ return result;+}++function serializeMember(member) {+ const result = { ...member };+ delete result.args;+ delete result.argsArray;+ result.args = {};+ for (const arg of member.argsArray)+ result.args[arg.name] = serializeProperty(arg);+ if (member.type)+ result.type = serializeType(member.type)+ return result;+}++function serializeProperty(arg) {+ const result = { ...arg };+ delete result.args;+ delete result.argsArray;+ if (arg.type)+ result.type = serializeType(arg.type)+ return result;+}++function serializeType(type) {+ const result = { ...type };+ if (type.properties) {+ result.properties = {};+ for (const prop of type.properties)+ result.properties[prop.name] = serializeProperty(prop);+ }+ return result;+}