mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(cookies): follow up to make all platform tests pass
This commit is contained in:
parent
0ffd99bdac
commit
8989da6c16
@ -69,8 +69,9 @@ export class BrowserContext extends EventEmitter {
|
|||||||
async cookies(...urls: string[]): Promise<NetworkCookie[]> {
|
async cookies(...urls: string[]): Promise<NetworkCookie[]> {
|
||||||
const { cookies } = await this._browser._client.send('Storage.getCookies', { browserContextId: this._id || undefined });
|
const { cookies } = await this._browser._client.send('Storage.getCookies', { browserContextId: this._id || undefined });
|
||||||
return filterCookies(cookies.map(c => {
|
return filterCookies(cookies.map(c => {
|
||||||
const copy = { sameSite: 'None', ...c, size: undefined } as NetworkCookie;
|
const copy: any = { sameSite: 'None', ...c };
|
||||||
return copy;
|
delete copy.size;
|
||||||
|
return copy as NetworkCookie;
|
||||||
}), urls);
|
}), urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,11 @@ export class BrowserContext extends EventEmitter {
|
|||||||
const { cookies } = await this._connection.send('Browser.getCookies', {
|
const { cookies } = await this._connection.send('Browser.getCookies', {
|
||||||
browserContextId: this._browserContextId || undefined
|
browserContextId: this._browserContextId || undefined
|
||||||
});
|
});
|
||||||
return filterCookies(cookies, urls);
|
return filterCookies(cookies, urls).map(c => {
|
||||||
|
const copy: any = { ... c };
|
||||||
|
delete copy.size;
|
||||||
|
return copy as NetworkCookie;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearCookies() {
|
async clearCookies() {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import * as frames from './frames';
|
import * as frames from './frames';
|
||||||
import { assert } from './helper';
|
import { assert } from './helper';
|
||||||
|
import { NetworkManager } from './chromium/NetworkManager';
|
||||||
|
|
||||||
export type NetworkCookie = {
|
export type NetworkCookie = {
|
||||||
name: string,
|
name: string,
|
||||||
@ -28,7 +29,7 @@ export type SetNetworkCookieParam = {
|
|||||||
sameSite?: 'Strict' | 'Lax' | 'None'
|
sameSite?: 'Strict' | 'Lax' | 'None'
|
||||||
};
|
};
|
||||||
|
|
||||||
export function filterCookies(cookies: NetworkCookie[], urls: string[]) {
|
export function filterCookies(cookies: NetworkCookie[], urls: string[]): NetworkCookie[] {
|
||||||
const parsedURLs = urls.map(s => new URL(s));
|
const parsedURLs = urls.map(s => new URL(s));
|
||||||
// Chromiums's cookies are missing sameSite when it is 'None'
|
// Chromiums's cookies are missing sameSite when it is 'None'
|
||||||
return cookies.filter(c => {
|
return cookies.filter(c => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user