Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove deprecated modules internally using remote.require in sandboxed renderer context #15957

Merged
merged 1 commit into from Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/api/screen.md
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion filenames.gni
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion lib/renderer/api/module-list.js
Expand Up @@ -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' }
]
8 changes: 0 additions & 8 deletions lib/renderer/api/screen.js

This file was deleted.

13 changes: 0 additions & 13 deletions lib/sandboxed_renderer/init.js
Expand Up @@ -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],
Expand Down Expand Up @@ -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')
}

Expand Down