[MM-61271] Upgrade to Electron v33.0.2 (#3181)
* [MM-61271] Upgrade to Electron v33.0.2 * Fix node-abi * Fix and patch nan
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// See LICENSE.txt for license information.
|
||||
'use strict';
|
||||
|
||||
import type {MenuItemConstructorOptions, MenuItem, BrowserWindow} from 'electron';
|
||||
import type {MenuItemConstructorOptions, MenuItem} from 'electron';
|
||||
import {app, ipcMain, Menu, session, shell, clipboard} from 'electron';
|
||||
import log from 'electron-log';
|
||||
|
||||
@@ -149,14 +149,16 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
|
||||
}
|
||||
return 'Ctrl+Shift+I';
|
||||
})(),
|
||||
click(item: Electron.MenuItem, focusedWindow?: BrowserWindow) {
|
||||
if (focusedWindow) {
|
||||
// toggledevtools opens it in the last known position, so sometimes it goes below the browserview
|
||||
if (focusedWindow.webContents.isDevToolsOpened()) {
|
||||
focusedWindow.webContents.closeDevTools();
|
||||
} else {
|
||||
focusedWindow.webContents.openDevTools({mode: 'detach'});
|
||||
}
|
||||
click() {
|
||||
const mainWindow = MainWindow.get();
|
||||
if (!mainWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainWindow.webContents.isDevToolsOpened()) {
|
||||
mainWindow.webContents.closeDevTools();
|
||||
} else {
|
||||
mainWindow.webContents.openDevTools({mode: 'detach'});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@@ -25,12 +25,14 @@ jest.mock('electron', () => ({
|
||||
on: jest.fn(),
|
||||
getTitle: () => 'title',
|
||||
getURL: () => 'http://server-1.com',
|
||||
clearHistory: jest.fn(),
|
||||
send: jest.fn(),
|
||||
canGoBack: jest.fn(),
|
||||
canGoForward: jest.fn(),
|
||||
goToOffset: jest.fn(),
|
||||
canGoToOffset: jest.fn(),
|
||||
navigationHistory: {
|
||||
clear: jest.fn(),
|
||||
canGoBack: jest.fn(),
|
||||
canGoForward: jest.fn(),
|
||||
goToOffset: jest.fn(),
|
||||
canGoToOffset: jest.fn(),
|
||||
},
|
||||
},
|
||||
})),
|
||||
ipcMain: {
|
||||
@@ -206,18 +208,18 @@ describe('main/views/MattermostBrowserView', () => {
|
||||
});
|
||||
|
||||
it('should only go to offset if it can', () => {
|
||||
mattermostView.browserView.webContents.canGoToOffset.mockReturnValue(false);
|
||||
mattermostView.browserView.webContents.navigationHistory.canGoToOffset.mockReturnValue(false);
|
||||
mattermostView.goToOffset(1);
|
||||
expect(mattermostView.browserView.webContents.goToOffset).not.toBeCalled();
|
||||
expect(mattermostView.browserView.webContents.navigationHistory.goToOffset).not.toBeCalled();
|
||||
|
||||
mattermostView.browserView.webContents.canGoToOffset.mockReturnValue(true);
|
||||
mattermostView.browserView.webContents.navigationHistory.canGoToOffset.mockReturnValue(true);
|
||||
mattermostView.goToOffset(1);
|
||||
expect(mattermostView.browserView.webContents.goToOffset).toBeCalled();
|
||||
expect(mattermostView.browserView.webContents.navigationHistory.goToOffset).toBeCalled();
|
||||
});
|
||||
|
||||
it('should call reload if an error occurs', () => {
|
||||
mattermostView.browserView.webContents.canGoToOffset.mockReturnValue(true);
|
||||
mattermostView.browserView.webContents.goToOffset.mockImplementation(() => {
|
||||
mattermostView.browserView.webContents.navigationHistory.canGoToOffset.mockReturnValue(true);
|
||||
mattermostView.browserView.webContents.navigationHistory.goToOffset.mockImplementation(() => {
|
||||
throw new Error('hi');
|
||||
});
|
||||
mattermostView.goToOffset(1);
|
||||
@@ -355,7 +357,7 @@ describe('main/views/MattermostBrowserView', () => {
|
||||
it('should erase history and set isAtRoot when navigating to root URL', () => {
|
||||
mattermostView.atRoot = false;
|
||||
mattermostView.updateHistoryButton();
|
||||
expect(mattermostView.browserView.webContents.clearHistory).toHaveBeenCalled();
|
||||
expect(mattermostView.browserView.webContents.navigationHistory.clear).toHaveBeenCalled();
|
||||
expect(mattermostView.isAtRoot).toBe(true);
|
||||
});
|
||||
});
|
||||
|
@@ -149,9 +149,9 @@ export class MattermostBrowserView extends EventEmitter {
|
||||
};
|
||||
|
||||
goToOffset = (offset: number) => {
|
||||
if (this.browserView.webContents.canGoToOffset(offset)) {
|
||||
if (this.browserView.webContents.navigationHistory.canGoToOffset(offset)) {
|
||||
try {
|
||||
this.browserView.webContents.goToOffset(offset);
|
||||
this.browserView.webContents.navigationHistory.goToOffset(offset);
|
||||
this.updateHistoryButton();
|
||||
} catch (error) {
|
||||
this.log.error(error);
|
||||
@@ -162,15 +162,15 @@ export class MattermostBrowserView extends EventEmitter {
|
||||
|
||||
getBrowserHistoryStatus = () => {
|
||||
if (this.currentURL?.toString() === this.view.url.toString()) {
|
||||
this.browserView.webContents.clearHistory();
|
||||
this.browserView.webContents.navigationHistory.clear();
|
||||
this.atRoot = true;
|
||||
} else {
|
||||
this.atRoot = false;
|
||||
}
|
||||
|
||||
return {
|
||||
canGoBack: this.browserView.webContents.canGoBack(),
|
||||
canGoForward: this.browserView.webContents.canGoForward(),
|
||||
canGoBack: this.browserView.webContents.navigationHistory.canGoBack(),
|
||||
canGoForward: this.browserView.webContents.navigationHistory.canGoForward(),
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user