From 942a8f229a6464ce063e814af1745f41ef9afd3d Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Wed, 17 Jan 2018 00:16:57 +0100 Subject: [PATCH] feat(dependencies): update Google Puppeteer to v1.0.0 Google Puppeteer (API to drive headless chromium) v1.0.0 is now released. --- packages/ace-core/package.json | 2 +- packages/jest-env-puppeteer/package.json | 2 +- packages/puppeteer-utils/src/index.js | 24 ++++-------------------- yarn.lock | 6 +++--- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/packages/ace-core/package.json b/packages/ace-core/package.json index 0c9a5542..4b1cca76 100644 --- a/packages/ace-core/package.json +++ b/packages/ace-core/package.json @@ -24,7 +24,7 @@ "axe-core": "^2.5.0", "h5o": "^0.11.3", "p-map": "^1.2.0", - "puppeteer": "^0.12.0", + "puppeteer": "^1.0.0", "tmp": "^0.0.33", "winston": "^2.4.0" }, diff --git a/packages/jest-env-puppeteer/package.json b/packages/jest-env-puppeteer/package.json index 7bd7e695..913d919c 100644 --- a/packages/jest-env-puppeteer/package.json +++ b/packages/jest-env-puppeteer/package.json @@ -18,7 +18,7 @@ "main": "lib/index.js", "dependencies": { "jest-environment-node": "^21.3.0-beta.3", - "puppeteer": "^0.12.0" + "puppeteer": "^1.0.0" }, "publishConfig": { "access": "public" diff --git a/packages/puppeteer-utils/src/index.js b/packages/puppeteer-utils/src/index.js index 74927eec..02c551e4 100644 --- a/packages/puppeteer-utils/src/index.js +++ b/packages/puppeteer-utils/src/index.js @@ -1,30 +1,14 @@ 'use strict'; async function addScripts(paths, page) { - // BEGIN HACK - // Used to differentiate original `script` elements from the one - // added by Puppeteer. - // FIXME remove this hack when GoogleChrome/puppeteer#1179 is fixed - await page.$$eval('script', (scripts) => { - scripts.forEach(script => script.setAttribute('data-ace-orig', '')); - }); /* eslint-disable no-restricted-syntax, no-await-in-loop */ for (const path of paths) { - await page.addScriptTag({ path }); + const scriptElemHandle = await page.addScriptTag({ path }); + await page.evaluate((scriptElem) => { + scriptElem.setAttribute('data-ace', ''); + }, scriptElemHandle); } /* eslint-enable no-restricted-syntax, no-await-in-loop */ - // BEGIN HACK - // FIXME remove this hack when GoogleChrome/puppeteer#1179 is fixed - await page.$$eval('script', (scripts) => { - scripts.forEach((script) => { - if (script.hasAttribute('data-ace-orig')) { - script.removeAttribute('data-ace-orig'); - } else { - script.setAttribute('data-ace', ''); - } - }); - }); - // END HACK } module.exports = { diff --git a/yarn.lock b/yarn.lock index b6865cd7..a6ec5ae7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4491,9 +4491,9 @@ punycode@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d" -puppeteer@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-0.12.0.tgz#9c421930851594dfdd479d07646666a74ced7719" +puppeteer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-1.0.0.tgz#20f3bb6ad6c6778b4d1fb750e808a29fec0a88a4" dependencies: debug "^2.6.8" extract-zip "^1.6.5"