From 713df08e3e9c2b0c54335f924a351f9e11a6a1f3 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Thu, 24 Jan 2019 19:53:52 +0100 Subject: [PATCH] chore: remove deprecated modules internally using remote.require in sandboxed renderer context (#15957) --- docs/api/screen.md | 5 +---- filenames.gni | 1 - lib/renderer/api/module-list.js | 1 - lib/renderer/api/screen.js | 8 -------- lib/sandboxed_renderer/init.js | 13 ------------- 5 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 lib/renderer/api/screen.js diff --git a/docs/api/screen.md b/docs/api/screen.md index c45a22e0efe4..38bb61780f08 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -2,14 +2,11 @@ > Retrieve information about screen size, displays, cursor position, etc. -Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process) +Process: [Main](../glossary.md#main-process) You cannot require or use this module until the `ready` event of the `app` module is emitted. -In the renderer process context it depends on the [`remote`](remote.md) module, -it is therefore not available when this module is disabled. - `screen` is an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter). **Note:** In the renderer / DevTools, `window.screen` is a reserved DOM diff --git a/filenames.gni b/filenames.gni index d913ad232fd1..0b623b0b5d54 100644 --- a/filenames.gni +++ b/filenames.gni @@ -80,7 +80,6 @@ filenames = { "lib/renderer/api/ipc-renderer.js", "lib/renderer/api/module-list.js", "lib/renderer/api/remote.js", - "lib/renderer/api/screen.js", "lib/renderer/api/web-frame.js", "lib/renderer/extensions/event.js", "lib/renderer/extensions/i18n.js", diff --git a/lib/renderer/api/module-list.js b/lib/renderer/api/module-list.js index b9bba8a0eb39..0586f494cc5e 100644 --- a/lib/renderer/api/module-list.js +++ b/lib/renderer/api/module-list.js @@ -16,6 +16,5 @@ module.exports = [ }, { name: 'ipcRenderer', file: 'ipc-renderer' }, { name: 'remote', file: 'remote', enabled: enableRemoteModule }, - { name: 'screen', file: 'screen' }, { name: 'webFrame', file: 'web-frame' } ] diff --git a/lib/renderer/api/screen.js b/lib/renderer/api/screen.js deleted file mode 100644 index a19604ca1499..000000000000 --- a/lib/renderer/api/screen.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict' - -const { deprecate } = require('electron') - -deprecate.warn(`electron.screen`, `electron.remote.screen`) - -const { getRemote } = require('@electron/internal/renderer/remote') -module.exports = getRemote('screen') diff --git a/lib/sandboxed_renderer/init.js b/lib/sandboxed_renderer/init.js index 43fcbbeb176d..949e1910c324 100644 --- a/lib/sandboxed_renderer/init.js +++ b/lib/sandboxed_renderer/init.js @@ -37,13 +37,6 @@ process.isRemoteModuleEnabled = isRemoteModuleEnabled // The electron module depends on process.atomBinding const electron = require('electron') -const remoteModules = new Set([ - 'child_process', - 'fs', - 'os', - 'path' -]) - const loadedModules = new Map([ ['electron', electron], ['events', events], @@ -91,17 +84,11 @@ Object.defineProperty(preloadProcess, 'noDeprecation', { process.on('exit', () => preloadProcess.emit('exit')) -const { remoteRequire } = require('@electron/internal/renderer/remote') - // This is the `require` function that will be visible to the preload script function preloadRequire (module) { if (loadedModules.has(module)) { return loadedModules.get(module) } - if (remoteModules.has(module)) { - electron.deprecate.warn(`require('${module}')`, `remote.require('${module}')`) - return remoteRequire(module) - } throw new Error('module not found') }