From 019b31d08466f5058df90a2ba793e6165fbd9d41 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Thu, 9 May 2019 20:48:10 +0200 Subject: [PATCH] chore: remove deprecated APIs (#18159) --- docs/api/breaking-changes.md | 35 +++++++++++++++++++++++++++++ docs/api/power-monitor.md | 18 --------------- docs/api/web-frame.md | 21 ------------------ lib/browser/api/app.ts | 8 ------- lib/browser/api/power-monitor.ts | 20 ----------------- lib/renderer/api/web-frame.ts | 21 ------------------ spec/api-power-monitor-spec.js | 38 -------------------------------- 7 files changed, 35 insertions(+), 126 deletions(-) diff --git a/docs/api/breaking-changes.md b/docs/api/breaking-changes.md index 51a1d7be9c1b..87997b73e7df 100644 --- a/docs/api/breaking-changes.md +++ b/docs/api/breaking-changes.md @@ -19,6 +19,41 @@ session.clearAuthCache({ type: 'password' }) session.clearAuthCache() ``` +### `powerMonitor.querySystemIdleState` + +```js +// Removed in Electron 7.0 +powerMonitor.querySystemIdleState(threshold, callback) +// Replace with synchronous API +const idleState = getSystemIdleState(threshold) +``` + +### `powerMonitor.querySystemIdleTime` + +```js +// Removed in Electron 7.0 +powerMonitor.querySystemIdleTime(callback) +// Replace with synchronous API +const idleTime = getSystemIdleTime() +``` + +### webFrame Isolated World APIs + +```js +// Removed in Elecron 7.0 +webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp) +webFrame.setIsolatedWorldHumanReadableName(worldId, name) +webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin) +// Replace with +webFrame.setIsolatedWorldInfo( + worldId, + { + securityOrigin: 'some_origin', + name: 'human_readable_name', + csp: 'content_security_policy' + }) +``` + ## Planned Breaking API Changes (6.0) ### `win.setMenu(null)` diff --git a/docs/api/power-monitor.md b/docs/api/power-monitor.md index b420a8c954ce..a2bf7eb3035d 100644 --- a/docs/api/power-monitor.md +++ b/docs/api/power-monitor.md @@ -59,24 +59,6 @@ Emitted as soon as the systems screen is unlocked. The `powerMonitor` module has the following methods: -### `powerMonitor.querySystemIdleState(idleThreshold, callback)` _(Deprecated)_ - -* `idleThreshold` Integer -* `callback` Function - * `idleState` String - Can be `active`, `idle`, `locked` or `unknown` - -Calculate the system idle state. `idleThreshold` is the amount of time (in seconds) -before considered idle. `callback` will be called synchronously on some systems -and with an `idleState` argument that describes the system's state. `locked` is -available on supported systems only. - -### `powerMonitor.querySystemIdleTime(callback)` _(Deprecated)_ - -* `callback` Function - * `idleTime` Integer - Idle time in seconds - -Calculate system idle time in seconds. - ### `powerMonitor.getSystemIdleState(idleThreshold)` * `idleThreshold` Integer diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index ac2c64b07ea4..d0a1609e1256 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -132,27 +132,6 @@ or is rejected if the result of the code is a rejected promise. Works like `executeJavaScript` but evaluates `scripts` in an isolated context. -### `webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp)` _(Deprecated)_ - -* `worldId` Integer - The ID of the world to run the javascript in, `0` is the default world, `999` is the world used by Electrons `contextIsolation` feature. Chrome extensions reserve the range of IDs in `[1 << 20, 1 << 29)`. You can provide any integer here. -* `csp` String - -Set the content security policy of the isolated world. - -### `webFrame.setIsolatedWorldHumanReadableName(worldId, name)` _(Deprecated)_ - -* `worldId` Integer - The ID of the world to run the javascript in, `0` is the default world, `999` is the world used by Electrons `contextIsolation` feature. Chrome extensions reserve the range of IDs in `[1 << 20, 1 << 29)`. You can provide any integer here. -* `name` String - -Set the name of the isolated world. Useful in devtools. - -### `webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin)` _(Deprecated)_ - -* `worldId` Integer - The ID of the world to run the javascript in, `0` is the default world, `999` is the world used by Electrons `contextIsolation` feature. Chrome extensions reserve the range of IDs in `[1 << 20, 1 << 29)`. You can provide any integer here. -* `securityOrigin` String - -Set the security origin of the isolated world. - ### `webFrame.setIsolatedWorldInfo(worldId, info)` * `worldId` Integer - The ID of the world to run the javascript in, `0` is the default world, `999` is the world used by Electrons `contextIsolation` feature. Chrome extensions reserve the range of IDs in `[1 << 20, 1 << 29)`. You can provide any integer here. * `info` Object diff --git a/lib/browser/api/app.ts b/lib/browser/api/app.ts index 52463958588a..7d5163a53e32 100644 --- a/lib/browser/api/app.ts +++ b/lib/browser/api/app.ts @@ -19,14 +19,6 @@ Object.setPrototypeOf(App.prototype, EventEmitter.prototype) EventEmitter.call(app as any) Object.assign(app, { - // TODO(codebytere): remove in 7.0 - setApplicationMenu (menu: Electron.Menu | null) { - return Menu.setApplicationMenu(menu) - }, - // TODO(codebytere): remove in 7.0 - getApplicationMenu () { - return Menu.getApplicationMenu() - }, commandLine: { hasSwitch: (theSwitch: string) => commandLine.hasSwitch(String(theSwitch)), getSwitchValue: (theSwitch: string) => commandLine.getSwitchValue(String(theSwitch)), diff --git a/lib/browser/api/power-monitor.ts b/lib/browser/api/power-monitor.ts index 197f5b97dd6e..795236334d65 100644 --- a/lib/browser/api/power-monitor.ts +++ b/lib/browser/api/power-monitor.ts @@ -4,7 +4,6 @@ import { createLazyInstance } from '../utils' const { EventEmitter } = require('events') const { createPowerMonitor, PowerMonitor } = process.electronBinding('power_monitor') -const { deprecate } = require('electron') // PowerMonitor is an EventEmitter. Object.setPrototypeOf(PowerMonitor.prototype, EventEmitter.prototype) @@ -26,23 +25,4 @@ if (process.platform === 'linux') { }) } -// TODO(nitsakh): Remove in 7.0 -powerMonitor.querySystemIdleState = function (threshold: number, callback: Function) { - deprecate.warn('powerMonitor.querySystemIdleState', 'powerMonitor.getSystemIdleState') - if (typeof threshold !== 'number') throw new Error('Must pass threshold as a number') - if (typeof callback !== 'function') throw new Error('Must pass callback as a function argument') - - const idleState = this.getSystemIdleState(threshold) - process.nextTick(() => callback(idleState)) -} - -// TODO(nitsakh): Remove in 7.0 -powerMonitor.querySystemIdleTime = function (callback: Function) { - deprecate.warn('powerMonitor.querySystemIdleTime', 'powerMonitor.getSystemIdleTime') - if (typeof callback !== 'function') throw new Error('Must pass function as an argument') - - const idleTime = this.getSystemIdleTime() - process.nextTick(() => callback(idleTime)) -} - module.exports = powerMonitor diff --git a/lib/renderer/api/web-frame.ts b/lib/renderer/api/web-frame.ts index 4d3b06489103..7b34e87229d1 100644 --- a/lib/renderer/api/web-frame.ts +++ b/lib/renderer/api/web-frame.ts @@ -1,5 +1,4 @@ import { EventEmitter } from 'events' -import { deprecate } from 'electron' const binding = process.electronBinding('web_frame') @@ -46,26 +45,6 @@ class WebFrame extends EventEmitter { get routingId () { return binding._getRoutingId(this.context) } - - // Deprecations - // TODO(nitsakh): Remove in 6.0 - setIsolatedWorldSecurityOrigin (worldId: number, securityOrigin: string) { - deprecate.warn('webFrame.setIsolatedWorldSecurityOrigin', 'webFrame.setIsolatedWorldInfo') - binding.setIsolatedWorldInfo(this.context, worldId, { securityOrigin }) - } - - setIsolatedWorldContentSecurityPolicy (worldId: number, csp: string) { - deprecate.warn('webFrame.setIsolatedWorldContentSecurityPolicy', 'webFrame.setIsolatedWorldInfo') - binding.setIsolatedWorldInfo(this.context, worldId, { - securityOrigin: window.location.origin, - csp - }) - } - - setIsolatedWorldHumanReadableName (worldId: number, name: string) { - deprecate.warn('webFrame.setIsolatedWorldHumanReadableName', 'webFrame.setIsolatedWorldInfo') - binding.setIsolatedWorldInfo(this.context, worldId, { name }) - } } // Populate the methods. diff --git a/spec/api-power-monitor-spec.js b/spec/api-power-monitor-spec.js index c1e62b0edfc3..9f5425f8ec63 100644 --- a/spec/api-power-monitor-spec.js +++ b/spec/api-power-monitor-spec.js @@ -128,44 +128,6 @@ describe('powerMonitor', () => { powerMonitor = require('electron').remote.powerMonitor }) - // TODO(nitsakh): Remove in 7.0 - describe('powerMonitor.querySystemIdleState', () => { - it('notify current system idle state', done => { - // this function is not mocked out, so we can test the result's - // form and type but not its value. - powerMonitor.querySystemIdleState(1, idleState => { - expect(idleState).to.be.a('string') - const validIdleStates = [ 'active', 'idle', 'locked', 'unknown' ] - expect(validIdleStates).to.include(idleState) - done() - }) - }) - - it('does not accept non positive integer threshold', () => { - expect(() => { - powerMonitor.querySystemIdleState(-1, (idleState) => {}) - }).to.throw() - - expect(() => { - powerMonitor.querySystemIdleState(NaN, (idleState) => {}) - }).to.throw() - - expect(() => { - powerMonitor.querySystemIdleState('a', (idleState) => {}) - }).to.throw() - }) - }) - - // TODO(nitsakh): Remove in 7.0 - describe('powerMonitor.querySystemIdleTime', () => { - it('notify current system idle time', done => { - powerMonitor.querySystemIdleTime(idleTime => { - expect(idleTime).to.be.at.least(0) - done() - }) - }) - }) - describe('powerMonitor.getSystemIdleState', () => { it('gets current system idle state', () => { // this function is not mocked out, so we can test the result's