Skip to content

Commit 18c9ba8

Browse files
committed
Debug
1 parent 7858f60 commit 18c9ba8

File tree

15 files changed

+55
-54
lines changed

15 files changed

+55
-54
lines changed

.github/actions/run-test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ runs:
5252
echo "::endgroup::"
5353
shell: bash
5454
- name: Allow WSL network access for WSL2
55-
if: inputs.browsers-to-install == 'webkit-wsl'
55+
if: contains(inputs.browsers-to-install, 'webkit-wsl')
5656
shell: powershell
5757
run: |
5858
$wslAdapter = Get-NetAdapter | Where-Object {$_.Name -like "*WSL*"}

.github/workflows/tests_primary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- uses: ./.github/actions/run-test
3535
with:
3636
node-version: 22
37-
browsers-to-install: webkit-wsl
37+
browsers-to-install: webkit-wsl chromium
3838
command: npm run test -- --project=webkit-* --reporter=list
3939
bot-name: "webkit-wsl-headed"
4040
flakiness-client-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_CLIENT_ID }}

packages/playwright-core/bin/webkit-wsl-pipe-wrapper.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const child = spawn(executable, args, {
3232
stdio: ['inherit', 'inherit', 'inherit', 'pipe', 'pipe']
3333
});
3434

35-
socket.pipe(child.stdio[3]);
36-
child.stdio[4].pipe(socket);
35+
socket.pipe(/** @type {NodeJS.WritableStream} */ (child.stdio[3]));
36+
/** @type {NodeJS.ReadableStream} */ (child.stdio[4]).pipe(socket);
3737

3838
// Handle cleanup
3939
socket.on('end', () => child.kill());

packages/playwright-core/src/server/webkit/webkit.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export class WebKit extends BrowserType {
9999
}
100100

101101
export function translatePathToWSL(path: string): string {
102-
console.log('translatePathToWSL', path);
103102
const result = spawnSync('wsl', ['-d', 'playwright', '--cd', '/home/pwuser', 'wslpath', path.replace(/\\/g, '\\\\')]).stdout.toString().trim();
104103
return result;
105104
}

packages/playwright-core/src/server/webkit/wkPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { WKInterceptableRequest, WKRouteImpl } from './wkInterceptableRequest';
3939
import { WKProvisionalPage } from './wkProvisionalPage';
4040
import { WKWorkers } from './wkWorkers';
4141
import { debugLogger } from '../utils/debugLogger';
42+
import { translatePathToWSL } from './webkit';
4243

4344
import type { Protocol } from './protocol';
4445
import type { WKBrowserContext } from './wkBrowser';
@@ -49,7 +50,6 @@ import type { JSHandle } from '../javascript';
4950
import type { InitScript, PageDelegate } from '../page';
5051
import type { Progress } from '../progress';
5152
import type * as types from '../types';
52-
import { translatePathToWSL } from './webkit';
5353

5454
const UTILITY_WORLD_NAME = '__playwright_utility_world__';
5555

tests/config/browserTest.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,14 @@ type BrowserTestTestFixtures = PageTestFixtures & {
5959

6060
const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>({
6161
loopback: [async ({ channel }, use) => {
62-
if (!channel)
63-
return await use(undefined);
64-
if (execSync('wsl -d playwright --cd /home/pwuser wslinfo --networking-mode').includes('nat'))
62+
if (channel === 'webkit-wsl' && execSync('wsl -d playwright --cd /home/pwuser wslinfo --networking-mode').includes('nat'))
6563
return await use(execSync('wsl -d playwright --cd /home/pwuser ip route show', { encoding: 'utf8' }).trim().split('\n').find(line => line.includes('default'))?.split(' ')[2]);
6664
return await use(undefined);
6765
}, { scope: 'worker', timeout: 10000 }],
6866

69-
loopback2: [async ({ channel }, use) => {
70-
if (!channel)
71-
return await use(undefined);
72-
if (execSync('wsl -d playwright --cd /home/pwuser wslinfo --networking-mode').includes('nat'))
73-
return await use(execSync('wsl -d playwright --cd /home/pwuser ip route show', { encoding: 'utf8' }).trim().split('\n').find(line => line.includes('default'))?.split(' ')[2]);
67+
loopback2: [async ({ channel, loopback }, use) => {
68+
if (channel === 'webkit-wsl' && loopback)
69+
return await use(`${loopback}.nip.io`);
7470
return await use(undefined);
7571
}, { scope: 'worker', timeout: 10000 }],
7672

tests/config/proxy.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const kConnectHostsToIgnore = new Set([
2929
export class TestProxy {
3030
readonly PORT: number;
3131
readonly URL: string;
32+
readonly HOSTNAME: string;
3233

3334
connectHosts: string[] = [];
3435
requestUrls: string[] = [];
@@ -38,15 +39,16 @@ export class TestProxy {
3839
private readonly _sockets = new Set<net.Socket>();
3940
private _handlers: { event: string, handler: (...args: any[]) => void }[] = [];
4041

41-
static async create(port: number): Promise<TestProxy> {
42-
const proxy = new TestProxy(port);
42+
static async create(port: number, loopback: string): Promise<TestProxy> {
43+
const proxy = new TestProxy(port, loopback);
4344
await new Promise<void>(f => proxy._server.listen(port, f));
4445
return proxy;
4546
}
4647

47-
private constructor(port: number) {
48+
private constructor(port: number, loopback: string) {
4849
this.PORT = port;
49-
this.URL = `http://localhost:${port}`;
50+
this.URL = `http://${loopback}:${port}`;
51+
this.HOSTNAME = loopback;
5052
this._server = createProxy();
5153
this._server.on('connection', socket => this._onSocket(socket));
5254
}

tests/config/serverFixtures.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type ServerFixtures = {
3838

3939
export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
4040
loopback: [undefined, { scope: 'worker', option: true }],
41+
loopback2: [undefined, { scope: 'worker', option: true }],
4142
__servers: [async ({ loopback, loopback2 }, run, workerInfo) => {
4243
const assetsPath = path.join(__dirname, '..', 'assets');
4344
const cachedPath = path.join(__dirname, '..', 'assets', 'cached');
@@ -55,7 +56,7 @@ export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
5556
await socksServer.listen(socksPort);
5657

5758
const proxyPort = port + 3;
58-
const proxyServer = await TestProxy.create(proxyPort);
59+
const proxyServer = await TestProxy.create(proxyPort, loopback);
5960

6061
await run({
6162
asset: (p: string) => path.join(__dirname, '..', 'assets', ...p.split('/')),

tests/library/browsercontext-add-cookies.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ it('should set cookie with reasonable defaults', async ({ context, server, defau
300300
expect(cookies.sort((a, b) => a.name.localeCompare(b.name))).toEqual([{
301301
name: 'defaults',
302302
value: '123456',
303-
domain: 'localhost',
303+
domain: new URL(server.EMPTY_PAGE).hostname,
304304
path: '/',
305305
expires: -1,
306306
httpOnly: false,
@@ -312,7 +312,7 @@ it('should set cookie with reasonable defaults', async ({ context, server, defau
312312
it('should set a cookie with a path', async ({ context, page, server, browserName, isWindows, channel }) => {
313313
await page.goto(server.PREFIX + '/grid.html');
314314
await context.addCookies([{
315-
domain: 'localhost',
315+
domain: new URL(server.EMPTY_PAGE).hostname,
316316
path: '/grid.html',
317317
name: 'gridcookie',
318318
value: 'GRID',
@@ -321,7 +321,7 @@ it('should set a cookie with a path', async ({ context, page, server, browserNam
321321
expect(await context.cookies()).toEqual([{
322322
name: 'gridcookie',
323323
value: 'GRID',
324-
domain: 'localhost',
324+
domain: new URL(server.EMPTY_PAGE).hostname,
325325
path: '/grid.html',
326326
expires: -1,
327327
httpOnly: false,
@@ -459,8 +459,8 @@ it('should set secure cookies on secure WebSocket', async ({ contextFactory, htt
459459
const context = await contextFactory({ ignoreHTTPSErrors: true });
460460
const page = await context.newPage();
461461
await page.goto(httpsServer.EMPTY_PAGE);
462-
await context.addCookies([{ domain: 'localhost', path: '/', name: 'foo', value: 'bar', secure: true }]);
463-
await page.evaluate(port => new WebSocket(`wss://localhost:${port}/ws`), httpsServer.PORT);
462+
await context.addCookies([{ domain: new URL(httpsServer.PREFIX).hostname, path: '/', name: 'foo', value: 'bar', secure: true }]);
463+
await page.evaluate(({ hostname, port }) => new WebSocket(`wss://${hostname}:${port}/ws`), { hostname: new URL(httpsServer.PREFIX).hostname, port: httpsServer.PORT });
464464
const headers = await receivedWebSocketHeaders;
465465
expect(headers.cookie).toBe('foo=bar');
466466
});

tests/library/browsercontext-cookies.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ it('should get a cookie @smoke', async ({ context, page, server, defaultSameSite
3131
expect(await context.cookies()).toEqual([{
3232
name: 'username',
3333
value: 'John Doe',
34-
domain: 'localhost',
34+
domain: new URL(server.EMPTY_PAGE).hostname,
3535
path: '/',
3636
expires: -1,
3737
httpOnly: false,
@@ -55,7 +55,7 @@ it('should get a non-session cookie', async ({ context, page, server, defaultSam
5555
expect(cookies[0]).toEqual({
5656
name: 'username',
5757
value: 'John Doe',
58-
domain: 'localhost',
58+
domain: new URL(server.EMPTY_PAGE).hostname,
5959
path: '/',
6060
// We will check this separately.
6161
expires: expect.anything(),
@@ -122,7 +122,7 @@ it('should get multiple cookies', async ({ context, page, server, defaultSameSit
122122
{
123123
name: 'password',
124124
value: '1234',
125-
domain: 'localhost',
125+
domain: new URL(server.EMPTY_PAGE).hostname,
126126
path: '/',
127127
expires: -1,
128128
httpOnly: false,
@@ -132,7 +132,7 @@ it('should get multiple cookies', async ({ context, page, server, defaultSameSit
132132
{
133133
name: 'username',
134134
value: 'John Doe',
135-
domain: 'localhost',
135+
domain: new URL(server.EMPTY_PAGE).hostname,
136136
path: '/',
137137
expires: -1,
138138
httpOnly: false,
@@ -391,7 +391,7 @@ it('should parse cookie with large Max-Age correctly', async ({ server, page, de
391391
{
392392
name: 'cookie1',
393393
value: 'value1',
394-
domain: 'localhost',
394+
domain: new URL(server.EMPTY_PAGE).hostname,
395395
path: '/',
396396
expires: expect.any(Number),
397397
httpOnly: false,

0 commit comments

Comments
 (0)