mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(api): make storageState option type same as context.storageState (#9333)
This commit is contained in:
parent
480e5a69e8
commit
ab879fecd6
@ -207,17 +207,16 @@ Specify environment variables that will be visible to the browser. Defaults to `
|
|||||||
## js-python-context-option-storage-state
|
## js-python-context-option-storage-state
|
||||||
* langs: js, python
|
* langs: js, python
|
||||||
- `storageState` <[path]|[Object]>
|
- `storageState` <[path]|[Object]>
|
||||||
- `cookies` <[Array]<[Object]>> Optional cookies to set for context
|
- `cookies` <[Array]<[Object]>> cookies to set for context
|
||||||
- `name` <[string]>
|
- `name` <[string]>
|
||||||
- `value` <[string]>
|
- `value` <[string]>
|
||||||
- `url` <[string]> Optional either url or domain / path are required
|
- `domain` <[string]> domain and path are required
|
||||||
- `domain` <[string]> Optional either url or domain / path are required
|
- `path` <[string]> domain and path are required
|
||||||
- `path` <[string]> Optional either url or domain / path are required
|
- `expires` <[float]> Unix time in seconds.
|
||||||
- `expires` <[float]> Optional Unix time in seconds.
|
- `httpOnly` <[boolean]>
|
||||||
- `httpOnly` <[boolean]> Optional httpOnly flag
|
- `secure` <[boolean]>
|
||||||
- `secure` <[boolean]> Optional secure flag
|
- `sameSite` <[SameSiteAttribute]<"Strict"|"Lax"|"None">> sameSite flag
|
||||||
- `sameSite` <[SameSiteAttribute]<"Strict"|"Lax"|"None">> Optional sameSite flag
|
- `origins` <[Array]<[Object]>> localStorage to set for context
|
||||||
- `origins` <[Array]<[Object]>> Optional localStorage to set for context
|
|
||||||
- `origin` <[string]>
|
- `origin` <[string]>
|
||||||
- `localStorage` <[Array]<[Object]>>
|
- `localStorage` <[Array]<[Object]>>
|
||||||
- `name` <[string]>
|
- `name` <[string]>
|
||||||
|
|||||||
@ -51,6 +51,7 @@ it('should capture local storage', async ({ contextFactory }) => {
|
|||||||
it('should set local storage', async ({ browser }) => {
|
it('should set local storage', async ({ browser }) => {
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
storageState: {
|
storageState: {
|
||||||
|
cookies: [],
|
||||||
origins: [
|
origins: [
|
||||||
{
|
{
|
||||||
origin: 'https://www.example.com',
|
origin: 'https://www.example.com',
|
||||||
|
|||||||
@ -152,3 +152,9 @@ it('should set playwright as user-agent', async ({ playwright, server }) => {
|
|||||||
]);
|
]);
|
||||||
expect(serverRequest.headers['user-agent']).toBe('Playwright/' + getPlaywrightVersion());
|
expect(serverRequest.headers['user-agent']).toBe('Playwright/' + getPlaywrightVersion());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should be able to construct with context options', async ({ playwright, server, contextOptions }) => {
|
||||||
|
const request = await playwright.request.newContext(contextOptions);
|
||||||
|
const response = await request.get(server.EMPTY_PAGE);
|
||||||
|
expect(response.ok()).toBeTruthy();
|
||||||
|
});
|
||||||
|
|||||||
86
types/types.d.ts
vendored
86
types/types.d.ts
vendored
@ -12367,53 +12367,42 @@ export interface Browser extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
storageState?: string|{
|
storageState?: string|{
|
||||||
/**
|
/**
|
||||||
* Optional cookies to set for context
|
* cookies to set for context
|
||||||
*/
|
*/
|
||||||
cookies?: Array<{
|
cookies: Array<{
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
value: string;
|
value: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional either url or domain / path are required
|
* domain and path are required
|
||||||
*/
|
*/
|
||||||
url?: string;
|
domain: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional either url or domain / path are required
|
* domain and path are required
|
||||||
*/
|
*/
|
||||||
domain?: string;
|
path: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional either url or domain / path are required
|
* Unix time in seconds.
|
||||||
*/
|
*/
|
||||||
path?: string;
|
expires: number;
|
||||||
|
|
||||||
|
httpOnly: boolean;
|
||||||
|
|
||||||
|
secure: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional Unix time in seconds.
|
* sameSite flag
|
||||||
*/
|
*/
|
||||||
expires?: number;
|
sameSite: "Strict"|"Lax"|"None";
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional httpOnly flag
|
|
||||||
*/
|
|
||||||
httpOnly?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional secure flag
|
|
||||||
*/
|
|
||||||
secure?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional sameSite flag
|
|
||||||
*/
|
|
||||||
sameSite?: "Strict"|"Lax"|"None";
|
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional localStorage to set for context
|
* localStorage to set for context
|
||||||
*/
|
*/
|
||||||
origins?: Array<{
|
origins: Array<{
|
||||||
origin: string;
|
origin: string;
|
||||||
|
|
||||||
localStorage: Array<{
|
localStorage: Array<{
|
||||||
@ -14680,53 +14669,42 @@ export interface BrowserContextOptions {
|
|||||||
*/
|
*/
|
||||||
storageState?: string|{
|
storageState?: string|{
|
||||||
/**
|
/**
|
||||||
* Optional cookies to set for context
|
* cookies to set for context
|
||||||
*/
|
*/
|
||||||
cookies?: Array<{
|
cookies: Array<{
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
value: string;
|
value: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional either url or domain / path are required
|
* domain and path are required
|
||||||
*/
|
*/
|
||||||
url?: string;
|
domain: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional either url or domain / path are required
|
* domain and path are required
|
||||||
*/
|
*/
|
||||||
domain?: string;
|
path: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional either url or domain / path are required
|
* Unix time in seconds.
|
||||||
*/
|
*/
|
||||||
path?: string;
|
expires: number;
|
||||||
|
|
||||||
|
httpOnly: boolean;
|
||||||
|
|
||||||
|
secure: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional Unix time in seconds.
|
* sameSite flag
|
||||||
*/
|
*/
|
||||||
expires?: number;
|
sameSite: "Strict"|"Lax"|"None";
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional httpOnly flag
|
|
||||||
*/
|
|
||||||
httpOnly?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional secure flag
|
|
||||||
*/
|
|
||||||
secure?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional sameSite flag
|
|
||||||
*/
|
|
||||||
sameSite?: "Strict"|"Lax"|"None";
|
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional localStorage to set for context
|
* localStorage to set for context
|
||||||
*/
|
*/
|
||||||
origins?: Array<{
|
origins: Array<{
|
||||||
origin: string;
|
origin: string;
|
||||||
|
|
||||||
localStorage: Array<{
|
localStorage: Array<{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user