mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
docs: fix some string union type (#39293)
* docs: fix some string union types Improve Type Union Typings in the Docs Co-authored-by: mhli <mhli@hillinsight.com> * test: add smoke tests Co-authored-by: mhli <mhli@hillinsight.com> * test: update `ses.clearStorageData` test case Co-authored-by: mhli <mhli@hillinsight.com> * test: update `ses.clearStorageData` test case Co-authored-by: mhli <mhli@hillinsight.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: mhli <mhli@hillinsight.com>
This commit is contained in:
@@ -252,12 +252,11 @@ describe('session module', () => {
|
||||
it('clears localstorage data', async () => {
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true } });
|
||||
await w.loadFile(path.join(fixtures, 'api', 'localstorage.html'));
|
||||
const options = {
|
||||
await w.webContents.session.clearStorageData({
|
||||
origin: 'file://',
|
||||
storages: ['localstorage'],
|
||||
quotas: ['persistent']
|
||||
};
|
||||
await w.webContents.session.clearStorageData(options);
|
||||
quotas: ['temporary']
|
||||
});
|
||||
while (await w.webContents.executeJavaScript('localStorage.length') !== 0) {
|
||||
// The storage clear isn't instantly visible to the renderer, so keep
|
||||
// trying until it is.
|
||||
|
||||
@@ -526,6 +526,10 @@ dialog.showMessageBoxSync(win3, { message: 'test', type: 'foo' });
|
||||
|
||||
ipcMain.handle('get-sources', (event, options) => desktopCapturer.getSources(options));
|
||||
|
||||
desktopCapturer.getSources({ types: ['window', 'screen'] });
|
||||
// @ts-expect-error Invalid type value
|
||||
desktopCapturer.getSources({ types: ['unknown'] });
|
||||
|
||||
// global-shortcut
|
||||
// https://github.com/electron/electron/blob/main/docs/api/global-shortcut.md
|
||||
|
||||
@@ -1029,6 +1033,12 @@ appIcon4.destroy();
|
||||
const image2 = nativeImage.createFromPath('/Users/somebody/images/icon.png');
|
||||
console.log(image2.getSize());
|
||||
|
||||
image2.resize({ quality: 'best' });
|
||||
image2.resize({ quality: 'better' });
|
||||
image2.resize({ quality: 'good' });
|
||||
// @ts-expect-error Invalid type value
|
||||
image2.resize({ quality: 'bad' });
|
||||
|
||||
// process
|
||||
// https://github.com/electron/electron/blob/main/docs/api/process.md
|
||||
|
||||
@@ -1132,6 +1142,16 @@ shell.writeShortcutLink('/home/user/Desktop/shortcut.lnk', 'update', shell.readS
|
||||
// session
|
||||
// https://github.com/electron/electron/blob/main/docs/api/session.md
|
||||
|
||||
session.defaultSession.clearStorageData({ storages: ['cookies', 'filesystem'] });
|
||||
session.defaultSession.clearStorageData({ storages: ['localstorage', 'indexdb', 'serviceworkers'] });
|
||||
session.defaultSession.clearStorageData({ storages: ['shadercache', 'websql', 'cachestorage'] });
|
||||
// @ts-expect-error Invalid type value
|
||||
session.defaultSession.clearStorageData({ storages: ['wrong_path'] });
|
||||
|
||||
session.defaultSession.clearStorageData({ quotas: ['syncable', 'temporary'] });
|
||||
// @ts-expect-error Invalid type value
|
||||
session.defaultSession.clearStorageData({ quotas: ['bad_type'] });
|
||||
|
||||
session.defaultSession.on('will-download', (event, item, webContents) => {
|
||||
console.log('will-download', webContents.id);
|
||||
event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user