Skip to content

Commit

Permalink
refactor: deprecate ServiceWorker APIs (#16732)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Feb 5, 2019
1 parent 05074ba commit 64cd5bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/browser/api/web-contents.js
Expand Up @@ -379,6 +379,8 @@ WebContents.prototype._init = function () {
this.setMaxListeners(0)

this.capturePage = deprecate.promisify(this.capturePage)
this.hasServiceWorker = deprecate.function(this.hasServiceWorker)
this.unregisterServiceWorker = deprecate.function(this.unregisterServiceWorker)

// Dispatch IPC messages to the ipc module.
this.on('-ipc-message', function (event, [channel, ...args]) {
Expand Down
10 changes: 10 additions & 0 deletions lib/common/api/deprecate.js
Expand Up @@ -69,6 +69,16 @@ const deprecate = {
})
},

function: (fn, newName) => {
// if newName is left blank, a removal warning will be displayed
const warn = warnOnce(fn.name, newName)

return function () {
if (!process.noDeprecation) warn()
return fn.apply(this, arguments)
}
},

promisify: (fn) => {
const fnName = fn.name || 'function'
const oldName = `${fnName} with callbacks`
Expand Down

0 comments on commit 64cd5bf

Please sign in to comment.