From 7a4170fe6e4ba1488fd27c98f2a6af089782bf57 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Fri, 19 Jun 2020 14:15:13 +0100 Subject: [PATCH] chore: remove top level errors and DeviceDescriptors (#6043) As far as I can tell these became irrelevant as of v1.15 which added `puppeteer.errors` and `puppeteer.devices [1]. This is a breaking change but one that's easily mitigated. We've said that we don't consider changes to our folder/file structure a breaking change, but we can't really do that if we have these two top level files that we've documented. [1]: https://github.com/puppeteer/puppeteer/commit/e3abb0aa32e38660abffad22d6446473be4b13cd#diff-522b24108d7446af4c59873472a90444 --- DeviceDescriptors.js | 17 ----------------- Errors.js | 17 ----------------- docs/api.md | 2 -- examples/screenshot-fullpage.js | 3 +-- package.json | 2 -- test/launcher.spec.js | 16 ---------------- 6 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 DeviceDescriptors.js delete mode 100644 Errors.js diff --git a/DeviceDescriptors.js b/DeviceDescriptors.js deleted file mode 100644 index 9b5345d4..00000000 --- a/DeviceDescriptors.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright 2019 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. - */ - -module.exports = require('./lib/common/DeviceDescriptors'); diff --git a/Errors.js b/Errors.js deleted file mode 100644 index e4bdabb1..00000000 --- a/Errors.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright 2018 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. - */ - -module.exports = require('./lib/common/Errors'); diff --git a/docs/api.md b/docs/api.md index c7860873..cb174248 100644 --- a/docs/api.md +++ b/docs/api.md @@ -514,8 +514,6 @@ const iPhone = puppeteer.devices['iPhone 6']; })(); ``` -> **NOTE** The old way (Puppeteer versions <= v1.14.0) devices can be obtained with `require('puppeteer/DeviceDescriptors')`. - #### puppeteer.errors - returns: <[Object]> - `TimeoutError` <[function]> A class of [TimeoutError]. diff --git a/examples/screenshot-fullpage.js b/examples/screenshot-fullpage.js index e6ca7657..8844cbcf 100644 --- a/examples/screenshot-fullpage.js +++ b/examples/screenshot-fullpage.js @@ -17,12 +17,11 @@ 'use strict'; const puppeteer = require('puppeteer'); -const devices = require('puppeteer/DeviceDescriptors'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); - await page.emulate(devices['iPhone 6']); + await page.emulate(puppeteer.devices['iPhone 6']); await page.goto('https://www.nytimes.com/'); await page.screenshot({ path: 'full.png', fullPage: true }); await browser.close(); diff --git a/package.json b/package.json index ba0d15db..ab58f3a4 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,6 @@ }, "files": [ "lib/", - "Errors.js", - "DeviceDescriptors.js", "index.js", "install.js", "typescript-if-required.js" diff --git a/test/launcher.spec.js b/test/launcher.spec.js index 7c031f5c..b20e0f52 100644 --- a/test/launcher.spec.js +++ b/test/launcher.spec.js @@ -592,22 +592,6 @@ describe('Launcher specs', function () { }); }); - describe('Top-level requires', function () { - it('should require top-level Errors', async () => { - const { puppeteer, puppeteerPath } = getTestState(); - const Errors = require(path.join(puppeteerPath, '/Errors')); - expect(Errors.TimeoutError).toBe(puppeteer.errors.TimeoutError); - }); - it('should require top-level DeviceDescriptors', async () => { - const { puppeteer, puppeteerPath } = getTestState(); - const { devicesMap } = require(path.join( - puppeteerPath, - '/DeviceDescriptors' - )); - expect(devicesMap['iPhone 6']).toBe(puppeteer.devices['iPhone 6']); - }); - }); - describe('Browser target events', function () { itFailsFirefox('should work', async () => { const { server, puppeteer, defaultBrowserOptions } = getTestState();