2024-12-12 09:11:58 -03:00
|
|
|
// Flags: --permission --allow-wasi --allow-fs-read=*
|
2024-06-01 10:13:12 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
2025-01-22 14:19:38 -08:00
|
|
|
const { isMainThread } = require('worker_threads');
|
|
|
|
|
|
|
|
if (!isMainThread) {
|
|
|
|
common.skip('This test only works on a main thread');
|
|
|
|
}
|
2024-06-01 10:13:12 -03:00
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const { WASI } = require('wasi');
|
|
|
|
|
|
|
|
// Guarantee the initial state
|
|
|
|
{
|
|
|
|
assert.ok(process.permission.has('wasi'));
|
|
|
|
}
|
|
|
|
|
|
|
|
// When a permission is set by cli, the process shouldn't be able
|
|
|
|
// to create WASI instance unless --allow-wasi is sent
|
|
|
|
{
|
|
|
|
// doesNotThrow
|
|
|
|
new WASI({
|
|
|
|
version: 'preview1',
|
|
|
|
});
|
|
|
|
}
|