chore: support props/fns for BrowserWindow (#22686)

This commit is contained in:
Shelley Vohr 2020-03-16 14:03:35 -07:00 committed by GitHub
parent 20480c8ea8
commit 97d8caa1e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 322 additions and 302 deletions

View file

@ -1115,15 +1115,11 @@ Returns `Integer[]` - Contains the window's maximum width and height.
* `resizable` Boolean * `resizable` Boolean
Sets whether the window can be manually resized by user. Sets whether the window can be manually resized by the user.
**[Deprecated](modernization/property-updates.md)**
#### `win.isResizable()` #### `win.isResizable()`
Returns `Boolean` - Whether the window can be manually resized by user. Returns `Boolean` - Whether the window can be manually resized by the user.
**[Deprecated](modernization/property-updates.md)**
#### `win.setMovable(movable)` _macOS_ _Windows_ #### `win.setMovable(movable)` _macOS_ _Windows_
@ -1131,41 +1127,29 @@ Returns `Boolean` - Whether the window can be manually resized by user.
Sets whether the window can be moved by user. On Linux does nothing. Sets whether the window can be moved by user. On Linux does nothing.
**[Deprecated](modernization/property-updates.md)**
#### `win.isMovable()` _macOS_ _Windows_ #### `win.isMovable()` _macOS_ _Windows_
Returns `Boolean` - Whether the window can be moved by user. Returns `Boolean` - Whether the window can be moved by user.
On Linux always returns `true`. On Linux always returns `true`.
**[Deprecated](modernization/property-updates.md)**
#### `win.setMinimizable(minimizable)` _macOS_ _Windows_ #### `win.setMinimizable(minimizable)` _macOS_ _Windows_
* `minimizable` Boolean * `minimizable` Boolean
Sets whether the window can be manually minimized by user. On Linux does Sets whether the window can be manually minimized by user. On Linux does nothing.
nothing.
**[Deprecated](modernization/property-updates.md)**
#### `win.isMinimizable()` _macOS_ _Windows_ #### `win.isMinimizable()` _macOS_ _Windows_
Returns `Boolean` - Whether the window can be manually minimized by user Returns `Boolean` - Whether the window can be manually minimized by the user.
On Linux always returns `true`. On Linux always returns `true`.
**[Deprecated](modernization/property-updates.md)**
#### `win.setMaximizable(maximizable)` _macOS_ _Windows_ #### `win.setMaximizable(maximizable)` _macOS_ _Windows_
* `maximizable` Boolean * `maximizable` Boolean
Sets whether the window can be manually maximized by user. On Linux does Sets whether the window can be manually maximized by user. On Linux does nothing.
nothing.
**[Deprecated](modernization/property-updates.md)**
#### `win.isMaximizable()` _macOS_ _Windows_ #### `win.isMaximizable()` _macOS_ _Windows_
@ -1173,23 +1157,15 @@ Returns `Boolean` - Whether the window can be manually maximized by user.
On Linux always returns `true`. On Linux always returns `true`.
**[Deprecated](modernization/property-updates.md)**
#### `win.setFullScreenable(fullscreenable)` #### `win.setFullScreenable(fullscreenable)`
* `fullscreenable` Boolean * `fullscreenable` Boolean
Sets whether the maximize/zoom window button toggles fullscreen mode or Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
maximizes the window.
**[Deprecated](modernization/property-updates.md)**
#### `win.isFullScreenable()` #### `win.isFullScreenable()`
Returns `Boolean` - Whether the maximize/zoom window button toggles fullscreen mode or Returns `Boolean` - Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
maximizes the window.
**[Deprecated](modernization/property-updates.md)**
#### `win.setClosable(closable)` _macOS_ _Windows_ #### `win.setClosable(closable)` _macOS_ _Windows_
@ -1197,16 +1173,12 @@ maximizes the window.
Sets whether the window can be manually closed by user. On Linux does nothing. Sets whether the window can be manually closed by user. On Linux does nothing.
**[Deprecated](modernization/property-updates.md)**
#### `win.isClosable()` _macOS_ _Windows_ #### `win.isClosable()` _macOS_ _Windows_
Returns `Boolean` - Whether the window can be manually closed by user. Returns `Boolean` - Whether the window can be manually closed by user.
On Linux always returns `true`. On Linux always returns `true`.
**[Deprecated](modernization/property-updates.md)**
#### `win.setAlwaysOnTop(flag[, level][, relativeLevel])` #### `win.setAlwaysOnTop(flag[, level][, relativeLevel])`
* `flag` Boolean * `flag` Boolean
@ -1618,23 +1590,17 @@ This cannot be called when `titleBarStyle` is set to `customButtonsOnHover`.
Sets whether the window menu bar should hide itself automatically. Once set the Sets whether the window menu bar should hide itself automatically. Once set the
menu bar will only show when users press the single `Alt` key. menu bar will only show when users press the single `Alt` key.
If the menu bar is already visible, calling `setAutoHideMenuBar(true)` won't If the menu bar is already visible, calling `setAutoHideMenuBar(true)` won't hide it immediately.
hide it immediately.
**[Deprecated](modernization/property-updates.md)**
#### `win.isMenuBarAutoHide()` #### `win.isMenuBarAutoHide()`
Returns `Boolean` - Whether menu bar automatically hides itself. Returns `Boolean` - Whether menu bar automatically hides itself.
**[Deprecated](modernization/property-updates.md)**
#### `win.setMenuBarVisibility(visible)` _Windows_ _Linux_ #### `win.setMenuBarVisibility(visible)` _Windows_ _Linux_
* `visible` Boolean * `visible` Boolean
Sets whether the menu bar should be visible. If the menu bar is auto-hide, users Sets whether the menu bar should be visible. If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
can still bring up the menu bar by pressing the single `Alt` key.
#### `win.isMenuBarVisible()` #### `win.isMenuBarVisible()`

View file

@ -72,6 +72,43 @@ BrowserWindow.prototype._init = function () {
return this.webContents.devToolsWebContents return this.webContents.devToolsWebContents
} }
}) })
// Properties
Object.defineProperty(this, 'autoHideMenuBar', {
get: () => this.isMenuBarAutoHide(),
set: (autoHide) => this.setAutoHideMenuBar(autoHide)
})
Object.defineProperty(this, 'minimizable', {
get: () => this.isMinimizable(),
set: (min) => this.setMinimizable(min)
})
Object.defineProperty(this, 'maximizable', {
get: () => this.isMaximizable(),
set: (max) => this.setMaximizable(max)
})
Object.defineProperty(this, 'resizable', {
get: () => this.isResizable(),
set: (res) => this.setResizable(res)
})
Object.defineProperty(this, 'fullScreenable', {
get: () => this.isFullScreenable(),
set: (full) => this.setFullScreenable(full)
})
Object.defineProperty(this, 'closable', {
get: () => this.isClosable(),
set: (close) => this.setClosable(close)
})
Object.defineProperty(this, 'movable', {
get: () => this.isMovable(),
set: (move) => this.setMovable(move)
})
} }
const isBrowserWindow = (win) => { const isBrowserWindow = (win) => {
@ -165,13 +202,4 @@ Object.assign(BrowserWindow.prototype, {
} }
}) })
// Deprecations
deprecate.fnToProperty(BrowserWindow.prototype, 'autoHideMenuBar', '_isMenuBarAutoHide', '_setAutoHideMenuBar')
deprecate.fnToProperty(BrowserWindow.prototype, 'minimizable', '_isMinimizable', '_setMinimizable')
deprecate.fnToProperty(BrowserWindow.prototype, 'maximizable', '_isMaximizable', '_setMaximizable')
deprecate.fnToProperty(BrowserWindow.prototype, 'resizable', '_isResizable', '_setResizable')
deprecate.fnToProperty(BrowserWindow.prototype, 'fullScreenable', '_isFullScreenable', '_setFullScreenable')
deprecate.fnToProperty(BrowserWindow.prototype, 'closable', '_isClosable', '_setClosable')
deprecate.fnToProperty(BrowserWindow.prototype, 'movable', '_isMovable', '_setMovable')
module.exports = BrowserWindow module.exports = BrowserWindow

