Skip to content

Commit

Permalink
updates to electon extensions
Browse files Browse the repository at this point in the history
- Windows.resetExtensions => removeAllExtensions
- remove all extensions before installing too
  • Loading branch information
flotwig committed Feb 5, 2020
1 parent 4b4842e commit 7019a0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/server/lib/browsers/electron.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ getAutomation = (win) ->
CdpAutomation(sendCommand)

_installExtensions = (extensionPaths = [], options) ->
Windows.removeAllExtensions()

extensionPaths.forEach (path) ->
try
Windows.installExtension(path)
Expand Down Expand Up @@ -264,7 +266,7 @@ module.exports = {
win.once "closed", ->
debug("closed event fired")

Windows.resetExtensions()
Windows.removeAllExtensions()

events.emit("exit")

Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/gui/windows.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = {
if !name
throw new Error('Extension could not be installed.')

resetExtensions: ->
removeAllExtensions: ->
## remove all extensions
extensions = _.keys(BrowserWindow.getExtensions())

Expand Down
9 changes: 8 additions & 1 deletion packages/server/test/unit/browsers/electron_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe "lib/browsers/electron", ->
})

sinon.stub(Windows, 'installExtension').returns()
sinon.stub(Windows, 'resetExtensions').returns()
sinon.stub(Windows, 'removeAllExtensions').returns()

@stubForOpen = ->
sinon.stub(electron, "_render").resolves(@win)
Expand Down Expand Up @@ -122,6 +122,8 @@ describe "lib/browsers/electron", ->

electron.open("electron", @url, @options, @automation)
.then =>
expect(Windows.removeAllExtensions).to.be.calledOnce

expect(Windows.installExtension).to.be.calledTwice
expect(Windows.installExtension).to.be.calledWith('foo')
expect(Windows.installExtension).to.be.calledWith('bar')
Expand All @@ -131,6 +133,11 @@ describe "lib/browsers/electron", ->
warning = @options.onWarning.firstCall.args[0].message
expect(warning).to.contain('Electron').and.contain('bar')

@win.emit('closed')

## called once before installing extensions, once on exit
expect(Windows.removeAllExtensions).to.be.calledTwice

context "._launch", ->
beforeEach ->
sinon.stub(menu, "set")
Expand Down

0 comments on commit 7019a0b

Please sign in to comment.