@lvce-editor/test-with-playwright-worker 22.38.3 → 22.38.5
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/coverageWorkerMain.js +2 -2
- package/dist/workerMain.js +92 -38
- package/package.json +1 -1
|
@@ -509,7 +509,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
509
509
|
}
|
|
510
510
|
};
|
|
511
511
|
const restoreMessageError = (error, _currentStack) => {
|
|
512
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
512
|
+
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
513
513
|
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
514
514
|
Object.defineProperty(restoredError, 'code', {
|
|
515
515
|
configurable: true,
|
|
@@ -597,7 +597,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
597
597
|
data: {
|
|
598
598
|
code: prettyError.code ?? error?.code,
|
|
599
599
|
codeFrame: prettyError.codeFrame,
|
|
600
|
-
name: prettyError.name,
|
|
600
|
+
name: prettyError.name ?? error?.name,
|
|
601
601
|
stack: getStack(prettyError),
|
|
602
602
|
type: getErrorType(prettyError)
|
|
603
603
|
},
|
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 () => {
|
|
@@ -770,7 +770,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
770
770
|
}
|
|
771
771
|
};
|
|
772
772
|
const restoreMessageError = (error, _currentStack) => {
|
|
773
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
773
|
+
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
774
774
|
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
775
775
|
Object.defineProperty(restoredError, 'code', {
|
|
776
776
|
configurable: true,
|
|
@@ -858,7 +858,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
858
858
|
data: {
|
|
859
859
|
code: prettyError.code ?? error?.code,
|
|
860
860
|
codeFrame: prettyError.codeFrame,
|
|
861
|
-
name: prettyError.name,
|
|
861
|
+
name: prettyError.name ?? error?.name,
|
|
862
862
|
stack: getStack(prettyError),
|
|
863
863
|
type: getErrorType(prettyError)
|
|
864
864
|
},
|
|
@@ -2263,6 +2263,28 @@ const getServerPath = async serverPath => {
|
|
|
2263
2263
|
throw new Error(`[test-with-playwright] server path not found`);
|
|
2264
2264
|
};
|
|
2265
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
|
+
|
|
2266
2288
|
/**
|
|
2267
2289
|
*
|
|
2268
2290
|
* @param {{browser:'chromium'|'firefox'|'webkit', signal:AbortSignal, headless:boolean}} options
|
|
@@ -2292,20 +2314,40 @@ const startBrowser = async ({
|
|
|
2292
2314
|
await patchPlaywrightFirefoxWorkerWebSocket();
|
|
2293
2315
|
}
|
|
2294
2316
|
const launcher = await getLauncher(browser);
|
|
2295
|
-
|
|
2317
|
+
signal.throwIfAborted();
|
|
2318
|
+
const options = {
|
|
2319
|
+
args: getBrowserLaunchArgs(browser),
|
|
2296
2320
|
headless
|
|
2297
|
-
});
|
|
2298
|
-
const page = await browserInstance.newPage();
|
|
2299
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
2300
|
-
signal.addEventListener('abort', async () => {
|
|
2301
|
-
await page.close();
|
|
2302
|
-
await browserInstance.close();
|
|
2303
|
-
});
|
|
2304
|
-
// @ts-ignore
|
|
2305
|
-
return {
|
|
2306
|
-
browser: browserInstance,
|
|
2307
|
-
page
|
|
2308
2321
|
};
|
|
2322
|
+
// Chromium 153 crashes when restoring OPFS handles from its in-memory IndexedDB backend.
|
|
2323
|
+
// An empty userDataDir gives each run a temporary disk-backed profile managed by Playwright.
|
|
2324
|
+
const browserInstance = browser === 'chromium' ? await launcher.launchPersistentContext('', options) : await launcher.launch(options);
|
|
2325
|
+
let disposal;
|
|
2326
|
+
const dispose = () => {
|
|
2327
|
+
signal.removeEventListener('abort', handleAbort);
|
|
2328
|
+
disposal ||= browserInstance.close();
|
|
2329
|
+
return disposal;
|
|
2330
|
+
};
|
|
2331
|
+
const handleAbort = () => {
|
|
2332
|
+
// The caller awaits disposal during teardown, including any cleanup error.
|
|
2333
|
+
void dispose().catch(() => {});
|
|
2334
|
+
};
|
|
2335
|
+
signal.addEventListener('abort', handleAbort, {
|
|
2336
|
+
once: true
|
|
2337
|
+
});
|
|
2338
|
+
try {
|
|
2339
|
+
signal.throwIfAborted();
|
|
2340
|
+
const page = await browserInstance.newPage();
|
|
2341
|
+
signal.throwIfAborted();
|
|
2342
|
+
return {
|
|
2343
|
+
browser: browserInstance,
|
|
2344
|
+
dispose,
|
|
2345
|
+
page
|
|
2346
|
+
};
|
|
2347
|
+
} catch (error) {
|
|
2348
|
+
await dispose();
|
|
2349
|
+
throw error;
|
|
2350
|
+
}
|
|
2309
2351
|
};
|
|
2310
2352
|
|
|
2311
2353
|
const getServerArgs = link => {
|
|
@@ -2368,29 +2410,36 @@ const setupTests = async ({
|
|
|
2368
2410
|
const port = await getPort();
|
|
2369
2411
|
const {
|
|
2370
2412
|
browser: browserInstance,
|
|
2413
|
+
dispose,
|
|
2371
2414
|
page
|
|
2372
2415
|
} = await startBrowser({
|
|
2373
2416
|
browser,
|
|
2374
2417
|
headless,
|
|
2375
2418
|
signal
|
|
2376
2419
|
});
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
link
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2420
|
+
try {
|
|
2421
|
+
const resolvedServerPath = await getServerPath(serverPath);
|
|
2422
|
+
const child = await startServer({
|
|
2423
|
+
...(link && link.length > 0 && {
|
|
2424
|
+
link
|
|
2425
|
+
}),
|
|
2426
|
+
onlyExtension,
|
|
2427
|
+
port,
|
|
2428
|
+
serverPath: resolvedServerPath,
|
|
2429
|
+
signal,
|
|
2430
|
+
testPath
|
|
2431
|
+
});
|
|
2432
|
+
return {
|
|
2433
|
+
browser: browserInstance,
|
|
2434
|
+
child,
|
|
2435
|
+
dispose,
|
|
2436
|
+
page,
|
|
2437
|
+
port
|
|
2438
|
+
};
|
|
2439
|
+
} catch (error) {
|
|
2440
|
+
await dispose();
|
|
2441
|
+
throw error;
|
|
2442
|
+
}
|
|
2394
2443
|
};
|
|
2395
2444
|
|
|
2396
2445
|
const getProcessEnv = () => {
|
|
@@ -2636,6 +2685,7 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
2636
2685
|
}
|
|
2637
2686
|
const {
|
|
2638
2687
|
child,
|
|
2688
|
+
dispose,
|
|
2639
2689
|
page,
|
|
2640
2690
|
port
|
|
2641
2691
|
} = await setupTests({
|
|
@@ -2704,10 +2754,14 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
2704
2754
|
}
|
|
2705
2755
|
});
|
|
2706
2756
|
} finally {
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2757
|
+
try {
|
|
2758
|
+
await tearDownTests({
|
|
2759
|
+
child,
|
|
2760
|
+
controller
|
|
2761
|
+
});
|
|
2762
|
+
} finally {
|
|
2763
|
+
await dispose();
|
|
2764
|
+
}
|
|
2711
2765
|
}
|
|
2712
2766
|
};
|
|
2713
2767
|
|