fix: check for Node.js-created module when contextIsolation disabled (#40993)

This commit is contained in:
Shelley Vohr 2024-01-16 14:29:00 +01:00 committed by GitHub
parent 4949c4c4e1
commit 6803624576
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 97 additions and 10 deletions

View file

@ -141,7 +141,7 @@ describe('esm', () => {
const hostsUrl = pathToFileURL(process.platform === 'win32' ? 'C:\\Windows\\System32\\drivers\\etc\\hosts' : '/etc/hosts');
describe('without context isolation', () => {
it('should use blinks dynamic loader in the main world', async () => {
it('should use Blinks dynamic loader in the main world', async () => {
const [webContents] = await loadWindowWithPreload('', {
nodeIntegration: true,
sandbox: false,
@ -159,6 +159,11 @@ describe('esm', () => {
// This is a blink specific error message
expect(error?.message).to.include('Failed to fetch dynamically imported module');
});
it('should use import.meta callback handling from Node.js for Node.js modules', async () => {
const result = await runFixture(path.resolve(fixturePath, 'import-meta'));
expect(result.code).to.equal(0);
});
});
describe('with context isolation', () => {
@ -173,7 +178,7 @@ describe('esm', () => {
await fs.promises.unlink(badFilePath);
});
it('should use nodes esm dynamic loader in the isolated context', async () => {
it('should use Node.js ESM dynamic loader in the isolated context', async () => {
const [, preloadError] = await loadWindowWithPreload(`await import(${JSON.stringify((pathToFileURL(badFilePath)))})`, {
nodeIntegration: true,
sandbox: false,
@ -185,7 +190,7 @@ describe('esm', () => {
expect(preloadError!.toString()).to.include('Unknown file extension');
});
it('should use blinks dynamic loader in the main world', async () => {
it('should use Blinks dynamic loader in the main world', async () => {
const [webContents] = await loadWindowWithPreload('', {
nodeIntegration: true,
sandbox: false,