diff --git a/CHANGELOG.md b/CHANGELOG.md index 3395c27d..81cceb16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - Upgrade Marp Core to [v4.0.0](https://github.com/marp-team/marp-core/releases/v4.0.0) ([#591](https://github.com/marp-team/marp-cli/pull/591)) - The slide container of built-in themes became the block element and adopted safe centering - Relax HTML allowlist: Allowed a lot of HTML elements and attributes by default +- Use [the new headless mode of Chrome](https://developer.chrome.com/docs/chromium/headless) while converting by default ([#593](https://github.com/marp-team/marp-cli/pull/593)) + - You can get back to the old headless mode by setting `PUPPETEER_HEADLESS_MODE=old` env. ### Added diff --git a/src/utils/puppeteer.ts b/src/utils/puppeteer.ts index 97b1ffaa..36f7dd05 100644 --- a/src/utils/puppeteer.ts +++ b/src/utils/puppeteer.ts @@ -15,7 +15,11 @@ let executablePath: string | undefined | false = false let wslTmp: string | undefined export const enableHeadless = (): 'shell' | true => - process.env.PUPPETEER_HEADLESS_MODE?.toLowerCase() === 'new' ? true : 'shell' + ['old', 'legacy', 'shell'].includes( + process.env.PUPPETEER_HEADLESS_MODE?.toLowerCase() ?? '' + ) + ? 'shell' + : true const isShebang = (path: string) => { let fd: number | null = null diff --git a/test/utils/puppeteer.ts b/test/utils/puppeteer.ts index e492a30e..72887178 100644 --- a/test/utils/puppeteer.ts +++ b/test/utils/puppeteer.ts @@ -201,14 +201,14 @@ describe('#generatePuppeteerLaunchArgs', () => { }) describe('with PUPPETEER_HEADLESS_MODE env', () => { - it('uses legacy headless mode if PUPPETEER_HEADLESS_MODE was empty', async () => { + it('uses headless mode if PUPPETEER_HEADLESS_MODE was empty', async () => { try { process.env.PUPPETEER_HEADLESS_MODE = '' const { headless } = await puppeteerUtils().generatePuppeteerLaunchArgs() - expect(headless).toBe('shell') + expect(headless).toBe(true) } finally { delete process.env.PUPPETEER_HEADLESS_MODE } @@ -252,6 +252,19 @@ describe('#generatePuppeteerLaunchArgs', () => { delete process.env.PUPPETEER_HEADLESS_MODE } }) + + it('uses legacy headless mode if PUPPETEER_HEADLESS_MODE was "shell"', async () => { + try { + process.env.PUPPETEER_HEADLESS_MODE = 'shell' + + const { headless } = + await puppeteerUtils().generatePuppeteerLaunchArgs() + + expect(headless).toBe('shell') + } finally { + delete process.env.PUPPETEER_HEADLESS_MODE + } + }) }) describe('with CHROME_PATH env in macOS', () => {