mongo/jstests/noPassthrough/shell/js/module_loader.js
Matt Broadstone 41b16e48d9 SERVER-126888: Add a high-resolution timer for perf testing in jstests (#53877)
Co-authored-by: Steve McClure <steve.mcclure@mongodb.com>
Co-authored-by: Teo Voinea <teo.voinea@mongodb.com>
GitOrigin-RevId: e91b166957c79f6576efe2c6fbf6d796a9636905
2026-05-20 18:14:42 +00:00

24 lines
911 B
JavaScript

import {describe, it} from "jstests/libs/mochalite.js";
describe("module loader internal binding restrictions", function () {
it("does not allow scripts to import internal bindings as ES modules", async function () {
let importError = null;
try {
await import("performance");
} catch (error) {
importError = error;
}
assert.neq(importError, null, "scripts should not import internal bindings as ES modules");
});
it("prevents non-std modules from calling internalModule()", function () {
let callError = assert.throws(() => internalModule("performance"));
assert.neq(callError, null, "non-std modules should not call internalModule()");
assert(
callError.message.includes("restricted to std:* modules"),
`unexpected internalModule error: ${callError.message}`,
);
});
});