test: add installation test for BiDi (#11311)

This commit is contained in:
Nikolay Vitkov 2023-11-07 08:20:44 +01:00 committed by GitHub
parent 8a54722328
commit 08615f848c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 9 deletions

View File

@ -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();
})();

View File

@ -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');
});
});
}
);