项目文件夹

文件
T
zyzyzyryxy 94752ffade fix: prevent dropping license notices on some files when publishing (#604)
This PR prevents license notices being dropped when creating package for
publication.

This can happen when first import in the file is type-only import that
gets removed during build. When there is no empty line between the
license block comment and such import, the comment is treated as related
to the import and gets removed alongside it.
Adding an empty line between copyright notice and the import fixes the
issue.

Co-authored-by: Piotr Paulski <piotrpaulski@chromium.org>
2025-11-24 12:38:30 +00:00

77 行
2.0 KiB
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import assert from 'node:assert';
import os from 'node:os';
import path from 'node:path';
import {describe, it} from 'node:test';
import {executablePath} from 'puppeteer';
import {launch} from '../src/browser.js';
describe('browser', () => {
it('cannot launch multiple times with the same profile', async () => {
const tmpDir = os.tmpdir();
const folderPath = path.join(tmpDir, `temp-folder-${crypto.randomUUID()}`);
const browser1 = await launch({
headless: true,
isolated: false,
userDataDir: folderPath,
executablePath: executablePath(),
devtools: false,
});
try {
try {
const browser2 = await launch({
headless: true,
isolated: false,
userDataDir: folderPath,
executablePath: executablePath(),
devtools: false,
});
await browser2.close();
assert.fail('not reached');
} catch (err) {
assert.strictEqual(
err.message,
`The browser is already running for ${folderPath}. Use --isolated to run multiple browser instances.`,
);
}
} finally {
await browser1.close();
}
});
it('launches with the initial viewport', async () => {
const tmpDir = os.tmpdir();
const folderPath = path.join(tmpDir, `temp-folder-${crypto.randomUUID()}`);
const browser = await launch({
headless: true,
isolated: false,
userDataDir: folderPath,
executablePath: executablePath(),
viewport: {
width: 1501,
height: 801,
},
devtools: false,
});
try {
const [page] = await browser.pages();
const result = await page.evaluate(() => {
return {width: window.innerWidth, height: window.innerHeight};
});
assert.deepStrictEqual(result, {
width: 1501,
height: 801,
});
} finally {
await browser.close();
}
});
});