View file

@ -1120,30 +1120,18 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setSheetOffset", &TopLevelWindow::SetSheetOffset) .SetMethod("setSheetOffset", &TopLevelWindow::SetSheetOffset)
.SetMethod("moveAbove", &TopLevelWindow::MoveAbove) .SetMethod("moveAbove", &TopLevelWindow::MoveAbove)
.SetMethod("moveTop", &TopLevelWindow::MoveTop) .SetMethod("moveTop", &TopLevelWindow::MoveTop)
.SetMethod("_setResizable", &TopLevelWindow::SetResizable) .SetMethod("setResizable", &TopLevelWindow::SetResizable)
.SetMethod("_isResizable", &TopLevelWindow::IsResizable) .SetMethod("isResizable", &TopLevelWindow::IsResizable)
.SetProperty("resizable", &TopLevelWindow::IsResizable, .SetMethod("setMovable", &TopLevelWindow::SetMovable)
&TopLevelWindow::SetResizable) .SetMethod("isMovable", &TopLevelWindow::IsMovable)
.SetMethod("_setMovable", &TopLevelWindow::SetMovable) .SetMethod("setMinimizable", &TopLevelWindow::SetMinimizable)
.SetMethod("_isMovable", &TopLevelWindow::IsMovable) .SetMethod("isMinimizable", &TopLevelWindow::IsMinimizable)
.SetProperty("movable", &TopLevelWindow::IsMovable, .SetMethod("setMaximizable", &TopLevelWindow::SetMaximizable)
&TopLevelWindow::SetMovable) .SetMethod("isMaximizable", &TopLevelWindow::IsMaximizable)
.SetMethod("_setMinimizable", &TopLevelWindow::SetMinimizable) .SetMethod("setFullScreenable", &TopLevelWindow::SetFullScreenable)
.SetMethod("_isMinimizable", &TopLevelWindow::IsMinimizable) .SetMethod("isFullScreenable", &TopLevelWindow::IsFullScreenable)
.SetProperty("minimizable", &TopLevelWindow::IsMinimizable, .SetMethod("setClosable", &TopLevelWindow::SetClosable)
&TopLevelWindow::SetMinimizable) .SetMethod("isClosable", &TopLevelWindow::IsClosable)
.SetMethod("_setMaximizable", &TopLevelWindow::SetMaximizable)
.SetMethod("_isMaximizable", &TopLevelWindow::IsMaximizable)
.SetProperty("maximizable", &TopLevelWindow::IsMaximizable,
&TopLevelWindow::SetMaximizable)
.SetMethod("_setFullScreenable", &TopLevelWindow::SetFullScreenable)
.SetMethod("_isFullScreenable", &TopLevelWindow::IsFullScreenable)
.SetProperty("fullScreenable", &TopLevelWindow::IsFullScreenable,
&TopLevelWindow::SetFullScreenable)
.SetMethod("_setClosable", &TopLevelWindow::SetClosable)
.SetMethod("_isClosable", &TopLevelWindow::IsClosable)
.SetProperty("closable", &TopLevelWindow::IsClosable,
&TopLevelWindow::SetClosable)
.SetMethod("setAlwaysOnTop", &TopLevelWindow::SetAlwaysOnTop) .SetMethod("setAlwaysOnTop", &TopLevelWindow::SetAlwaysOnTop)
.SetMethod("isAlwaysOnTop", &TopLevelWindow::IsAlwaysOnTop) .SetMethod("isAlwaysOnTop", &TopLevelWindow::IsAlwaysOnTop)
.SetMethod("center", &TopLevelWindow::Center) .SetMethod("center", &TopLevelWindow::Center)
@ -1217,10 +1205,8 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
&TopLevelWindow::IsExcludedFromShownWindowsMenu, &TopLevelWindow::IsExcludedFromShownWindowsMenu,
&TopLevelWindow::SetExcludedFromShownWindowsMenu) &TopLevelWindow::SetExcludedFromShownWindowsMenu)
#endif #endif
.SetMethod("_setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar) .SetMethod("setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar)
.SetMethod("_isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide) .SetMethod("isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide)
.SetProperty("autoHideMenuBar", &TopLevelWindow::IsMenuBarAutoHide,
&TopLevelWindow::SetAutoHideMenuBar)
.SetMethod("setMenuBarVisibility", &TopLevelWindow::SetMenuBarVisibility) .SetMethod("setMenuBarVisibility", &TopLevelWindow::SetMenuBarVisibility)
.SetMethod("isMenuBarVisible", &TopLevelWindow::IsMenuBarVisible) .SetMethod("isMenuBarVisible", &TopLevelWindow::IsMenuBarVisible)
.SetMethod("setAspectRatio", &TopLevelWindow::SetAspectRatio) .SetMethod("setAspectRatio", &TopLevelWindow::SetAspectRatio)

