chore: remove check for node < 16 (#33301)

This commit is contained in:
Yury Semikhatsky 2024-10-25 10:33:43 -07:00 committed by GitHub
parent 7e00112fec
commit f98531baee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 16 additions and 21 deletions

View File

@ -43,12 +43,8 @@ import type { StackFrame } from '@protocol/channels';
const StackUtils: typeof import('../bundles/utils/node_modules/@types/stack-utils') = require('./utilsBundleImpl').StackUtils;
const stackUtils = new StackUtils({ internals: StackUtils.nodeInternals() });
const nodeInternals = StackUtils.nodeInternals();
const nodeMajorVersion = +process.versions.node.split('.')[0];
export function parseStackTraceLine(line: string): StackFrame | null {
if (!process.env.PWDEBUGIMPL && nodeMajorVersion < 16 && nodeInternals.some(internal => internal.test(line)))
return null;
const frame = stackUtils.parseLine(line);
if (!frame)
return null;

View File

@ -378,11 +378,6 @@ export function restartWithExperimentalTsEsm(configFile: string | undefined, for
// Now check for the newer API presence.
if (!require('node:module').register) {
// Older API is experimental, only supported on Node 16+.
const nodeVersion = +process.versions.node.split('.')[0];
if (nodeVersion < 16)
return false;
// With older API requiring a process restart, do so conditionally on the config.
const configIsModule = !!configFile && fileIsModule(configFile);
if (!force && !configIsModule)

View File

@ -36,6 +36,7 @@ export type BrowserTestWorkerFixtures = PageWorkerFixtures & {
browserType: BrowserType;
isAndroid: boolean;
isElectron: boolean;
nodeVersion: { major: number, minor: number, patch: number };
bidiTestSkipPredicate: (info: TestInfo) => boolean;
};
@ -96,6 +97,11 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
await run(Number(browserVersion.split('.')[0]));
}, { scope: 'worker' }],
nodeVersion: [async ({}, use) => {
const [major, minor, patch] = process.versions.node.split('.');
await use({ major: +major, minor: +minor, patch: +patch });
}, { scope: 'worker' }],
isAndroid: [false, { scope: 'worker' }],
isElectron: [false, { scope: 'worker' }],
electronMajorVersion: [0, { scope: 'worker' }],

View File

@ -880,9 +880,9 @@ it('should respect timeout after redirects', async function({ context, server })
expect(error.message).toContain(`Request timed out after 100ms`);
});
it('should not hang on a brotli encoded Range request', async ({ context, server }) => {
it('should not hang on a brotli encoded Range request', async ({ context, server, nodeVersion }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/18190' });
it.skip(+process.versions.node.split('.')[0] < 18);
it.skip(nodeVersion.major < 18);
const encodedRequestPayload = zlib.brotliCompressSync(Buffer.from('A'));
server.setRoute('/brotli', (req, res) => {
@ -1094,10 +1094,9 @@ it('should support multipart/form-data and keep the order', async function({ con
expect(response.status()).toBe(200);
});
it('should support repeating names in multipart/form-data', async function({ context, server }) {
it('should support repeating names in multipart/form-data', async function({ context, server, nodeVersion }) {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28070' });
const nodeVersion = +process.versions.node.split('.')[0];
it.skip(nodeVersion < 20, 'File is not available in Node.js < 20. FormData is not available in Node.js < 18');
it.skip(nodeVersion.major < 20, 'File is not available in Node.js < 20. FormData is not available in Node.js < 18');
const postBodyPromise = new Promise<string>(resolve => {
server.setRoute('/empty.html', async (req, res) => {
resolve((await req.postBody).toString('utf-8'));

View File

@ -204,13 +204,13 @@ it('should handle missing file', async ({ contextFactory }, testInfo) => {
expect(error.message).toContain(`Error reading storage state from ${file}:\nENOENT`);
});
it('should handle malformed file', async ({ contextFactory }, testInfo) => {
it('should handle malformed file', async ({ contextFactory, nodeVersion }, testInfo) => {
const file = testInfo.outputPath('state.json');
fs.writeFileSync(file, 'not-json', 'utf-8');
const error = await contextFactory({
storageState: file,
}).catch(e => e);
if (+process.versions.node.split('.')[0] > 18)
if (nodeVersion.major > 18)
expect(error.message).toContain(`Error reading storage state from ${file}:\nUnexpected token 'o', \"not-json\" is not valid JSON`);
else
expect(error.message).toContain(`Error reading storage state from ${file}:\nUnexpected token o in JSON at position 1`);

View File

@ -130,9 +130,8 @@ it('should be callable twice', async ({ browserType }) => {
await browser.close();
});
it('should allow await using', async ({ browserType }) => {
const nodeVersion = +process.versions.node.split('.')[0];
it.skip(nodeVersion < 18);
it('should allow await using', async ({ browserType, nodeVersion }) => {
it.skip(nodeVersion.major < 18);
let b: Browser;
let c: BrowserContext;

View File

@ -727,9 +727,9 @@ test.describe('browser', () => {
await browser.close();
});
test('should return target connection errors when using http2', async ({ browser, startCCServer, asset, browserName, isMac, isLinux }) => {
test('should return target connection errors when using http2', async ({ browser, startCCServer, asset, browserName, isMac, nodeVersion }) => {
test.skip(browserName === 'webkit' && isMac, 'WebKit on macOS does not proxy localhost');
test.skip(+process.versions.node.split('.')[0] < 20, 'http2.performServerHandshake is not supported in older Node.js versions');
test.skip(nodeVersion.major < 20, 'http2.performServerHandshake is not supported in older Node.js versions');
const serverURL = await startCCServer({ http2: true });
const page = await browser.newPage({