summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/test/src/launcher.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'remote/test/puppeteer/test/src/launcher.spec.ts')
-rw-r--r--remote/test/puppeteer/test/src/launcher.spec.ts62
1 files changed, 19 insertions, 43 deletions
diff --git a/remote/test/puppeteer/test/src/launcher.spec.ts b/remote/test/puppeteer/test/src/launcher.spec.ts
index f31b22b1e5..876f8d1624 100644
--- a/remote/test/puppeteer/test/src/launcher.spec.ts
+++ b/remote/test/puppeteer/test/src/launcher.spec.ts
@@ -16,7 +16,7 @@ import type {Page} from 'puppeteer-core/internal/api/Page.js';
import {rmSync} from 'puppeteer-core/internal/node/util/fs.js';
import sinon from 'sinon';
-import {getTestState, isHeadless, launch} from './mocha-utils.js';
+import {getTestState, launch} from './mocha-utils.js';
import {dumpFrames, waitEvent} from './utils.js';
const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
@@ -48,7 +48,10 @@ describe('Launcher specs', function () {
[
'Navigating frame was detached',
'Protocol error (Page.navigate): Target closed.',
- ].includes(error.message)
+ 'Protocol error (browsingContext.navigate): Target closed',
+ ].some(message => {
+ return error.message.startsWith(message);
+ })
).toBeTruthy();
} finally {
await close();
@@ -99,6 +102,7 @@ describe('Launcher specs', function () {
expect(message).atLeastOneToContain([
'Target closed',
'Page closed!',
+ 'Browser already closed',
]);
expect(message).not.toContain('Timeout');
}
@@ -363,9 +367,9 @@ describe('Launcher specs', function () {
if (isChrome) {
expect(puppeteer.defaultArgs()).toContain('--no-first-run');
- expect(puppeteer.defaultArgs()).toContain('--headless');
+ expect(puppeteer.defaultArgs()).toContain('--headless=new');
expect(puppeteer.defaultArgs({headless: false})).not.toContain(
- '--headless'
+ '--headless=new'
);
expect(puppeteer.defaultArgs({userDataDir: 'foo'})).toContain(
`--user-data-dir=${path.resolve('foo')}`
@@ -408,21 +412,18 @@ describe('Launcher specs', function () {
expect(puppeteer.product).toBe('firefox');
}
});
- (!isHeadless ? it : it.skip)(
- 'should work with no default arguments',
- async () => {
- const {context, close} = await launch({
- ignoreDefaultArgs: true,
- });
- try {
- const page = await context.newPage();
- expect(await page.evaluate('11 * 11')).toBe(121);
- await page.close();
- } finally {
- await close();
- }
+ it('should work with no default arguments', async () => {
+ const {context, close} = await launch({
+ ignoreDefaultArgs: true,
+ });
+ try {
+ const page = await context.newPage();
+ expect(await page.evaluate('11 * 11')).toBe(121);
+ await page.close();
+ } finally {
+ await close();
}
- );
+ });
it('should filter out ignored default arguments in Chrome', async () => {
const {defaultBrowserOptions, puppeteer} = await getTestState({
skipLaunch: true,
@@ -590,31 +591,6 @@ describe('Launcher specs', function () {
});
expect(error.message).toContain('either pipe or debugging port');
});
- (!isHeadless ? it : it.skip)(
- 'should launch Chrome properly with --no-startup-window and waitForInitialPage=false',
- async () => {
- const {defaultBrowserOptions} = await getTestState({
- skipLaunch: true,
- });
- const options = {
- waitForInitialPage: false,
- // This is needed to prevent Puppeteer from adding an initial blank page.
- // See also https://github.com/puppeteer/puppeteer/blob/ad6b736039436fcc5c0a262e5b575aa041427be3/src/node/Launcher.ts#L200
- ignoreDefaultArgs: true,
- ...defaultBrowserOptions,
- args: ['--no-startup-window'],
- };
- const {browser, close} = await launch(options, {
- createContext: false,
- });
- try {
- const pages = await browser.pages();
- expect(pages).toHaveLength(0);
- } finally {
- await close();
- }
- }
- );
});
describe('Puppeteer.launch', function () {