Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-escape-import-names.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that import names are properly escaped
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-escape-import-names.mjs')],
{ stdout: '', stderr: '', trim: true }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-globals-all-types.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that all WebAssembly global types are properly handled
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-globals-all-types.mjs')],
{ stdout: '', stderr: '', trim: true }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-js-string-builtins.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that js-string builtins are supported
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-js-string-builtins.mjs')],
{ stdout: '', stderr: '', trim: true }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-load-exports.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that WASM modules can load and export functions correctly
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-load-exports.mjs')],
{ stdout: '', stderr: '', trim: true }
);
17 changes: 17 additions & 0 deletions test/es-module/test-esm-wasm-module-instances-warning.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Test that experimental warning is emitted for WASM module instances
import '../common/index.mjs';
import assert from 'node:assert';

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

spawnSyncAndAssert(
process.execPath,
[fixtures.path('es-modules/wasm-modules.mjs')],
{
stderr(output) {
assert.match(output, /ExperimentalWarning/);
assert.match(output, /Importing WebAssembly module instances/);
}
}
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-no-code-injection.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that code injection through export names is not allowed
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/export-name-code-injection.wasm')],
{ stdout: '', stderr: '', trim: true }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-non-identifier-exports.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that WASM modules can have non-identifier export names
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-non-identifier-exports.mjs')],
{ stdout: '', stderr: '', trim: true }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-reject-wasm-export-names.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test WASM module with invalid export name starting with 'wasm:'
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-reject-wasm-export-names.mjs')],
{ status: 1, stderr: /Invalid Wasm export/ }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-reject-wasm-import-names.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test WASM module with invalid import name starting with 'wasm:'
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-reject-wasm-import-names.mjs')],
{ status: 1, stderr: /Invalid Wasm import name/ }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-reject-wasm-js-export-names.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test WASM module with invalid export name starting with 'wasm-js:'
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-reject-wasm-js-export-names.mjs')],
{ status: 1, stderr: /Invalid Wasm export/ }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-reject-wasm-js-import-module.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test WASM module with invalid import module name starting with 'wasm-js:'
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-reject-wasm-js-import-module.mjs')],
{ status: 1, stderr: /Invalid Wasm import/ }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-reject-wasm-js-import-names.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test WASM module with invalid import name starting with 'wasm-js:'
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-reject-wasm-js-import-names.mjs')],
{ status: 1, stderr: /Invalid Wasm import name/ }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-source-phase-dynamic.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that dynamic source phase imports are supported
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-source-phase-dynamic.mjs')],
{ stdout: '', stderr: '', trim: true }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-source-phase-no-execute-dynamic.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that dynamic source phase imports don't execute
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-source-phase-no-execute-dynamic.mjs')],
{ stdout: '', stderr: '', trim: true }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-source-phase-no-execute.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that source phase imports don't execute
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-source-phase-no-execute.mjs')],
{ stdout: '', stderr: '', trim: true }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-source-phase-not-defined-dynamic.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that error is thrown for dynamic source phase imports not defined
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-source-phase-not-defined-dynamic.mjs')],
{ stdout: '', stderr: '', trim: true }
);
19 changes: 19 additions & 0 deletions test/es-module/test-esm-wasm-source-phase-not-defined-static.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Test that error is thrown for static source phase imports not defined
import '../common/index.mjs';
import assert from 'node:assert';

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

const fileUrl = fixtures.fileURL('es-modules/wasm-source-phase.js').href;
spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-source-phase-not-defined-static.mjs')],
{
status: 1,
stderr(output) {
assert.match(output, /Source phase import object is not defined for module/);
assert(output.includes(fileUrl));
}
}
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-source-phase-static.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that static source phase imports are supported
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/test-wasm-source-phase-static.mjs')],
{ stdout: '', stderr: '', trim: true }
);
14 changes: 14 additions & 0 deletions test/es-module/test-esm-wasm-top-level-execution.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test that WASM modules support top-level execution
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', fixtures.path('es-modules/top-level-wasm.wasm')],
{
stdout: '[Object: null prototype] { prop: \'hello world\' }',
stderr: '',
trim: true
}
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-vm-source-phase-dynamic.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that error is thrown for vm source phase dynamic import
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', '--experimental-vm-modules', fixtures.path('es-modules/test-wasm-vm-source-phase-dynamic.mjs')],
{ status: 1, stderr: /Source phase import object is not defined for module/ }
);
10 changes: 10 additions & 0 deletions test/es-module/test-esm-wasm-vm-source-phase-static.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that error is thrown for vm source phase static import
import '../common/index.mjs';
import { spawnSyncAndAssert } from '../common/child_process.js';
import * as fixtures from '../common/fixtures.js';

spawnSyncAndAssert(
process.execPath,
['--no-warnings', '--experimental-vm-modules', fixtures.path('es-modules/test-wasm-vm-source-phase-static.mjs')],
{ status: 1, stderr: /Source phase import object is not defined for module/ }
);
Loading
Loading