chore: cleanup eslint suppressions (#38417)
* chore: cleanup eslint suppressions * address feedback * revert script/lib/azput.js * revert spec/fixtures/apps/remote-control/main.js * address feedback * revert typings/internal-ambient.d.ts
This commit is contained in:
parent
1c075e5ea0
commit
82af000a37
34 changed files with 76 additions and 115 deletions
|
@ -574,7 +574,6 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const { readFile: readFilePromise } = fs.promises;
|
const { readFile: readFilePromise } = fs.promises;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
fs.promises.readFile = function (pathArgument: string, options: any) {
|
fs.promises.readFile = function (pathArgument: string, options: any) {
|
||||||
const pathInfo = splitPath(pathArgument);
|
const pathInfo = splitPath(pathArgument);
|
||||||
if (!pathInfo.isAsar) {
|
if (!pathInfo.isAsar) {
|
||||||
|
|
|
@ -24,8 +24,6 @@ const spawnUpdate = function (args: string[], detached: boolean, callback: Funct
|
||||||
// Process spawned, different args: Return with error
|
// Process spawned, different args: Return with error
|
||||||
// No process spawned: Spawn new process
|
// No process spawned: Spawn new process
|
||||||
if (spawnedProcess && !isSameArgs(args)) {
|
if (spawnedProcess && !isSameArgs(args)) {
|
||||||
// Disabled for backwards compatibility:
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
return callback(`AutoUpdater process with arguments ${args} is already running`);
|
return callback(`AutoUpdater process with arguments ${args} is already running`);
|
||||||
} else if (!spawnedProcess) {
|
} else if (!spawnedProcess) {
|
||||||
spawnedProcess = spawn(updateExe, args, {
|
spawnedProcess = spawn(updateExe, args, {
|
||||||
|
@ -66,8 +64,6 @@ const spawnUpdate = function (args: string[], detached: boolean, callback: Funct
|
||||||
|
|
||||||
// Process terminated with error.
|
// Process terminated with error.
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
// Disabled for backwards compatibility:
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
return callback(`Command failed: ${signal ?? code}\n${stderr}`);
|
return callback(`Command failed: ${signal ?? code}\n${stderr}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +89,6 @@ export function checkForUpdate (updateURL: string, callback: (error: Error | nul
|
||||||
const json = stdout.trim().split('\n').pop();
|
const json = stdout.trim().split('\n').pop();
|
||||||
update = (ref = JSON.parse(json!)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === 'function' ? ref1.pop() : undefined : undefined : undefined;
|
update = (ref = JSON.parse(json!)) != null ? (ref1 = ref.releasesToApply) != null ? typeof ref1.pop === 'function' ? ref1.pop() : undefined : undefined : undefined;
|
||||||
} catch {
|
} catch {
|
||||||
// Disabled for backwards compatibility:
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
return callback(new Error(`Invalid result:\n${stdout}`));
|
return callback(new Error(`Invalid result:\n${stdout}`));
|
||||||
}
|
}
|
||||||
return callback(null, update);
|
return callback(null, update);
|
||||||
|
|
|
@ -237,8 +237,6 @@ const messageBox = (sync: boolean, window: BrowserWindow | null, options?: Messa
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// eat dirt, eslint
|
|
||||||
/* eslint-disable import/export */
|
|
||||||
export function showOpenDialog(window: BrowserWindow, options: OpenDialogOptions): OpenDialogReturnValue;
|
export function showOpenDialog(window: BrowserWindow, options: OpenDialogOptions): OpenDialogReturnValue;
|
||||||
export function showOpenDialog(options: OpenDialogOptions): OpenDialogReturnValue;
|
export function showOpenDialog(options: OpenDialogOptions): OpenDialogReturnValue;
|
||||||
export function showOpenDialog (windowOrOptions: BrowserWindow | OpenDialogOptions, maybeOptions?: OpenDialogOptions): OpenDialogReturnValue {
|
export function showOpenDialog (windowOrOptions: BrowserWindow | OpenDialogOptions, maybeOptions?: OpenDialogOptions): OpenDialogReturnValue {
|
||||||
|
|
|
@ -14,8 +14,8 @@ import * as deprecate from '@electron/internal/common/deprecate';
|
||||||
|
|
||||||
// session is not used here, the purpose is to make sure session is initialized
|
// session is not used here, the purpose is to make sure session is initialized
|
||||||
// before the webContents module.
|
// before the webContents module.
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line no-unused-expressions
|
||||||
session
|
session;
|
||||||
|
|
||||||
const webFrameMainBinding = process._linkedBinding('electron_browser_web_frame_main');
|
const webFrameMainBinding = process._linkedBinding('electron_browser_web_frame_main');
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,6 @@ const createGuest = function (embedder: Electron.WebContents, embedderFrameId: n
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
const guest = (webContents as typeof ElectronInternal.WebContents).create({
|
const guest = (webContents as typeof ElectronInternal.WebContents).create({
|
||||||
...webPreferences,
|
...webPreferences,
|
||||||
type: 'webview',
|
type: 'webview',
|
||||||
|
|
|
@ -81,7 +81,8 @@ export function event (emitter: NodeJS.EventEmitter, oldName: string, newName: s
|
||||||
// remove a property with no replacement
|
// remove a property with no replacement
|
||||||
export function removeProperty<T, K extends (keyof T & string)>(object: T, removedName: K, onlyForValues?: any[]): T {
|
export function removeProperty<T, K extends (keyof T & string)>(object: T, removedName: K, onlyForValues?: any[]): T {
|
||||||
// if the property's already been removed, warn about it
|
// if the property's already been removed, warn about it
|
||||||
const info = Object.getOwnPropertyDescriptor((object as any).__proto__, removedName) // eslint-disable-line
|
// eslint-disable-next-line no-proto
|
||||||
|
const info = Object.getOwnPropertyDescriptor((object as any).__proto__, removedName);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
log(`Unable to remove property '${removedName}' from an object that lacks it.`);
|
log(`Unable to remove property '${removedName}' from an object that lacks it.`);
|
||||||
return object;
|
return object;
|
||||||
|
|
|
@ -57,7 +57,7 @@ require('@electron/internal/renderer/common-init');
|
||||||
|
|
||||||
if (nodeIntegration) {
|
if (nodeIntegration) {
|
||||||
// Export node bindings to global.
|
// Export node bindings to global.
|
||||||
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers') // eslint-disable-line
|
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers');
|
||||||
global.module = new Module('electron/js2c/renderer_init');
|
global.module = new Module('electron/js2c/renderer_init');
|
||||||
global.require = makeRequireFunction(global.module);
|
global.require = makeRequireFunction(global.module);
|
||||||
|
|
||||||
|
|
|
@ -86,9 +86,7 @@ const defineWebViewElement = (hooks: WebViewImplHooks) => {
|
||||||
|
|
||||||
// Register <webview> custom element.
|
// Register <webview> custom element.
|
||||||
const registerWebViewElement = (hooks: WebViewImplHooks) => {
|
const registerWebViewElement = (hooks: WebViewImplHooks) => {
|
||||||
// I wish eslint wasn't so stupid, but it is
|
const WebViewElement = defineWebViewElement(hooks) as unknown as typeof ElectronInternal.WebViewElement;
|
||||||
// eslint-disable-next-line
|
|
||||||
const WebViewElement = defineWebViewElement(hooks) as unknown as typeof ElectronInternal.WebViewElement
|
|
||||||
|
|
||||||
setupMethods(WebViewElement, hooks);
|
setupMethods(WebViewElement, hooks);
|
||||||
|
|
||||||
|
|
|
@ -197,8 +197,6 @@ export class WebViewImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// I wish eslint wasn't so stupid, but it is
|
|
||||||
// eslint-disable-next-line
|
|
||||||
export const setupMethods = (WebViewElement: typeof ElectronInternal.WebViewElement, hooks: WebViewImplHooks) => {
|
export const setupMethods = (WebViewElement: typeof ElectronInternal.WebViewElement, hooks: WebViewImplHooks) => {
|
||||||
// Focusing the webview should move page focus to the underlying iframe.
|
// Focusing the webview should move page focus to the underlying iframe.
|
||||||
WebViewElement.prototype.focus = function () {
|
WebViewElement.prototype.focus = function () {
|
||||||
|
|
|
@ -16,7 +16,7 @@ require('@electron/internal/common/init');
|
||||||
const { hasSwitch, getSwitchValue } = process._linkedBinding('electron_common_command_line');
|
const { hasSwitch, getSwitchValue } = process._linkedBinding('electron_common_command_line');
|
||||||
|
|
||||||
// Export node bindings to global.
|
// Export node bindings to global.
|
||||||
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers') // eslint-disable-line
|
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers');
|
||||||
global.module = new Module('electron/js2c/worker_init');
|
global.module = new Module('electron/js2c/worker_init');
|
||||||
global.require = makeRequireFunction(global.module);
|
global.require = makeRequireFunction(global.module);
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,8 @@ describe('BrowserView module', () => {
|
||||||
const rc = await startRemoteControlApp();
|
const rc = await startRemoteControlApp();
|
||||||
await rc.remotely(() => {
|
await rc.remotely(() => {
|
||||||
const { BrowserView, app } = require('electron');
|
const { BrowserView, app } = require('electron');
|
||||||
new BrowserView({}) // eslint-disable-line
|
// eslint-disable-next-line no-new
|
||||||
|
new BrowserView({});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
|
@ -84,7 +84,6 @@ describe('BrowserWindow module', () => {
|
||||||
it('window does not get garbage collected when opened', async () => {
|
it('window does not get garbage collected when opened', async () => {
|
||||||
const w = new BrowserWindow({ show: false });
|
const w = new BrowserWindow({ show: false });
|
||||||
// Keep a weak reference to the window.
|
// Keep a weak reference to the window.
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
const wr = new WeakRef(w);
|
const wr = new WeakRef(w);
|
||||||
await setTimeout();
|
await setTimeout();
|
||||||
// Do garbage collection, since |w| is not referenced in this closure
|
// Do garbage collection, since |w| is not referenced in this closure
|
||||||
|
@ -3158,15 +3157,15 @@ describe('BrowserWindow module', () => {
|
||||||
afterEach(closeAllWindows);
|
afterEach(closeAllWindows);
|
||||||
it('can be set on a window', () => {
|
it('can be set on a window', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
/* eslint-disable no-new */
|
/* eslint-disable-next-line no-new */
|
||||||
new BrowserWindow({
|
new BrowserWindow({
|
||||||
tabbingIdentifier: 'group1'
|
tabbingIdentifier: 'group1'
|
||||||
});
|
});
|
||||||
|
/* eslint-disable-next-line no-new */
|
||||||
new BrowserWindow({
|
new BrowserWindow({
|
||||||
tabbingIdentifier: 'group2',
|
tabbingIdentifier: 'group2',
|
||||||
frame: false
|
frame: false
|
||||||
});
|
});
|
||||||
/* eslint-enable no-new */
|
|
||||||
}).not.to.throw();
|
}).not.to.throw();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -113,8 +113,7 @@ describe('ipc module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws an error in the renderer if the reply callback is dropped', async () => {
|
it('throws an error in the renderer if the reply callback is dropped', async () => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
ipcMain.handleOnce('test', () => new Promise(() => {
|
||||||
ipcMain.handleOnce('test', () => new Promise(resolve => {
|
|
||||||
setTimeout(() => v8Util.requestGarbageCollectionForTesting());
|
setTimeout(() => v8Util.requestGarbageCollectionForTesting());
|
||||||
/* never resolve */
|
/* never resolve */
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -859,7 +859,6 @@ describe('Menu module', function () {
|
||||||
menu.popup({ window: w });
|
menu.popup({ window: w });
|
||||||
|
|
||||||
// Keep a weak reference to the menu.
|
// Keep a weak reference to the menu.
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
const wr = new WeakRef(menu);
|
const wr = new WeakRef(menu);
|
||||||
|
|
||||||
await setTimeout();
|
await setTimeout();
|
||||||
|
|
|
@ -1336,8 +1336,6 @@ describe('net module', () => {
|
||||||
(details, callback) => {
|
(details, callback) => {
|
||||||
if (details.url === `${serverUrl}${requestUrl}`) {
|
if (details.url === `${serverUrl}${requestUrl}`) {
|
||||||
requestIsIntercepted = true;
|
requestIsIntercepted = true;
|
||||||
// Disabled due to false positive in StandardJS
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
callback({
|
callback({
|
||||||
redirectURL: `${serverUrl}${redirectUrl}`
|
redirectURL: `${serverUrl}${redirectUrl}`
|
||||||
});
|
});
|
||||||
|
@ -1375,8 +1373,6 @@ describe('net module', () => {
|
||||||
customSession.webRequest.onBeforeRequest((details, callback) => {
|
customSession.webRequest.onBeforeRequest((details, callback) => {
|
||||||
if (details.url === `${serverUrl}${requestUrl}`) {
|
if (details.url === `${serverUrl}${requestUrl}`) {
|
||||||
requestIsIntercepted = true;
|
requestIsIntercepted = true;
|
||||||
// Disabled due to false positive in StandardJS
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
callback({
|
callback({
|
||||||
redirectURL: `${serverUrl}${redirectUrl}`
|
redirectURL: `${serverUrl}${redirectUrl}`
|
||||||
});
|
});
|
||||||
|
@ -1416,8 +1412,6 @@ describe('net module', () => {
|
||||||
customSession.webRequest.onBeforeRequest((details, callback) => {
|
customSession.webRequest.onBeforeRequest((details, callback) => {
|
||||||
if (details.url === `${serverUrl}${requestUrl}`) {
|
if (details.url === `${serverUrl}${requestUrl}`) {
|
||||||
requestIsIntercepted = true;
|
requestIsIntercepted = true;
|
||||||
// Disabled due to false positive in StandardJS
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
callback({
|
callback({
|
||||||
redirectURL: `${serverUrl}${redirectUrl}`
|
redirectURL: `${serverUrl}${redirectUrl}`
|
||||||
});
|
});
|
||||||
|
|
|
@ -141,7 +141,6 @@ describe('powerMonitor', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when powerMonitor module is loaded', () => {
|
describe('when powerMonitor module is loaded', () => {
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
let powerMonitor: typeof Electron.powerMonitor;
|
let powerMonitor: typeof Electron.powerMonitor;
|
||||||
before(() => {
|
before(() => {
|
||||||
powerMonitor = require('electron').powerMonitor;
|
powerMonitor = require('electron').powerMonitor;
|
||||||
|
|
|
@ -12,9 +12,6 @@ import { defer, listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'timers/promises';
|
||||||
|
|
||||||
/* The whole session API doesn't use standard callbacks */
|
|
||||||
/* eslint-disable standard/no-callback-literal */
|
|
||||||
|
|
||||||
describe('session module', () => {
|
describe('session module', () => {
|
||||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||||
const url = 'http://127.0.0.1';
|
const url = 'http://127.0.0.1';
|
||||||
|
|
|
@ -13,41 +13,33 @@ describe('utilityProcess module', () => {
|
||||||
describe('UtilityProcess constructor', () => {
|
describe('UtilityProcess constructor', () => {
|
||||||
it('throws when empty script path is provided', async () => {
|
it('throws when empty script path is provided', async () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
/* eslint-disable no-new */
|
|
||||||
utilityProcess.fork('');
|
utilityProcess.fork('');
|
||||||
/* eslint-disable no-new */
|
|
||||||
}).to.throw();
|
}).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when options.stdio is not valid', async () => {
|
it('throws when options.stdio is not valid', async () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
/* eslint-disable no-new */
|
|
||||||
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
|
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
|
||||||
execArgv: ['--test', '--test2'],
|
execArgv: ['--test', '--test2'],
|
||||||
serviceName: 'test',
|
serviceName: 'test',
|
||||||
stdio: 'ipc'
|
stdio: 'ipc'
|
||||||
});
|
});
|
||||||
/* eslint-disable no-new */
|
|
||||||
}).to.throw(/stdio must be of the following values: inherit, pipe, ignore/);
|
}).to.throw(/stdio must be of the following values: inherit, pipe, ignore/);
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
/* eslint-disable no-new */
|
|
||||||
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
|
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
|
||||||
execArgv: ['--test', '--test2'],
|
execArgv: ['--test', '--test2'],
|
||||||
serviceName: 'test',
|
serviceName: 'test',
|
||||||
stdio: ['ignore', 'ignore']
|
stdio: ['ignore', 'ignore']
|
||||||
});
|
});
|
||||||
/* eslint-disable no-new */
|
|
||||||
}).to.throw(/configuration missing for stdin, stdout or stderr/);
|
}).to.throw(/configuration missing for stdin, stdout or stderr/);
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
/* eslint-disable no-new */
|
|
||||||
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
|
utilityProcess.fork(path.join(fixturesPath, 'empty.js'), [], {
|
||||||
execArgv: ['--test', '--test2'],
|
execArgv: ['--test', '--test2'],
|
||||||
serviceName: 'test',
|
serviceName: 'test',
|
||||||
stdio: ['pipe', 'inherit', 'inherit']
|
stdio: ['pipe', 'inherit', 'inherit']
|
||||||
});
|
});
|
||||||
/* eslint-disable no-new */
|
|
||||||
}).to.throw(/stdin value other than ignore is not supported/);
|
}).to.throw(/stdin value other than ignore is not supported/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1111,29 +1111,25 @@ describe('asar package', function () {
|
||||||
describe('fs.exists', function () {
|
describe('fs.exists', function () {
|
||||||
itremote('handles an existing file', async function () {
|
itremote('handles an existing file', async function () {
|
||||||
const p = path.join(asarDir, 'a.asar', 'file1');
|
const p = path.join(asarDir, 'a.asar', 'file1');
|
||||||
// eslint-disable-next-line
|
const exists = await new Promise(resolve => fs.exists(p, resolve));
|
||||||
const exists = await new Promise(resolve => fs.exists(p, resolve))
|
|
||||||
expect(exists).to.be.true();
|
expect(exists).to.be.true();
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('handles a non-existent file', async function () {
|
itremote('handles a non-existent file', async function () {
|
||||||
const p = path.join(asarDir, 'a.asar', 'not-exist');
|
const p = path.join(asarDir, 'a.asar', 'not-exist');
|
||||||
// eslint-disable-next-line
|
const exists = await new Promise(resolve => fs.exists(p, resolve));
|
||||||
const exists = await new Promise(resolve => fs.exists(p, resolve))
|
|
||||||
expect(exists).to.be.false();
|
expect(exists).to.be.false();
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('promisified version handles an existing file', async () => {
|
itremote('promisified version handles an existing file', async () => {
|
||||||
const p = path.join(asarDir, 'a.asar', 'file1');
|
const p = path.join(asarDir, 'a.asar', 'file1');
|
||||||
// eslint-disable-next-line
|
const exists = await require('util').promisify(fs.exists)(p);
|
||||||
const exists = await require('util').promisify(fs.exists)(p)
|
|
||||||
expect(exists).to.be.true();
|
expect(exists).to.be.true();
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('promisified version handles a non-existent file', async function () {
|
itremote('promisified version handles a non-existent file', async function () {
|
||||||
const p = path.join(asarDir, 'a.asar', 'not-exist');
|
const p = path.join(asarDir, 'a.asar', 'not-exist');
|
||||||
// eslint-disable-next-line
|
const exists = await require('util').promisify(fs.exists)(p);
|
||||||
const exists = await require('util').promisify(fs.exists)(p)
|
|
||||||
expect(exists).to.be.false();
|
expect(exists).to.be.false();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
nonExistingFunc(); // eslint-disable-line
|
nonExistingFunc(); // eslint-disable-line no-undef
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const { WebContentsView, app } = require('electron');
|
const { WebContentsView, app } = require('electron');
|
||||||
app.whenReady().then(function () {
|
app.whenReady().then(function () {
|
||||||
new WebContentsView({}) // eslint-disable-line
|
// eslint-disable-next-line no-new
|
||||||
|
new WebContentsView({});
|
||||||
|
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* global registerPaint */
|
||||||
|
|
||||||
class CheckerboardPainter {
|
class CheckerboardPainter {
|
||||||
paint (ctx, geom, properties) {
|
paint (ctx, geom, properties) {
|
||||||
const colors = ['red', 'green', 'blue'];
|
const colors = ['red', 'green', 'blue'];
|
||||||
|
@ -14,5 +16,4 @@ class CheckerboardPainter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
registerPaint('checkerboard', CheckerboardPainter);
|
registerPaint('checkerboard', CheckerboardPainter);
|
||||||
|
|
36
spec/fixtures/extensions/chrome-i18n/main.js
vendored
36
spec/fixtures/extensions/chrome-i18n/main.js
vendored
|
@ -1,33 +1,33 @@
|
||||||
/* eslint-disable */
|
/* global chrome */
|
||||||
|
|
||||||
function evalInMainWorld(fn) {
|
function evalInMainWorld (fn) {
|
||||||
const script = document.createElement('script')
|
const script = document.createElement('script');
|
||||||
script.textContent = `((${fn})())`
|
script.textContent = `((${fn})())`;
|
||||||
document.documentElement.appendChild(script)
|
document.documentElement.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function exec(name) {
|
async function exec (name) {
|
||||||
let result
|
let result;
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'getMessage':
|
case 'getMessage':
|
||||||
result = {
|
result = {
|
||||||
id: chrome.i18n.getMessage('@@extension_id'),
|
id: chrome.i18n.getMessage('@@extension_id'),
|
||||||
name: chrome.i18n.getMessage('extName'),
|
name: chrome.i18n.getMessage('extName')
|
||||||
}
|
};
|
||||||
break
|
break;
|
||||||
case 'getAcceptLanguages':
|
case 'getAcceptLanguages':
|
||||||
result = await new Promise(resolve => chrome.i18n.getAcceptLanguages(resolve))
|
result = await new Promise(resolve => chrome.i18n.getAcceptLanguages(resolve));
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const funcStr = `() => { require('electron').ipcRenderer.send('success', ${JSON.stringify(result)}) }`
|
const funcStr = `() => { require('electron').ipcRenderer.send('success', ${JSON.stringify(result)}) }`;
|
||||||
evalInMainWorld(funcStr)
|
evalInMainWorld(funcStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('message', event => {
|
window.addEventListener('message', event => {
|
||||||
exec(event.data.name)
|
exec(event.data.name);
|
||||||
})
|
});
|
||||||
|
|
||||||
evalInMainWorld(() => {
|
evalInMainWorld(() => {
|
||||||
window.exec = name => window.postMessage({ name })
|
window.exec = name => window.postMessage({ name });
|
||||||
})
|
});
|
||||||
|
|
44
spec/fixtures/extensions/chrome-runtime/main.js
vendored
44
spec/fixtures/extensions/chrome-runtime/main.js
vendored
|
@ -1,39 +1,39 @@
|
||||||
/* eslint-disable */
|
/* global chrome */
|
||||||
|
|
||||||
function evalInMainWorld(fn) {
|
function evalInMainWorld (fn) {
|
||||||
const script = document.createElement('script')
|
const script = document.createElement('script');
|
||||||
script.textContent = `((${fn})())`
|
script.textContent = `((${fn})())`;
|
||||||
document.documentElement.appendChild(script)
|
document.documentElement.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function exec(name) {
|
async function exec (name) {
|
||||||
let result
|
let result;
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'getManifest':
|
case 'getManifest':
|
||||||
result = chrome.runtime.getManifest()
|
result = chrome.runtime.getManifest();
|
||||||
break
|
break;
|
||||||
case 'id':
|
case 'id':
|
||||||
result = chrome.runtime.id
|
result = chrome.runtime.id;
|
||||||
break
|
break;
|
||||||
case 'getURL':
|
case 'getURL':
|
||||||
result = chrome.runtime.getURL('main.js')
|
result = chrome.runtime.getURL('main.js');
|
||||||
break
|
break;
|
||||||
case 'getPlatformInfo': {
|
case 'getPlatformInfo': {
|
||||||
result = await new Promise(resolve => {
|
result = await new Promise(resolve => {
|
||||||
chrome.runtime.sendMessage(name, resolve)
|
chrome.runtime.sendMessage(name, resolve);
|
||||||
})
|
});
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const funcStr = `() => { require('electron').ipcRenderer.send('success', ${JSON.stringify(result)}) }`
|
const funcStr = `() => { require('electron').ipcRenderer.send('success', ${JSON.stringify(result)}) }`;
|
||||||
evalInMainWorld(funcStr)
|
evalInMainWorld(funcStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('message', event => {
|
window.addEventListener('message', event => {
|
||||||
exec(event.data.name)
|
exec(event.data.name);
|
||||||
})
|
});
|
||||||
|
|
||||||
evalInMainWorld(() => {
|
evalInMainWorld(() => {
|
||||||
window.exec = name => window.postMessage({ name })
|
window.exec = name => window.postMessage({ name });
|
||||||
})
|
});
|
||||||
|
|
12
spec/fixtures/extensions/chrome-storage/main.js
vendored
12
spec/fixtures/extensions/chrome-storage/main.js
vendored
|
@ -1,8 +1,8 @@
|
||||||
/* eslint-disable */
|
/* global chrome */
|
||||||
chrome.storage.local.set({ key: 'value' }, () => {
|
chrome.storage.local.set({ key: 'value' }, () => {
|
||||||
chrome.storage.local.get(['key'], ({ key }) => {
|
chrome.storage.local.get(['key'], ({ key }) => {
|
||||||
const script = document.createElement('script')
|
const script = document.createElement('script');
|
||||||
script.textContent = `require('electron').ipcRenderer.send('storage-success', ${JSON.stringify(key)})`
|
script.textContent = `require('electron').ipcRenderer.send('storage-success', ${JSON.stringify(key)})`;
|
||||||
document.documentElement.appendChild(script)
|
document.documentElement.appendChild(script);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
// eslint-disable-next-line
|
/* global chrome */
|
||||||
chrome.devtools.panels.create('Foo', 'icon.png', 'index.html')
|
chrome.devtools.panels.create('Foo', 'icon.png', 'index.html');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// eslint-disable-next-line
|
/* global chrome */
|
||||||
chrome.devtools.inspectedWindow.eval(`require("electron").ipcRenderer.send("winning")`, (result, exc) => {
|
chrome.devtools.inspectedWindow.eval('require("electron").ipcRenderer.send("winning")', (result, exc) => {
|
||||||
console.log(result, exc);
|
console.log(result, exc);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* eslint-disable no-undef */
|
/* global chrome */
|
||||||
chrome.runtime.onMessage.addListener((message, sender, reply) => {
|
chrome.runtime.onMessage.addListener((message, sender, reply) => {
|
||||||
window.receivedMessage = message;
|
window.receivedMessage = message;
|
||||||
reply({ message, sender });
|
reply({ message, sender });
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* eslint-disable no-undef */
|
/* global chrome */
|
||||||
chrome.runtime.sendMessage({ some: 'message' }, (response) => {
|
chrome.runtime.sendMessage({ some: 'message' }, (response) => {
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.textContent = `require('electron').ipcRenderer.send('bg-page-message-response', ${JSON.stringify(response)})`;
|
script.textContent = `require('electron').ipcRenderer.send('bg-page-message-response', ${JSON.stringify(response)})`;
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
/* eslint-disable no-undef */
|
|
2
spec/fixtures/module/preload-context.js
vendored
2
spec/fixtures/module/preload-context.js
vendored
|
@ -1,4 +1,4 @@
|
||||||
var test = 'test' // eslint-disable-line
|
var test = 'test'; // eslint-disable-line no-var
|
||||||
|
|
||||||
const types = {
|
const types = {
|
||||||
require: typeof require,
|
require: typeof require,
|
||||||
|
|
2
spec/fixtures/module/preload-sandbox.js
vendored
2
spec/fixtures/module/preload-sandbox.js
vendored
|
@ -52,7 +52,7 @@
|
||||||
ipcRenderer.on('touch-the-opener', () => {
|
ipcRenderer.on('touch-the-opener', () => {
|
||||||
let errorMessage = null;
|
let errorMessage = null;
|
||||||
try {
|
try {
|
||||||
const openerDoc = opener.document; // eslint-disable-line no-unused-vars
|
const openerDoc = opener.document;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errorMessage = error.message;
|
errorMessage = error.message;
|
||||||
}
|
}
|
||||||
|
|
2
spec/fixtures/testsnap.js
vendored
2
spec/fixtures/testsnap.js
vendored
|
@ -1,3 +1,3 @@
|
||||||
// taken from https://chromium.googlesource.com/v8/v8.git/+/HEAD/test/cctest/test-serialize.cc#1127
|
// taken from https://chromium.googlesource.com/v8/v8.git/+/HEAD/test/cctest/test-serialize.cc#1127
|
||||||
function f () { return g() * 2; } // eslint-disable-line no-unused-vars
|
function f () { return g() * 2; }
|
||||||
function g () { return 43; }
|
function g () { return 43; }
|
||||||
|
|
|
@ -200,7 +200,6 @@ describe('node feature', () => {
|
||||||
emitter.on(eventName, listener);
|
emitter.on(eventName, listener);
|
||||||
});
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
callback(...args);
|
callback(...args);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -422,9 +421,7 @@ describe('node feature', () => {
|
||||||
|
|
||||||
// Needed to test specific DiffieHellman ctors.
|
// Needed to test specific DiffieHellman ctors.
|
||||||
|
|
||||||
// eslint-disable-next-line no-octal
|
|
||||||
crypto.createDiffieHellman('abc', Buffer.from([2]));
|
crypto.createDiffieHellman('abc', Buffer.from([2]));
|
||||||
// eslint-disable-next-line no-octal
|
|
||||||
crypto.createDiffieHellman('abc', '123');
|
crypto.createDiffieHellman('abc', '123');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue