From 95cc079298c4fc0d884e1998ba0ebd2e48c2c59f Mon Sep 17 00:00:00 2001 From: "cypress-bot[bot]" <+cypress-bot[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 00:33:45 +0000 Subject: [PATCH] chore: updating v8 snapshot cache --- browser-versions.json | 4 +- packages/extension/app/{ => v2}/background.js | 2 +- packages/extension/app/{ => v2}/client.ts | 0 packages/extension/app/{ => v2}/init.js | 0 packages/extension/app/{ => v2}/manifest.json | 0 packages/extension/app/v3/manifest.json | 28 +++++++++++++ packages/extension/gulpfile.ts | 23 +++++++---- packages/extension/lib/extension.js | 6 ++- .../test/integration/background_spec.js | 4 +- .../extension/test/unit/extension_spec.js | 19 ++++++--- packages/extension/webpack.config.js | 4 +- packages/server/lib/browsers/chrome.ts | 7 +--- .../server/test/unit/browsers/chrome_spec.js | 39 ------------------- .../server/test/unit/browsers/firefox_spec.ts | 2 +- packages/server/test/unit/socket_spec.js | 2 +- 15 files changed, 72 insertions(+), 68 deletions(-) rename packages/extension/app/{ => v2}/background.js (99%) rename packages/extension/app/{ => v2}/client.ts (100%) rename packages/extension/app/{ => v2}/init.js (100%) rename packages/extension/app/{ => v2}/manifest.json (100%) create mode 100644 packages/extension/app/v3/manifest.json diff --git a/browser-versions.json b/browser-versions.json index a123031782e8..916a03abb5dd 100644 --- a/browser-versions.json +++ b/browser-versions.json @@ -1,5 +1,5 @@ { - "chrome:beta": "118.0.5993.11", - "chrome:stable": "117.0.5938.88", + "chrome:beta": "118.0.5993.21", + "chrome:stable": "117.0.5938.132", "chrome:minimum": "64.0.3282.0" } diff --git a/packages/extension/app/background.js b/packages/extension/app/v2/background.js similarity index 99% rename from packages/extension/app/background.js rename to packages/extension/app/v2/background.js index 0dc29693170e..e70d5729f6e5 100644 --- a/packages/extension/app/background.js +++ b/packages/extension/app/v2/background.js @@ -7,7 +7,7 @@ const browser = require('webextension-polyfill') const { cookieMatches } = require('@packages/server/lib/automation/util') const client = require('./client') -const util = require('../lib/util') +const util = require('../../lib/util') const COOKIE_PROPS = ['url', 'name', 'path', 'secure', 'domain'] const GET_ALL_PROPS = COOKIE_PROPS.concat(['session', 'storeId']) diff --git a/packages/extension/app/client.ts b/packages/extension/app/v2/client.ts similarity index 100% rename from packages/extension/app/client.ts rename to packages/extension/app/v2/client.ts diff --git a/packages/extension/app/init.js b/packages/extension/app/v2/init.js similarity index 100% rename from packages/extension/app/init.js rename to packages/extension/app/v2/init.js diff --git a/packages/extension/app/manifest.json b/packages/extension/app/v2/manifest.json similarity index 100% rename from packages/extension/app/manifest.json rename to packages/extension/app/v2/manifest.json diff --git a/packages/extension/app/v3/manifest.json b/packages/extension/app/v3/manifest.json new file mode 100644 index 000000000000..a7413a18da30 --- /dev/null +++ b/packages/extension/app/v3/manifest.json @@ -0,0 +1,28 @@ +{ + "name": "Cypress", + "description": "Adds Themes for testing with Cypress", + "applications": { + "gecko": { + "id": "automation-extension-v3@cypress.io" + } + }, + "permissions": [], + "icons": { + "16": "icons/icon_16x16.png", + "48": "icons/icon_48x48.png", + "128": "icons/icon_128x128.png" + }, + "browser_action": { + "default_title": "Cypress", + "default_icon": { + "19": "icons/icon_19x19.png", + "38": "icons/icon_38x38.png" + }, + "default_popup": "popup.html" + }, + "chrome_url_overrides": { + "newtab": "newtab.html" + }, + "manifest_version": 3, + "version": "0.0.0" +} diff --git a/packages/extension/gulpfile.ts b/packages/extension/gulpfile.ts index 00fd4b9ae89d..874de8ebdbe0 100644 --- a/packages/extension/gulpfile.ts +++ b/packages/extension/gulpfile.ts @@ -16,9 +16,11 @@ const clean = (done) => { rimraf('dist', done) } -const manifest = () => { - return gulp.src('app/manifest.json') - .pipe(gulp.dest('dist')) +const manifest = (v: 'v2' | 'v3') => { + return () => { + return gulp.src(`app/${v}/manifest.json`) + .pipe(gulp.dest(`dist/${v}`)) + } } const background = (cb) => { @@ -29,12 +31,14 @@ const background = (cb) => { const html = () => { return gulp.src('app/**/*.html') - .pipe(gulp.dest('dist')) + .pipe(gulp.dest('dist/v2')) + .pipe(gulp.dest('dist/v3')) } const css = () => { return gulp.src('app/**/*.css') - .pipe(gulp.dest('dist')) + .pipe(gulp.dest('dist/v2')) + .pipe(gulp.dest('dist/v3')) } const icons = async () => { @@ -47,7 +51,8 @@ const icons = async () => { cyIcons.getPathToIcon('icon_48x48.png'), cyIcons.getPathToIcon('icon_128x128.png'), ]) - .pipe(gulp.dest('dist/icons')) + .pipe(gulp.dest('dist/v2/icons')) + .pipe(gulp.dest('dist/v3/icons')) } const logos = async () => { @@ -57,7 +62,8 @@ const logos = async () => { return gulp.src([ cyIcons.getPathToLogo('cypress-bw.png'), ]) - .pipe(gulp.dest('dist/logos')) + .pipe(gulp.dest('dist/v2/logos')) + .pipe(gulp.dest('dist/v3/logos')) } const build = gulp.series( @@ -65,7 +71,8 @@ const build = gulp.series( gulp.parallel( icons, logos, - manifest, + manifest('v2'), + manifest('v3'), background, html, css, diff --git a/packages/extension/lib/extension.js b/packages/extension/lib/extension.js index 297bf0bda0d5..75612fe7908f 100644 --- a/packages/extension/lib/extension.js +++ b/packages/extension/lib/extension.js @@ -5,11 +5,15 @@ const fs = Promise.promisifyAll(require('fs')) module.exports = { getPathToExtension (...args) { - args = [__dirname, '..', 'dist'].concat(args) + args = [__dirname, '..', 'dist', 'v2'].concat(args) return path.join.apply(path, args) }, + getPathToV3Extension (...args) { + return path.join(...[__dirname, '..', 'dist', 'v3', ...args]) + }, + getPathToTheme () { return path.join(__dirname, '..', 'theme') }, diff --git a/packages/extension/test/integration/background_spec.js b/packages/extension/test/integration/background_spec.js index 0bb6f3555da4..b0d4617a275b 100644 --- a/packages/extension/test/integration/background_spec.js +++ b/packages/extension/test/integration/background_spec.js @@ -4,7 +4,7 @@ const http = require('http') const socket = require('@packages/socket') const Promise = require('bluebird') const mockRequire = require('mock-require') -const client = require('../../app/client') +const client = require('../../app/v2/client') const browser = { cookies: { @@ -48,7 +48,7 @@ const browser = { mockRequire('webextension-polyfill', browser) -const background = require('../../app/background') +const background = require('../../app/v2/background') const { expect } = require('chai') const PORT = 12345 diff --git a/packages/extension/test/unit/extension_spec.js b/packages/extension/test/unit/extension_spec.js index 86bf514c7973..3f3d518f1ce9 100644 --- a/packages/extension/test/unit/extension_spec.js +++ b/packages/extension/test/unit/extension_spec.js @@ -26,16 +26,25 @@ describe('Extension', () => { }) context('.getPathToExtension', () => { - it('returns path to dist', () => { + it('returns path to dist/v2', () => { const result = extension.getPathToExtension() - const expected = path.join(cwd, 'dist') + const expected = path.join(cwd, 'dist', 'v2') expect(path.normalize(result)).to.eq(path.normalize(expected)) }) - it('returns path to files in dist', () => { + it('returns path to files in dist/v2', () => { const result = extension.getPathToExtension('background.js') - const expected = path.join(cwd, '/dist/background.js') + const expected = path.join(cwd, '/dist/v2/background.js') + + expect(path.normalize(result)).to.eq(path.normalize(expected)) + }) + }) + + context('.getPathToV3Extension', () => { + it('returns path to dist/v3', () => { + const result = extension.getPathToV3Extension() + const expected = path.join(cwd, 'dist', 'v3') expect(path.normalize(result)).to.eq(path.normalize(expected)) }) @@ -113,7 +122,7 @@ describe('Extension', () => { context('manifest', () => { it('has a key that resolves to the static extension ID', () => { - return fs.readJsonAsync(path.join(cwd, 'app/manifest.json')) + return fs.readJsonAsync(path.join(cwd, 'app/v2/manifest.json')) .then((manifest) => { const cmd = `echo \"${manifest.key}\" | openssl base64 -d -A | shasum -a 256 | head -c32 | tr 0-9a-f a-p` diff --git a/packages/extension/webpack.config.js b/packages/extension/webpack.config.js index 75317bcf2d06..7dc314f78ed4 100644 --- a/packages/extension/webpack.config.js +++ b/packages/extension/webpack.config.js @@ -3,7 +3,7 @@ const webpack = require('webpack') module.exports = { mode: process.env.NODE_ENV || 'development', - entry: './app/init.js', + entry: './app/v2/init.js', // https://github.com/cypress-io/cypress/issues/15032 // Default webpack output setting is "eval". // Chrome doesn't allow "eval" inside extensions. @@ -22,7 +22,7 @@ module.exports = { }, output: { filename: 'background.js', - path: path.resolve(__dirname, 'dist'), + path: path.resolve(__dirname, 'dist', 'v2'), }, plugins: [ new webpack.DefinePlugin({ diff --git a/packages/server/lib/browsers/chrome.ts b/packages/server/lib/browsers/chrome.ts index 5b0424ebc352..e3a11b10067c 100644 --- a/packages/server/lib/browsers/chrome.ts +++ b/packages/server/lib/browsers/chrome.ts @@ -44,7 +44,7 @@ type ChromePreferences = { localState: object } -const pathToExtension = extension.getPathToExtension() +const pathToExtension = extension.getPathToV3Extension() const pathToTheme = extension.getPathToTheme() // Common Chrome Flags for Automation @@ -357,15 +357,10 @@ export = { return } - // get the string bytes for the final extension file - const str = await extension.setHostAndPath(options.proxyUrl, options.socketIoRoute) const extensionDest = utils.getExtensionDir(browser, options.isTextTerminal) - const extensionBg = path.join(extensionDest, 'background.js') // copy the extension src to the extension dist await utils.copyExtension(pathToExtension, extensionDest) - await fs.chmod(extensionBg, 0o0644) - await fs.writeFileAsync(extensionBg, str) return extensionDest }, diff --git a/packages/server/test/unit/browsers/chrome_spec.js b/packages/server/test/unit/browsers/chrome_spec.js index 3114ea33fc93..4aa4aeef440b 100644 --- a/packages/server/test/unit/browsers/chrome_spec.js +++ b/packages/server/test/unit/browsers/chrome_spec.js @@ -2,8 +2,6 @@ require('../../spec_helper') const os = require('os') const mockfs = require('mock-fs') -const path = require('path') -const _ = require('lodash') const extension = require('@packages/extension') const launch = require('@packages/launcher/lib/browsers') @@ -258,43 +256,6 @@ describe('lib/browsers/chrome', () => { }) }) - it('install extension and ensure write access', function () { - mockfs({ - [path.resolve(`${__dirname }../../../../../extension/dist`)]: { - 'background.js': mockfs.file({ - mode: 0o0444, - }), - }, - }) - - const getFile = function (path) { - return _.reduce(_.compact(_.split(path, '/')), (acc, item) => { - return acc.getItem(item) - }, mockfs.getMockRoot()) - } - - chrome._writeExtension.restore() - utils.getProfileDir.restore() - - const profilePath = '/home/foo/snap/chromium/current' - const fullPath = `${profilePath}/Cypress/chromium-stable/interactive` - - this.readJson.withArgs(`${fullPath}/Default/Preferences`).rejects({ code: 'ENOENT' }) - this.readJson.withArgs(`${fullPath}/Default/Secure Preferences`).rejects({ code: 'ENOENT' }) - this.readJson.withArgs(`${fullPath}/Local State`).rejects({ code: 'ENOENT' }) - - return chrome.open({ - isHeadless: false, - isHeaded: false, - profilePath, - name: 'chromium', - channel: 'stable', - }, 'http://', openOpts, this.automation) - .then(() => { - expect((getFile(fullPath).getMode()) & 0o0700).to.be.above(0o0500) - }) - }) - it('cleans up an unclean browser profile exit status', function () { this.readJson.withArgs('/profile/dir/Default/Preferences').resolves({ profile: { diff --git a/packages/server/test/unit/browsers/firefox_spec.ts b/packages/server/test/unit/browsers/firefox_spec.ts index 936865e654e4..069573ea399a 100644 --- a/packages/server/test/unit/browsers/firefox_spec.ts +++ b/packages/server/test/unit/browsers/firefox_spec.ts @@ -251,7 +251,7 @@ describe('lib/browsers/firefox', () => { } mockfs({ - [path.resolve(`${__dirname }../../../../../extension/dist`)]: { + [path.resolve(`${__dirname }../../../../../extension/dist/v2`)]: { 'background.js': mockfs.file({ mode: 0o444, }), diff --git a/packages/server/test/unit/socket_spec.js b/packages/server/test/unit/socket_spec.js index d5b7cb1c98c9..62a1a15a99f1 100644 --- a/packages/server/test/unit/socket_spec.js +++ b/packages/server/test/unit/socket_spec.js @@ -157,7 +157,7 @@ describe('lib/socket', () => { }, } - extensionBackgroundPage = require('@packages/extension/app/background') + extensionBackgroundPage = require('@packages/extension/app/v2/background') }) beforeEach(function (done) {