test: split test-esm-wasm.js · nodejs/node@2c199f7

40 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test that import names are properly escaped

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/test-wasm-escape-import-names.mjs')],

9+

{ stdout: '', stderr: '', trim: true }

10+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test that all WebAssembly global types are properly handled

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/test-wasm-globals-all-types.mjs')],

9+

{ stdout: '', stderr: '', trim: true }

10+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test that js-string builtins are supported

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/test-wasm-js-string-builtins.mjs')],

9+

{ stdout: '', stderr: '', trim: true }

10+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test that WASM modules can load and export functions correctly

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/test-wasm-load-exports.mjs')],

9+

{ stdout: '', stderr: '', trim: true }

10+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,17 @@

1+

// Test that experimental warning is emitted for WASM module instances

2+

import '../common/index.mjs';

3+

import assert from 'node:assert';

4+
5+

import { spawnSyncAndAssert } from '../common/child_process.js';

6+

import * as fixtures from '../common/fixtures.js';

7+
8+

spawnSyncAndAssert(

9+

process.execPath,

10+

[fixtures.path('es-modules/wasm-modules.mjs')],

11+

{

12+

stderr(output) {

13+

assert.match(output, /ExperimentalWarning/);

14+

assert.match(output, /Importing WebAssembly module instances/);

15+

}

16+

}

17+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test that code injection through export names is not allowed

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/export-name-code-injection.wasm')],

9+

{ stdout: '', stderr: '', trim: true }

10+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test that WASM modules can have non-identifier export names

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/test-wasm-non-identifier-exports.mjs')],

9+

{ stdout: '', stderr: '', trim: true }

10+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test WASM module with invalid export name starting with 'wasm:'

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/test-wasm-reject-wasm-export-names.mjs')],

9+

{ status: 1, stderr: /Invalid Wasm export/ }

10+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test WASM module with invalid import name starting with 'wasm:'

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/test-wasm-reject-wasm-import-names.mjs')],

9+

{ status: 1, stderr: /Invalid Wasm import name/ }

10+

);

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,10 @@

1+

// Test WASM module with invalid export name starting with 'wasm-js:'

2+

import '../common/index.mjs';

3+

import { spawnSyncAndAssert } from '../common/child_process.js';

4+

import * as fixtures from '../common/fixtures.js';

5+
6+

spawnSyncAndAssert(

7+

process.execPath,

8+

['--no-warnings', fixtures.path('es-modules/test-wasm-reject-wasm-js-export-names.mjs')],

9+

{ status: 1, stderr: /Invalid Wasm export/ }

10+

);