From 08615f848c87ffa44bde0e0c2ecef07545ba4d39 Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Tue, 7 Nov 2023 08:20:44 +0100 Subject: [PATCH] test: add installation test for BiDi (#11311) --- test/installation/assets/puppeteer/bidi.js | 27 +++++++++++++++++++ .../src/puppeteer-firefox.spec.ts | 27 ++++++++++++------- 2 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 test/installation/assets/puppeteer/bidi.js diff --git a/test/installation/assets/puppeteer/bidi.js b/test/installation/assets/puppeteer/bidi.js new file mode 100644 index 00000000..e412a0f3 --- /dev/null +++ b/test/installation/assets/puppeteer/bidi.js @@ -0,0 +1,27 @@ +/** + * Copyright 2023 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import puppeteer from 'puppeteer'; +(async () => { + const browser = await puppeteer.launch({ + protocol: 'webDriverBiDi', + }); + const page = await browser.newPage(); + await page.goto('http://example.com'); + await page.$('h1'); + await page.screenshot({path: 'example.png'}); + await browser.close(); +})(); diff --git a/test/installation/src/puppeteer-firefox.spec.ts b/test/installation/src/puppeteer-firefox.spec.ts index 9c52911d..9f7720bd 100644 --- a/test/installation/src/puppeteer-firefox.spec.ts +++ b/test/installation/src/puppeteer-firefox.spec.ts @@ -36,17 +36,26 @@ import {readAsset} from './util.js'; }, }); - it('evaluates CommonJS', async function () { - const files = await readdir(join(this.sandbox, '.cache', 'puppeteer')); - assert.equal(files.length, 1); - assert.equal(files[0], 'firefox'); - const script = await readAsset('puppeteer-core', 'requires.cjs'); - await this.runScript(script, 'cjs'); + describe('with CDP', () => { + it('evaluates CommonJS', async function () { + const files = await readdir(join(this.sandbox, '.cache', 'puppeteer')); + assert.equal(files.length, 1); + assert.equal(files[0], 'firefox'); + const script = await readAsset('puppeteer-core', 'requires.cjs'); + await this.runScript(script, 'cjs'); + }); + + it('evaluates ES modules', async function () { + const script = await readAsset('puppeteer-core', 'imports.js'); + await this.runScript(script, 'mjs'); + }); }); - it('evaluates ES modules', async function () { - const script = await readAsset('puppeteer-core', 'imports.js'); - await this.runScript(script, 'mjs'); + describe('with WebDriverBiDi', () => { + it('evaluates ES modules', async function () { + const script = await readAsset('puppeteer', 'bidi.js'); + await this.runScript(script, 'mjs'); + }); }); } );