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
|
||||
* langs: js, python
|
||||
- `storageState` <[path]|[Object]>
|
||||
- `cookies` <[Array]<[Object]>> Optional cookies to set for context
|
||||
- `cookies` <[Array]<[Object]>> cookies to set for context
|
||||
- `name` <[string]>
|
||||
- `value` <[string]>
|
||||
- `url` <[string]> Optional either url or domain / path are required
|
||||
- `domain` <[string]> Optional either url or domain / path are required
|
||||
- `path` <[string]> Optional either url or domain / path are required
|
||||
- `expires` <[float]> Optional Unix time in seconds.
|
||||
- `httpOnly` <[boolean]> Optional httpOnly flag
|
||||
- `secure` <[boolean]> Optional secure flag
|
||||
- `sameSite` <[SameSiteAttribute]<"Strict"|"Lax"|"None">> Optional sameSite flag
|
||||
- `origins` <[Array]<[Object]>> Optional localStorage to set for context
|
||||
- `domain` <[string]> domain and path are required
|
||||
- `path` <[string]> domain and path are required
|
||||
- `expires` <[float]> Unix time in seconds.
|
||||
- `httpOnly` <[boolean]>
|
||||
- `secure` <[boolean]>
|
||||
- `sameSite` <[SameSiteAttribute]<"Strict"|"Lax"|"None">> sameSite flag
|
||||
- `origins` <[Array]<[Object]>> localStorage to set for context
|
||||
- `origin` <[string]>
|
||||
- `localStorage` <[Array]<[Object]>>
|
||||
- `name` <[string]>
|
||||
|
||||
@ -51,6 +51,7 @@ it('should capture local storage', async ({ contextFactory }) => {
|
||||
it('should set local storage', async ({ browser }) => {
|
||||
const context = await browser.newContext({
|
||||
storageState: {
|
||||
cookies: [],
|
||||
origins: [
|
||||
{
|
||||
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());
|
||||
});
|
||||
|
||||
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|{
|
||||
/**
|
||||
* Optional cookies to set for context
|
||||
* cookies to set for context
|
||||
*/
|
||||
cookies?: Array<{
|
||||
cookies: Array<{
|
||||
name: 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;
|
||||
|
||||
/**
|
||||
* Optional httpOnly flag
|
||||
*/
|
||||
httpOnly?: boolean;
|
||||
|
||||
/**
|
||||
* Optional secure flag
|
||||
*/
|
||||
secure?: boolean;
|
||||
|
||||
/**
|
||||
* Optional sameSite flag
|
||||
*/
|
||||
sameSite?: "Strict"|"Lax"|"None";
|
||||
sameSite: "Strict"|"Lax"|"None";
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Optional localStorage to set for context
|
||||
* localStorage to set for context
|
||||
*/
|
||||
origins?: Array<{
|
||||
origins: Array<{
|
||||
origin: string;
|
||||
|
||||
localStorage: Array<{
|
||||
@ -14680,53 +14669,42 @@ export interface BrowserContextOptions {
|
||||
*/
|
||||
storageState?: string|{
|
||||
/**
|
||||
* Optional cookies to set for context
|
||||
* cookies to set for context
|
||||
*/
|
||||
cookies?: Array<{
|
||||
cookies: Array<{
|
||||
name: 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;
|
||||
|
||||
/**
|
||||
* Optional httpOnly flag
|
||||
*/
|
||||
httpOnly?: boolean;
|
||||
|
||||
/**
|
||||
* Optional secure flag
|
||||
*/
|
||||
secure?: boolean;
|
||||
|
||||
/**
|
||||
* Optional sameSite flag
|
||||
*/
|
||||
sameSite?: "Strict"|"Lax"|"None";
|
||||
sameSite: "Strict"|"Lax"|"None";
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Optional localStorage to set for context
|
||||
* localStorage to set for context
|
||||
*/
|
||||
origins?: Array<{
|
||||
origins: Array<{
|
||||
origin: string;
|
||||
|
||||
localStorage: Array<{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user