diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index 8eb3096b052c..0966c81245a5 100644 --- a/lib/browser/api/dialog.js +++ b/lib/browser/api/dialog.js @@ -61,9 +61,7 @@ module.exports = { if (properties == null) { properties = ['openFile'] - } - - if (!Array.isArray(properties)) { + } else if (!Array.isArray(properties)) { throw new TypeError('Properties must be an array') } @@ -167,7 +165,9 @@ module.exports = { throw new TypeError('Invalid message box type') } - if (!Array.isArray(buttons)) { + if (buttons == null) { + buttons = [] + } else if (!Array.isArray(buttons)) { throw new TypeError('Buttons must be an array') } diff --git a/spec/api-dialog-spec.js b/spec/api-dialog-spec.js index 6391edcd7573..5d6c54083b8d 100644 --- a/spec/api-dialog-spec.js +++ b/spec/api-dialog-spec.js @@ -49,15 +49,15 @@ describe('dialog module', () => { }, /Buttons must be an array/) assert.throws(() => { - dialog.showMessageBox({title: 300, buttons: ['OK']}) + dialog.showMessageBox({title: 300}) }, /Title must be a string/) assert.throws(() => { - dialog.showMessageBox({message: [], buttons: ['OK']}) + dialog.showMessageBox({message: []}) }, /Message must be a string/) assert.throws(() => { - dialog.showMessageBox({detail: 3.14, buttons: ['OK']}) + dialog.showMessageBox({detail: 3.14}) }, /Detail must be a string/) }) })