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
17 changes: 8 additions & 9 deletions docs/src/api/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand Down
1 change: 1 addition & 0 deletions tests/browsercontext-storage-state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions tests/global-fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
78 changes: 28 additions & 50 deletions types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
url?: string;

/**
* Optional either url or domain / path are required
* domain and path are required
*/
domain?: string;
domain: string;

/**
* Optional either url or domain / path are required
* domain and path are required
*/
path?: string;
path: string;

/**
* Optional Unix time in seconds.
* Unix time in seconds.
*/
expires?: number;
expires: number;

/**
* Optional httpOnly flag
*/
httpOnly?: boolean;
httpOnly: boolean;

/**
* Optional secure flag
*/
secure?: boolean;
secure: boolean;

/**
* Optional sameSite flag
* 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<{
Expand Down Expand Up @@ -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
*/
url?: string;

/**
* Optional either url or domain / path are required
* domain and path are required
*/
domain?: string;
domain: string;

/**
* Optional either url or domain / path are required
* domain and path are required
*/
path?: string;
path: string;

/**
* Optional Unix time in seconds.
* Unix time in seconds.
*/
expires?: number;
expires: number;

/**
* Optional httpOnly flag
*/
httpOnly?: boolean;
httpOnly: boolean;

/**
* Optional secure flag
*/
secure?: boolean;
secure: boolean;

/**
* Optional sameSite flag
* 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<{
Expand Down