зеркало из https://github.com/electron/electron.git
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:
Родитель
7249b25868
Коммит
27599a851f
|
@ -1013,6 +1013,10 @@ Returns [`Rectangle`](structures/rectangle.md) - Contains the window bounds of t
|
|||
|
||||
Disable or enable the window.
|
||||
|
||||
#### `win.isEnabled()`
|
||||
|
||||
Returns Boolean - whether the window is enabled.
|
||||
|
||||
#### `win.setSize(width, height[, animate])`
|
||||
|
||||
* `width` Integer
|
||||
|
@ -1625,7 +1629,7 @@ On macOS it does not remove the focus from the window.
|
|||
|
||||
#### `win.setParentWindow(parent)`
|
||||
|
||||
* `parent` BrowserWindow
|
||||
* `parent` BrowserWindow | null
|
||||
|
||||
Sets `parent` as current window's parent window, passing `null` will turn
|
||||
current window into a top-level window.
|
||||
|
|
|
@ -218,14 +218,12 @@ int SystemPreferences::DoSubscribeNotification(
|
|||
|
||||
if (user_info) {
|
||||
copied_callback.Run(
|
||||
base::SysNSStringToUTF8(notification.name),
|
||||
*user_info,
|
||||
base::SysNSStringToUTF8(notification.name), *user_info,
|
||||
object);
|
||||
} else {
|
||||
copied_callback.Run(
|
||||
base::SysNSStringToUTF8(notification.name),
|
||||
base::DictionaryValue(),
|
||||
object);
|
||||
base::DictionaryValue(), object);
|
||||
}
|
||||
}];
|
||||
return request_id;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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
|
||||
process.stdout
|
||||
|
||||
// Adding a variable for sandbox process.env test validation
|
||||
process.env.sandboxmain = ''
|
||||
|
||||
// Access console to reproduce #3482.
|
||||
// eslint-disable-next-line
|
||||
console
|
||||
|
@ -231,18 +228,6 @@ ipcMain.on('prevent-next-new-window', (event, id) => {
|
|||
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) => {
|
||||
event.sender.once('will-attach-webview', event => event.preventDefault())
|
||||
})
|
||||
|
|
|
@ -40,6 +40,8 @@ declare namespace NodeJS {
|
|||
|
||||
// Additional properties
|
||||
_firstFileName?: string;
|
||||
|
||||
helperExecPath: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче