@lvce-editor/test-with-playwright-worker 22.38.2 → 22.38.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/workerMain.js +34 -6
- package/package.json +1 -1
package/dist/workerMain.js
CHANGED
|
@@ -3,10 +3,10 @@ import { readFile, writeFile, readdir, rm, mkdir, access, mkdtemp } from 'node:f
|
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import net from 'node:net';
|
|
5
5
|
import os, { tmpdir } from 'node:os';
|
|
6
|
-
import { fork } from 'node:child_process';
|
|
7
6
|
import { createRequire } from 'node:module';
|
|
7
|
+
import { fork } from 'node:child_process';
|
|
8
8
|
|
|
9
|
-
const require$
|
|
9
|
+
const require$2 = createRequire(import.meta.url);
|
|
10
10
|
const before = ` _onWebSocketOpened(event) {
|
|
11
11
|
const request2 = this._webSocketRequests.get(event.requestId);
|
|
12
12
|
assert(request2);
|
|
@@ -61,7 +61,7 @@ const patchCoreBundleContent = content => {
|
|
|
61
61
|
return content.split(before).join(after);
|
|
62
62
|
};
|
|
63
63
|
const getCoreBundlePath = () => {
|
|
64
|
-
const packageJsonPath = require$
|
|
64
|
+
const packageJsonPath = require$2.resolve('playwright-core/package.json');
|
|
65
65
|
return join(dirname(packageJsonPath), 'lib', 'coreBundle.js');
|
|
66
66
|
};
|
|
67
67
|
const patchPlaywrightFirefoxWorkerWebSocket = async () => {
|
|
@@ -1452,7 +1452,7 @@ const Cli = 6001;
|
|
|
1452
1452
|
const browserScriptCache = {};
|
|
1453
1453
|
const fileExtensionRegex = /\.[^.]+$/;
|
|
1454
1454
|
const generatedMaskIconClassRegex = /\bMaskIconCustomView[a-z0-9]+\b/g;
|
|
1455
|
-
const localServerUrlRegex = /http:\/\/localhost:\d+/g;
|
|
1455
|
+
const localServerUrlRegex = /http:\/\/(?:localhost|127\.0\.0\.1):\d+/g;
|
|
1456
1456
|
const tagBoundaryRegex = />\s*</g;
|
|
1457
1457
|
const getBrowserScriptCandidates = () => {
|
|
1458
1458
|
return [fileURLToPath(new URL('svgScreenshot.js', import.meta.url)), fileURLToPath(new URL('../../../../../dist/test-with-playwright-worker/dist/svgScreenshot.js', import.meta.url))];
|
|
@@ -1727,6 +1727,10 @@ const getTestState = (testOverlayState, text) => {
|
|
|
1727
1727
|
}
|
|
1728
1728
|
};
|
|
1729
1729
|
|
|
1730
|
+
// Keep the server bind address and browser URLs on the same address family.
|
|
1731
|
+
// Chromium can fall back to IPv4 even when Node resolved localhost to ::1.
|
|
1732
|
+
const testServerHost = '127.0.0.1';
|
|
1733
|
+
|
|
1730
1734
|
/**
|
|
1731
1735
|
* @param {string} absolutePath
|
|
1732
1736
|
* @param {number} port
|
|
@@ -1735,7 +1739,7 @@ const getTestState = (testOverlayState, text) => {
|
|
|
1735
1739
|
const getUrlFromTestFile = (absolutePath, port, traceFocus, traceRendererWorker) => {
|
|
1736
1740
|
const baseName = basename(absolutePath);
|
|
1737
1741
|
const htmlFileName = baseName.slice(0, -'.js'.length) + '.html';
|
|
1738
|
-
const url = new URL(`http
|
|
1742
|
+
const url = new URL(`http://${testServerHost}:${port}/tests/${htmlFileName}`);
|
|
1739
1743
|
if (traceFocus) {
|
|
1740
1744
|
url.searchParams.set('traceFocus', 'true');
|
|
1741
1745
|
}
|
|
@@ -1923,7 +1927,7 @@ const getResultCounts = status => {
|
|
|
1923
1927
|
}
|
|
1924
1928
|
};
|
|
1925
1929
|
const getAllTestsUrl = (port, filter, traceFocus, traceRendererWorker) => {
|
|
1926
|
-
const url = new URL(`http
|
|
1930
|
+
const url = new URL(`http://${testServerHost}:${port}/tests/_all.html`);
|
|
1927
1931
|
if (traceFocus) {
|
|
1928
1932
|
url.searchParams.set('traceFocus', 'true');
|
|
1929
1933
|
}
|
|
@@ -2259,6 +2263,28 @@ const getServerPath = async serverPath => {
|
|
|
2259
2263
|
throw new Error(`[test-with-playwright] server path not found`);
|
|
2260
2264
|
};
|
|
2261
2265
|
|
|
2266
|
+
const require$1 = createRequire(import.meta.url);
|
|
2267
|
+
const disabledFeaturesPrefix = '--disable-features=';
|
|
2268
|
+
const getBrowserLaunchArgs = (browser, platform = process.platform) => {
|
|
2269
|
+
if (browser !== 'chromium' || platform !== 'win32') {
|
|
2270
|
+
return [];
|
|
2271
|
+
}
|
|
2272
|
+
// SO_RANDOMIZE_PORT intermittently fails with WSAENOBUFS on Windows.
|
|
2273
|
+
// Read Playwright's defaults so this override preserves its other disabled features.
|
|
2274
|
+
const {
|
|
2275
|
+
server
|
|
2276
|
+
} = require$1('playwright-core/lib/coreBundle');
|
|
2277
|
+
const playwright = server.createPlaywright({
|
|
2278
|
+
sdkLanguage: 'javascript'
|
|
2279
|
+
});
|
|
2280
|
+
const defaultArgs = playwright.chromium._innerDefaultArgs({});
|
|
2281
|
+
const disabledFeatures = defaultArgs.find(argument => argument.startsWith(disabledFeaturesPrefix));
|
|
2282
|
+
if (!disabledFeatures) {
|
|
2283
|
+
throw new Error('Could not find Playwright Chromium disabled features');
|
|
2284
|
+
}
|
|
2285
|
+
return [`${disabledFeatures},TcpPortRandomizationWin`];
|
|
2286
|
+
};
|
|
2287
|
+
|
|
2262
2288
|
/**
|
|
2263
2289
|
*
|
|
2264
2290
|
* @param {{browser:'chromium'|'firefox'|'webkit', signal:AbortSignal, headless:boolean}} options
|
|
@@ -2289,6 +2315,7 @@ const startBrowser = async ({
|
|
|
2289
2315
|
}
|
|
2290
2316
|
const launcher = await getLauncher(browser);
|
|
2291
2317
|
const browserInstance = await launcher.launch({
|
|
2318
|
+
args: getBrowserLaunchArgs(browser),
|
|
2292
2319
|
headless
|
|
2293
2320
|
});
|
|
2294
2321
|
const page = await browserInstance.newPage();
|
|
@@ -2325,6 +2352,7 @@ const startServer = async ({
|
|
|
2325
2352
|
// signal,
|
|
2326
2353
|
env: {
|
|
2327
2354
|
...process.env,
|
|
2355
|
+
HOST: testServerHost,
|
|
2328
2356
|
ONLY_EXTENSION: onlyExtension,
|
|
2329
2357
|
PORT: String(port),
|
|
2330
2358
|
TEST_PATH: testPath
|