test: add test for android cookies on webview (#35399)

This commit is contained in:
Max Schmitt 2025-03-31 08:31:44 +01:00 committed by GitHub
parent 63cf78471f
commit fffd87af1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 0 deletions

View File

@ -69,3 +69,36 @@ test('select webview from socketName', async function({ androidDevice }) {
await newPage.close();
await context.close();
});
test.fixme('should be able to receive webView cookies', {
annotation: {
type: 'issue',
description: 'https://github.com/microsoft/playwright/issues/35392',
}
}, async function({ androidDevice, server }) {
expect(androidDevice.webViews().length).toBe(0);
server.setRoute('/cookies', (req, res) => {
res.setHeader('Set-Cookie', 'cookie1=value1; Path=/; HttpOnly');
res.setHeader('Content-Type', 'text/html');
res.end('<html><body>hello world</body></html>');
});
await androidDevice.shell('am start org.chromium.webview_shell/.WebViewBrowserActivity');
const webview = await androidDevice.webView({ pkg: 'org.chromium.webview_shell' });
const page = await webview.page();
await page.goto(server.CROSS_PROCESS_PREFIX + '/cookies');
const cookies = await page.context().cookies();
expect(cookies.length).toBe(1);
expect(cookies).toEqual([
{
name: 'cookie1',
value: 'value1',
domain: new URL(server.CROSS_PROCESS_PREFIX).hostname,
path: '/',
expires: -1,
httpOnly: true,
secure: false,
sameSite: 'Lax'
}
]);
await page.context().clearCookies();
});