fix: make protocol wrapper remote-friendly again (#27009)
This commit is contained in:
parent
9eab298779
commit
998f17ee59
2 changed files with 16 additions and 2 deletions
|
@ -17,8 +17,12 @@ Object.setPrototypeOf(protocol, new Proxy({}, {
|
||||||
|
|
||||||
ownKeys () {
|
ownKeys () {
|
||||||
if (!app.isReady()) return [];
|
if (!app.isReady()) return [];
|
||||||
|
return Reflect.ownKeys(session.defaultSession!.protocol);
|
||||||
|
},
|
||||||
|
|
||||||
return Object.getOwnPropertyNames(Object.getPrototypeOf(session.defaultSession!.protocol));
|
has: (target, property: string) => {
|
||||||
|
if (!app.isReady()) return false;
|
||||||
|
return Reflect.has(session.defaultSession!.protocol, property);
|
||||||
},
|
},
|
||||||
|
|
||||||
getOwnPropertyDescriptor () {
|
getOwnPropertyDescriptor () {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ipcMain, BrowserWindow } from 'electron/main';
|
||||||
import { emittedOnce } from './events-helpers';
|
import { emittedOnce } from './events-helpers';
|
||||||
import { NativeImage } from 'electron/common';
|
import { NativeImage } from 'electron/common';
|
||||||
import { serialize, deserialize } from '../lib/common/type-utils';
|
import { serialize, deserialize } from '../lib/common/type-utils';
|
||||||
import { nativeImage } from 'electron';
|
import { protocol, nativeImage } from 'electron';
|
||||||
|
|
||||||
const features = process._linkedBinding('electron_common_features');
|
const features = process._linkedBinding('electron_common_features');
|
||||||
|
|
||||||
|
@ -641,6 +641,16 @@ ifdescribe(features.isRemoteModuleEnabled())('remote module', () => {
|
||||||
const { functionWithToStringProperty } = require('electron').remote.require(path.join(fixtures, 'to-string-non-function.js'));
|
const { functionWithToStringProperty } = require('electron').remote.require(path.join(fixtures, 'to-string-non-function.js'));
|
||||||
expect(functionWithToStringProperty.toString).to.equal('hello');
|
expect(functionWithToStringProperty.toString).to.equal('hello');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const protocolKeys = Object.getOwnPropertyNames(protocol);
|
||||||
|
remotely.it(protocolKeys)('remote.protocol returns all keys', (protocolKeys: [string]) => {
|
||||||
|
const protocol = require('electron').remote.protocol;
|
||||||
|
const remoteKeys = Object.getOwnPropertyNames(protocol);
|
||||||
|
expect(remoteKeys).to.deep.equal(protocolKeys);
|
||||||
|
for (const key of remoteKeys) {
|
||||||
|
expect(typeof (protocol as any)[key]).to.equal('function');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('remote object in renderer', () => {
|
describe('remote object in renderer', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue