test: move some BrowserWindow specs to the main process (#19182)
* test: move some BrowserWindow specs to the main process * uncomment cross-site test * move more tests * re-enable, refactor and move visibilitychange specs * move new-window event tests and re-enable them on mac * move max/minimize event tests * move modal tests * move beginFrameSubscription tests * move savePage test * move BrowserWindow options argument is optional test * move restore, unmaximize, fullscreen tests * move parent window tests * don't wait for show event on windows (#8664) * add debugging logs to fullscreen tests * more debugging on windows * explicitly destroy browserviews to prevent crash during gc * only await show on darwin * more event timing fixes * disable max/minimize event tests on linux, since they're broken on CI
This commit is contained in:
parent
7249b25868
commit
27599a851f
7 changed files with 1474 additions and 1677 deletions
|
@ -1013,6 +1013,10 @@ Returns [`Rectangle`](structures/rectangle.md) - Contains the window bounds of t
|
||||||
|
|
||||||
Disable or enable the window.
|
Disable or enable the window.
|
||||||
|
|
||||||
|
#### `win.isEnabled()`
|
||||||
|
|
||||||
|
Returns Boolean - whether the window is enabled.
|
||||||
|
|
||||||
#### `win.setSize(width, height[, animate])`
|
#### `win.setSize(width, height[, animate])`
|
||||||
|
|
||||||
* `width` Integer
|
* `width` Integer
|
||||||
|
@ -1625,7 +1629,7 @@ On macOS it does not remove the focus from the window.
|
||||||
|
|
||||||
#### `win.setParentWindow(parent)`
|
#### `win.setParentWindow(parent)`
|
||||||
|
|
||||||
* `parent` BrowserWindow
|
* `parent` BrowserWindow | null
|
||||||
|
|
||||||
Sets `parent` as current window's parent window, passing `null` will turn
|
Sets `parent` as current window's parent window, passing `null` will turn
|
||||||
current window into a top-level window.
|
current window into a top-level window.
|
||||||
|
|
|
@ -218,14 +218,12 @@ int SystemPreferences::DoSubscribeNotification(
|
||||||
|
|
||||||
if (user_info) {
|
if (user_info) {
|
||||||
copied_callback.Run(
|
copied_callback.Run(
|
||||||
base::SysNSStringToUTF8(notification.name),
|
base::SysNSStringToUTF8(notification.name), *user_info,
|
||||||
*user_info,
|
|
||||||
object);
|
object);
|
||||||
} else {
|
} else {
|
||||||
copied_callback.Run(
|
copied_callback.Run(
|
||||||
base::SysNSStringToUTF8(notification.name),
|
base::SysNSStringToUTF8(notification.name),
|
||||||
base::DictionaryValue(),
|
base::DictionaryValue(), object);
|
||||||
object);
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
return request_id;
|
return request_id;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,75 +0,0 @@
|
||||||
const fs = require('fs')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test sandbox environment used to fake network responses.
|
|
||||||
*/
|
|
||||||
class NetworkSandbox {
|
|
||||||
constructor (protocol) {
|
|
||||||
this.protocol = protocol
|
|
||||||
this._resetFns = []
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the sandbox.
|
|
||||||
*/
|
|
||||||
async reset () {
|
|
||||||
for (const resetFn of this._resetFns) {
|
|
||||||
await resetFn()
|
|
||||||
}
|
|
||||||
this._resetFns = []
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will serve the content of file at `filePath` to network requests towards
|
|
||||||
* `protocolName` scheme.
|
|
||||||
*
|
|
||||||
* Example: `sandbox.serveFileFromProtocol('foo', 'index.html')` will serve the content
|
|
||||||
* of 'index.html' to `foo://page` requests.
|
|
||||||
*
|
|
||||||
* @param {string} protocolName
|
|
||||||
* @param {string} filePath
|
|
||||||
*/
|
|
||||||
serveFileFromProtocol (protocolName, filePath) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.protocol.registerBufferProtocol(protocolName, (request, callback) => {
|
|
||||||
// Disabled due to false positive in StandardJS
|
|
||||||
// eslint-disable-next-line standard/no-callback-literal
|
|
||||||
callback({
|
|
||||||
mimeType: 'text/html',
|
|
||||||
data: fs.readFileSync(filePath)
|
|
||||||
})
|
|
||||||
}, (error) => {
|
|
||||||
if (error != null) {
|
|
||||||
reject(error)
|
|
||||||
} else {
|
|
||||||
this._resetFns.push(() => this.unregisterProtocol(protocolName))
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
unregisterProtocol (protocolName) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.protocol.unregisterProtocol(protocolName, (error) => {
|
|
||||||
if (error != null) {
|
|
||||||
reject(error)
|
|
||||||
} else {
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will create a NetworkSandbox that uses
|
|
||||||
* `protocol` as `Electron.Protocol`.
|
|
||||||
*
|
|
||||||
* @param {Electron.Protocol} protocol
|
|
||||||
*/
|
|
||||||
function createNetworkSandbox (protocol) {
|
|
||||||
return new NetworkSandbox(protocol)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.createNetworkSandbox = createNetworkSandbox
|
|
|
@ -34,9 +34,6 @@ process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
process.stdout
|
process.stdout
|
||||||
|
|
||||||
// Adding a variable for sandbox process.env test validation
|
|
||||||
process.env.sandboxmain = ''
|
|
||||||
|
|
||||||
// Access console to reproduce #3482.
|
// Access console to reproduce #3482.
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
console
|
console
|
||||||
|
@ -231,18 +228,6 @@ ipcMain.on('prevent-next-new-window', (event, id) => {
|
||||||
webContents.fromId(id).once('new-window', event => event.preventDefault())
|
webContents.fromId(id).once('new-window', event => event.preventDefault())
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('set-options-on-next-new-window', (event, id, key, value) => {
|
|
||||||
webContents.fromId(id).once('new-window', (event, url, frameName, disposition, options) => {
|
|
||||||
options[key] = value
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('set-web-preferences-on-next-new-window', (event, id, key, value) => {
|
|
||||||
webContents.fromId(id).once('new-window', (event, url, frameName, disposition, options) => {
|
|
||||||
options.webPreferences[key] = value
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('prevent-next-will-attach-webview', (event) => {
|
ipcMain.on('prevent-next-will-attach-webview', (event) => {
|
||||||
event.sender.once('will-attach-webview', event => event.preventDefault())
|
event.sender.once('will-attach-webview', event => event.preventDefault())
|
||||||
})
|
})
|
||||||
|
|
2
typings/internal-ambient.d.ts
vendored
2
typings/internal-ambient.d.ts
vendored
|
@ -40,6 +40,8 @@ declare namespace NodeJS {
|
||||||
|
|
||||||
// Additional properties
|
// Additional properties
|
||||||
_firstFileName?: string;
|
_firstFileName?: string;
|
||||||
|
|
||||||
|
helperExecPath: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue