refactor: use node scheme imports in spec (#38487)

Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
Milan Burda 2023-06-15 16:42:27 +02:00 committed by GitHub
parent bf1ba4a857
commit d78f37ec8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
105 changed files with 533 additions and 352 deletions

View file

@ -2,14 +2,14 @@ import { BrowserWindow, ipcMain } from 'electron/main';
import { contextBridge } from 'electron/renderer';
import { expect } from 'chai';
import * as fs from 'fs-extra';
import * as http from 'http';
import * as os from 'os';
import * as path from 'path';
import * as cp from 'child_process';
import * as http from 'node:http';
import * as os from 'node:os';
import * as path from 'node:path';
import * as cp from 'node:child_process';
import { closeWindow } from './lib/window-helpers';
import { listen } from './lib/spec-helpers';
import { once } from 'events';
import { once } from 'node:events';
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'context-bridge');
@ -67,16 +67,16 @@ describe('contextBridge', () => {
describe(`with sandbox=${useSandbox}`, () => {
const makeBindingWindow = async (bindingCreator: Function, worldId: number = 0) => {
const preloadContentForMainWorld = `const renderer_1 = require('electron');
${useSandbox ? '' : `require('v8').setFlagsFromString('--expose_gc');
const gc=require('vm').runInNewContext('gc');
${useSandbox ? '' : `require('node:v8').setFlagsFromString('--expose_gc');
const gc=require('node:vm').runInNewContext('gc');
renderer_1.contextBridge.exposeInMainWorld('GCRunner', {
run: () => gc()
});`}
(${bindingCreator.toString()})();`;
const preloadContentForIsolatedWorld = `const renderer_1 = require('electron');
${useSandbox ? '' : `require('v8').setFlagsFromString('--expose_gc');
const gc=require('vm').runInNewContext('gc');
${useSandbox ? '' : `require('node:v8').setFlagsFromString('--expose_gc');
const gc=require('node:vm').runInNewContext('gc');
renderer_1.webFrame.setIsolatedWorldInfo(${worldId}, {
name: "Isolated World"
});