View file

@ -1102,15 +1102,39 @@ describe('BrowserWindow module', () => {
}) })
}) })
describe('autoHideMenuBar property', () => { describe('autoHideMenuBar state', () => {
afterEach(closeAllWindows) afterEach(closeAllWindows)
it('exists', () => {
const w = new BrowserWindow({ show: false })
expect(w).to.have.property('autoHideMenuBar')
// TODO(codebytere): remove when propertyification is complete it('for properties', () => {
expect(w.setAutoHideMenuBar).to.be.a('function') it('can be set with autoHideMenuBar constructor option', () => {
expect(w.isMenuBarAutoHide).to.be.a('function') const w = new BrowserWindow({ show: false, autoHideMenuBar: true })
expect(w.autoHideMenuBar).to.be.true('autoHideMenuBar')
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.autoHideMenuBar).to.be.false('autoHideMenuBar')
w.autoHideMenuBar = true
expect(w.autoHideMenuBar).to.be.true('autoHideMenuBar')
w.autoHideMenuBar = false
expect(w.autoHideMenuBar).to.be.false('autoHideMenuBar')
})
})
it('for functions', () => {
it('can be set with autoHideMenuBar constructor option', () => {
const w = new BrowserWindow({ show: false, autoHideMenuBar: true })
expect(w.isMenuBarAutoHide()).to.be.true('autoHideMenuBar')
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.isMenuBarAutoHide()).to.be.false('autoHideMenuBar')
w.setAutoHideMenuBar(true)
expect(w.isMenuBarAutoHide()).to.be.true('autoHideMenuBar')
w.setAutoHideMenuBar(false)
expect(w.isMenuBarAutoHide()).to.be.false('autoHideMenuBar')
})
}) })
}) })
@ -3247,7 +3271,8 @@ describe('BrowserWindow module', () => {
}) })
describe('resizable state', () => { describe('resizable state', () => {
it('can be changed with resizable option', () => { it('with properties', () => {
it('can be set with resizable constructor option', () => {
const w = new BrowserWindow({ show: false, resizable: false }) const w = new BrowserWindow({ show: false, resizable: false })
expect(w.resizable).to.be.false('resizable') expect(w.resizable).to.be.false('resizable')
@ -3256,8 +3281,27 @@ describe('BrowserWindow module', () => {
} }
}) })
// TODO(codebytere): remove when propertyification is complete it('can be changed', () => {
it('can be changed with setResizable method', () => { const w = new BrowserWindow({ show: false })
expect(w.resizable).to.be.true('resizable')
w.resizable = false
expect(w.resizable).to.be.false('resizable')
w.resizable = true
expect(w.resizable).to.be.true('resizable')
})
})
it('with functions', () => {
it('can be set with resizable constructor option', () => {
const w = new BrowserWindow({ show: false, resizable: false })
expect(w.isResizable()).to.be.false('resizable')
if (process.platform === 'darwin') {
expect(w.isMaximizable()).to.to.true('maximizable')
}
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.isResizable()).to.be.true('resizable') expect(w.isResizable()).to.be.true('resizable')
w.setResizable(false) w.setResizable(false)
@ -3265,14 +3309,6 @@ describe('BrowserWindow module', () => {
w.setResizable(true) w.setResizable(true)
expect(w.isResizable()).to.be.true('resizable') expect(w.isResizable()).to.be.true('resizable')
}) })
it('can be changed with resizable property', () => {
const w = new BrowserWindow({ show: false })
expect(w.resizable).to.be.true('resizable')
w.resizable = false
expect(w.resizable).to.be.false('resizable')
w.resizable = true
expect(w.resizable).to.be.true('resizable')
}) })
it('works for a frameless window', () => { it('works for a frameless window', () => {
@ -3361,12 +3397,14 @@ describe('BrowserWindow module', () => {
// Not implemented on Linux. // Not implemented on Linux.
afterEach(closeAllWindows) afterEach(closeAllWindows)
describe('movable state (property)', () => { describe('movable state', () => {
it('can be changed with movable option', () => { it('with properties', () => {
it('can be set with movable constructor option', () => {
const w = new BrowserWindow({ show: false, movable: false }) const w = new BrowserWindow({ show: false, movable: false })
expect(w.movable).to.be.false('movable') expect(w.movable).to.be.false('movable')
}) })
it('can be changed with movable property', () => {
it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.movable).to.be.true('movable') expect(w.movable).to.be.true('movable')
w.movable = false w.movable = false
@ -3376,13 +3414,13 @@ describe('BrowserWindow module', () => {
}) })
}) })
// TODO(codebytere): remove when propertyification is complete it('with functions', () => {
describe('movable state (methods)', () => { it('can be set with movable constructor option', () => {
it('can be changed with movable option', () => {
const w = new BrowserWindow({ show: false, movable: false }) const w = new BrowserWindow({ show: false, movable: false })
expect(w.isMovable()).to.be.false('movable') expect(w.isMovable()).to.be.false('movable')
}) })
it('can be changed with setMovable method', () => {
it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.isMovable()).to.be.true('movable') expect(w.isMovable()).to.be.true('movable')
w.setMovable(false) w.setMovable(false)
@ -3391,14 +3429,16 @@ describe('BrowserWindow module', () => {
expect(w.isMovable()).to.be.true('movable') expect(w.isMovable()).to.be.true('movable')
}) })
}) })
})
describe('minimizable state (property)', () => { describe('minimizable state', () => {
it('can be changed with minimizable option', () => { it('with properties', () => {
it('can be set with minimizable constructor option', () => {
const w = new BrowserWindow({ show: false, minimizable: false }) const w = new BrowserWindow({ show: false, minimizable: false })
expect(w.minimizable).to.be.false('minimizable') expect(w.minimizable).to.be.false('minimizable')
}) })
it('can be changed with minimizable property', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.minimizable).to.be.true('minimizable') expect(w.minimizable).to.be.true('minimizable')
w.minimizable = false w.minimizable = false
@ -3408,14 +3448,13 @@ describe('BrowserWindow module', () => {
}) })
}) })
// TODO(codebytere): remove when propertyification is complete it('with functions', () => {
describe('minimizable state (methods)', () => { it('can be set with minimizable constructor option', () => {
it('can be changed with minimizable option', () => {
const w = new BrowserWindow({ show: false, minimizable: false }) const w = new BrowserWindow({ show: false, minimizable: false })
expect(w.isMinimizable()).to.be.false('movable') expect(w.isMinimizable()).to.be.false('movable')
}) })
it('can be changed with setMinimizable method', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.isMinimizable()).to.be.true('isMinimizable') expect(w.isMinimizable()).to.be.true('isMinimizable')
w.setMinimizable(false) w.setMinimizable(false)
@ -3424,14 +3463,16 @@ describe('BrowserWindow module', () => {
expect(w.isMinimizable()).to.be.true('isMinimizable') expect(w.isMinimizable()).to.be.true('isMinimizable')
}) })
}) })
})
describe('maximizable state (property)', () => { describe('maximizable state (property)', () => {
it('can be changed with maximizable option', () => { it('with properties', () => {
it('can be set with maximizable constructor option', () => {
const w = new BrowserWindow({ show: false, maximizable: false }) const w = new BrowserWindow({ show: false, maximizable: false })
expect(w.maximizable).to.be.false('maximizable') expect(w.maximizable).to.be.false('maximizable')
}) })
it('can be changed with maximizable property', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.maximizable).to.be.true('maximizable') expect(w.maximizable).to.be.true('maximizable')
w.maximizable = false w.maximizable = false
@ -3458,14 +3499,13 @@ describe('BrowserWindow module', () => {
}) })
}) })
// TODO(codebytere): remove when propertyification is complete it('with functions', () => {
describe('maximizable state (methods)', () => { it('can be set with maximizable constructor option', () => {
it('can be changed with maximizable option', () => {
const w = new BrowserWindow({ show: false, maximizable: false }) const w = new BrowserWindow({ show: false, maximizable: false })
expect(w.isMaximizable()).to.be.false('isMaximizable') expect(w.isMaximizable()).to.be.false('isMaximizable')
}) })
it('can be changed with setMaximizable method', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.isMaximizable()).to.be.true('isMaximizable') expect(w.isMaximizable()).to.be.true('isMaximizable')
w.setMaximizable(false) w.setMaximizable(false)
@ -3491,10 +3531,10 @@ describe('BrowserWindow module', () => {
expect(w.isMaximizable()).to.be.true('isMaximizable') expect(w.isMaximizable()).to.be.true('isMaximizable')
}) })
}) })
})
ifdescribe(process.platform === 'win32')('maximizable state (Windows only)', () => { ifdescribe(process.platform === 'win32')('maximizable state', () => {
// Only implemented on windows. it('with properties', () => {
it('is reset to its former state', () => { it('is reset to its former state', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
w.maximizable = false w.maximizable = false
@ -3508,10 +3548,7 @@ describe('BrowserWindow module', () => {
}) })
}) })
// TODO(codebytere): remove when propertyification is complete it('with functions', () => {
ifdescribe(process.platform === 'win32')('maximizable state (Windows only) (methods)', () => {
// Only implemented on windows.
it('is reset to its former state', () => { it('is reset to its former state', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
w.setMaximizable(false) w.setMaximizable(false)
@ -3524,14 +3561,16 @@ describe('BrowserWindow module', () => {
expect(w.isMaximizable()).to.be.true('isMaximizable') expect(w.isMaximizable()).to.be.true('isMaximizable')
}) })
}) })
})
ifdescribe(process.platform === 'darwin')('fullscreenable state (property)', () => { ifdescribe(process.platform === 'darwin')('fullscreenable state', () => {
it('can be changed with fullscreenable option', () => { it('with properties', () => {
it('can be set with fullscreenable constructor option', () => {
const w = new BrowserWindow({ show: false, fullscreenable: false }) const w = new BrowserWindow({ show: false, fullscreenable: false })
expect(w.fullScreenable).to.be.false('fullScreenable') expect(w.fullScreenable).to.be.false('fullScreenable')
}) })
it('can be changed with fullScreenable property', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.fullScreenable).to.be.true('fullScreenable') expect(w.fullScreenable).to.be.true('fullScreenable')
w.fullScreenable = false w.fullScreenable = false
@ -3541,14 +3580,13 @@ describe('BrowserWindow module', () => {
}) })
}) })
// TODO(codebytere): remove when propertyification is complete it('with functions', () => {
ifdescribe(process.platform === 'darwin')('fullscreenable state (methods)', () => { it('can be set with fullscreenable constructor option', () => {
it('can be changed with fullscreenable option', () => {
const w = new BrowserWindow({ show: false, fullscreenable: false }) const w = new BrowserWindow({ show: false, fullscreenable: false })
expect(w.isFullScreenable()).to.be.false('isFullScreenable') expect(w.isFullScreenable()).to.be.false('isFullScreenable')
}) })
it('can be changed with setFullScreenable method', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.isFullScreenable()).to.be.true('isFullScreenable') expect(w.isFullScreenable()).to.be.true('isFullScreenable')
w.setFullScreenable(false) w.setFullScreenable(false)
@ -3557,6 +3595,7 @@ describe('BrowserWindow module', () => {
expect(w.isFullScreenable()).to.be.true('isFullScreenable') expect(w.isFullScreenable()).to.be.true('isFullScreenable')
}) })
}) })
})
// fullscreen events are dispatched eagerly and twiddling things too fast can confuse poor Electron // fullscreen events are dispatched eagerly and twiddling things too fast can confuse poor Electron
const tick = () => new Promise(resolve => setTimeout(resolve)) const tick = () => new Promise(resolve => setTimeout(resolve))
@ -3637,13 +3676,14 @@ describe('BrowserWindow module', () => {
}) })
}) })
describe('closable state (property)', () => { describe('closable state', () => {
it('can be changed with closable option', () => { it('with properties', () => {
it('can be set with closable constructor option', () => {
const w = new BrowserWindow({ show: false, closable: false }) const w = new BrowserWindow({ show: false, closable: false })
expect(w.closable).to.be.false('closable') expect(w.closable).to.be.false('closable')
}) })
it('can be changed with setClosable method', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.closable).to.be.true('closable') expect(w.closable).to.be.true('closable')
w.closable = false w.closable = false
@ -3653,14 +3693,13 @@ describe('BrowserWindow module', () => {
}) })
}) })
// TODO(codebytere): remove when propertyification is complete it('with functions', () => {
describe('closable state (methods)', () => { it('can be set with closable constructor option', () => {
it('can be changed with closable option', () => {
const w = new BrowserWindow({ show: false, closable: false }) const w = new BrowserWindow({ show: false, closable: false })
expect(w.isClosable()).to.be.false('isClosable') expect(w.isClosable()).to.be.false('isClosable')
}) })
it('can be changed with setClosable method', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
expect(w.isClosable()).to.be.true('isClosable') expect(w.isClosable()).to.be.true('isClosable')
w.setClosable(false) w.setClosable(false)
@ -3669,6 +3708,7 @@ describe('BrowserWindow module', () => {
expect(w.isClosable()).to.be.true('isClosable') expect(w.isClosable()).to.be.true('isClosable')
}) })
}) })
})
describe('hasShadow state', () => { describe('hasShadow state', () => {
it('returns a boolean on all platforms', () => { it('returns a boolean on all platforms', () => {