Repository: electron/fiddle (ts)

Issue:
Remove usage of Electron `remote` 
In Electron from version 10 `enableRemoteModule` default value changed to `false`. This issue created to track replacing the `remote` import by the `IPC` layer.

1. [x] [`src/renderer/components/show-me/app.tsx`] (https://github.com/electron/fiddle/blob/374a85e2f65c5acf99f62001ade139ae0e29e441/src/renderer/components/show-me/app.tsx) (Need to figure where it's used)
	- https://github.com/electron/fiddle/blob/374a85e2f65c5acf99f62001ade139ae0e29e441/src/renderer/components/show-me/app.tsx#L18
	- https://github.com/electron/fiddle/blob/374a85e2f65c5acf99f62001ade139ae0e29e441/src/renderer/components/show-me/app.tsx#L20
	- https://github.com/electron/fiddle/blob/374a85e2f65c5acf99f62001ade139ae0e29e441/src/renderer/components/show-me/app.tsx#L21
	- https://github.com/electron/fiddle/blob/374a85e2f65c5acf99f62001ade139ae0e29e441/src/renderer/components/show-me/app.tsx#L45
	- https://github.com/electron/fiddle/blob/374a85e2f65c5acf99f62001ade139ae0e29e441/src/renderer/components/show-me/app.tsx#L63
	- https://github.com/electron/fiddle/blob/374a85e2f65c5acf99f62001ade139ae0e29e441/src/renderer/components/show-me/app.tsx#L71
2. [x] [`src/renderer/components/chrome-mac.tsx`](https://github.com/electron/fiddle/blob/dca2cd67e545dbe39ca705db526c7325eb25a111/src/renderer/components/chrome-mac.tsx) (See #598)
	- https://github.com/electron/fiddle/blob/dca2cd67e545dbe39ca705db526c7325eb25a111/src/renderer/components/chrome-mac.tsx#L15
	- https://github.com/electron/fiddle/blob/dca2cd67e545dbe39ca705db526c7325eb25a111/src/renderer/components/chrome-mac.tsx#L16
3. [x] [`src/renderer/constants.ts`](https://github.com/electron/fiddle/blob/b98472f973ecb60dd4f2fe07b94be4ae3d658cef/src/renderer/constants.ts)
	- https://github.com/electron/fiddle/blob/b98472f973ecb60dd4f2fe07b94be4ae3d658cef/src/renderer/constants.ts#L10
	- https://github.com/electron/fiddle/blob/b98472f973ecb60dd4f2fe07b94be4ae3d658cef/src/renderer/constants.ts#L11
4. [x] [`src/utils/app-data-dir.ts`](https://github.com/electron/fiddle/blob/66536a52609b066c44f7069e90e5df2cf131c0ea/src/utils/app-data-dir.ts) (See #430)
	- https://github.com/electron/fiddle/blob/66536a52609b066c44f7069e90e5df2cf131c0ea/src/utils/app-data-dir.ts#L14
5. [x] [`src/renderer/touch-bar-manager.ts`](https://github.com/electron/fiddle/blob/98a358b75630c2ba025f26bb9056e99d7f295a7e/src/renderer/touch-bar-manager.ts) (See #562)
	- https://github.com/electron/fiddle/blob/98a358b75630c2ba025f26bb9056e99d7f295a7e/src/renderer/touch-bar-manager.ts#L13
	- https://github.com/electron/fiddle/blob/98a358b75630c2ba025f26bb9056e99d7f295a7e/src/renderer/touch-bar-manager.ts#L130
6. [x] [`src/renderer/state.ts`](https://github.com/electron/fiddle/blob/b98472f973ecb60dd4f2fe07b94be4ae3d658cef/src/renderer/state.ts) (See #423)
	- https://github.com/electron/fiddle/blob/b98472f973ecb60dd4f2fe07b94be4ae3d658cef/src/renderer/state.ts#L191
	- https://github.com/electron/fiddle/blob/b98472f973ecb60dd4f2fe07b94be4ae3d658cef/src/renderer/state.ts#L192
	- https://github.com/electron/fiddle/blob/b98472f973ecb60dd4f2fe07b94be4ae3d658cef/src/renderer/state.ts#L195

Pull request description:
chore: disable remote module
Closes #418.



Patch:
diff --git a/src/main/windows.ts b/src/main/windows.ts
index 3fd38a6a..843726fb 100644
--- a/src/main/windows.ts
+++ b/src/main/windows.ts
@@ -25,7 +25,6 @@ export function getMainWindowOptions(): Electron.BrowserWindowConstructorOptions
     webPreferences: {
       webviewTag: false,
       nodeIntegration: true,
-      enableRemoteModule: true,
       nodeIntegrationInWorker: true,
       contextIsolation: false,
       preload: path.join(__dirname, '..', 'preload', 'preload'),


Test patch:
diff --git a/tests/main/windows-spec.ts b/tests/main/windows-spec.ts
index 85136566..43ef6cae 100644
--- a/tests/main/windows-spec.ts
+++ b/tests/main/windows-spec.ts
@@ -37,7 +37,6 @@ describe('windows', () => {
       titleBarStyle: undefined,
       webPreferences: {
         webviewTag: false,
-        enableRemoteModule: true,
         nodeIntegration: true,
         nodeIntegrationInWorker: true,
         contextIsolation: false,
diff --git a/tests/mocks/electron-fiddle.ts b/tests/mocks/electron-fiddle.ts
index 15e13285..a23733ed 100644
--- a/tests/mocks/electron-fiddle.ts
+++ b/tests/mocks/electron-fiddle.ts
@@ -1,12 +1,11 @@
 import { AppMock } from './app';
 import { EditorsMock } from './editors';
-import * as electron from './electron';
 
 export class ElectronFiddleMock {
   public app = new AppMock();
   public editors = new EditorsMock();
   public appPaths = {
-    userData: (electron as any).remote.app.getPath('userData'),
+    userData: '/fake/path',
     home: `~`,
   };
 }
diff --git a/tests/mocks/electron.ts b/tests/mocks/electron.ts
index a0281fad..7be97bea 100644
--- a/tests/mocks/electron.ts
+++ b/tests/mocks/electron.ts
@@ -209,23 +209,6 @@ const electronMock = {
     interceptHttpProtocol: jest.fn(),
     uninterceptProtocol: jest.fn(),
   },
-  remote: {
-    app,
-    session,
-    BrowserWindow: MockBrowserWindow,
-    getCurrentWindow: jest.fn(),
-    getGlobal: jest.fn(),
-    Menu: MockMenu,
-    MenuItem: MockMenuItem,
-    process: {
-      argv: [
-        '/Applications/Electron Fiddle.app/Contents/MacOS/electron-fiddle',
-      ],
-    },
-    shell,
-    require: jest.fn(),
-    systemPreferences,
-  },
   require: jest.fn(),
   screen: new Screen(),
   session,
@@ -238,6 +221,5 @@ electronMock.BrowserWindow.getAllWindows.mockReturnValue([]);
 electronMock.BrowserWindow.fromId.mockReturnValue(mainWindowStub);
 electronMock.BrowserWindow.fromWebContents.mockReturnValue(mainWindowStub);
 electronMock.BrowserWindow.getFocusedWindow.mockReturnValue(focusedWindowStub);
-electronMock.remote.getCurrentWindow.mockReturnValue(mainWindowStub);
 
 module.exports = electronMock;