GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing patch-diff.githubusercontent.com — patch-diff.githubusercontent.com diff --git a/test/es-module/test-esm-loader-mock.mjs b/test/es-module/test-esm-loader-mock.mjs
deleted file mode 100644
index 2783bf694d23..000000000000
--- a/test/es-module/test-esm-loader-mock.mjs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Flags: --loader ./test/fixtures/es-module-loaders/mock-loader.mjs
-import '../common/index.mjs';
-import assert from 'assert/strict';
-
-// This is provided by test/fixtures/es-module-loaders/mock-loader.mjs
-import mock from 'node:mock';
-
-mock('node:events', {
- EventEmitter: 'This is mocked!'
-});
-
-// This resolves to node:events
-// It is intercepted by mock-loader and doesn't return the normal value
-assert.deepStrictEqual(await import('events'), Object.defineProperty({
- __proto__: null,
- EventEmitter: 'This is mocked!'
-}, Symbol.toStringTag, {
- enumerable: false,
- value: 'Module'
-}));
-
-const mutator = mock('node:events', {
- EventEmitter: 'This is mocked v2!'
-});
-
-// It is intercepted by mock-loader and doesn't return the normal value.
-// This is resolved separately from the import above since the specifiers
-// are different.
-const mockedV2 = await import('node:events');
-assert.deepStrictEqual(mockedV2, Object.defineProperty({
- __proto__: null,
- EventEmitter: 'This is mocked v2!'
-}, Symbol.toStringTag, {
- enumerable: false,
- value: 'Module'
-}));
-
-mutator.EventEmitter = 'This is mocked v3!';
-assert.deepStrictEqual(mockedV2, Object.defineProperty({
- __proto__: null,
- EventEmitter: 'This is mocked v3!'
-}, Symbol.toStringTag, {
- enumerable: false,
- value: 'Module'
-}));
diff --git a/test/fixtures/es-module-loaders/mock-loader.mjs b/test/fixtures/es-module-loaders/mock-loader.mjs
deleted file mode 100644
index 062be39603e8..000000000000
--- a/test/fixtures/es-module-loaders/mock-loader.mjs
+++ /dev/null
@@ -1,249 +0,0 @@
-import { receiveMessageOnPort } from 'node:worker_threads';
-const mockedModuleExports = new Map();
-let currentMockVersion = 0;
-
-// This loader causes a new module `node:mock` to become available as a way to
-// swap module resolution results for mocking purposes. It uses this instead
-// of import.meta so that CommonJS can still use the functionality.
-//
-// It does so by allowing non-mocked modules to live in normal URL cache
-// locations but creates 'mock-facade:' URL cache location for every time a
-// module location is mocked. Since a single URL can be mocked multiple
-// times but it cannot be removed from the cache, `mock-facade:` URLs have a
-// form of mock-facade:$VERSION:$REPLACING_URL with the parameters being URL
-// percent encoded every time a module is resolved. So if a module for
-// 'file:///app.js' is mocked it might look like
-// 'mock-facade:12:file%3A%2F%2F%2Fapp.js'. This encoding is done to prevent
-// problems like mocking URLs with special URL characters like '#' or '?' from
-// accidentally being picked up as part of the 'mock-facade:' URL containing
-// the mocked URL.
-//
-// NOTE: due to ESM spec, once a specifier has been resolved in a source text
-// it cannot be changed. So things like the following DO NOT WORK:
-//
-// ```mjs
-// import mock from 'node:mock';
-// mock('file:///app.js', {x:1});
-// const namespace1 = await import('file:///app.js');
-// namespace1.x; // 1
-// mock('file:///app.js', {x:2});
-// const namespace2 = await import('file:///app.js');
-// namespace2.x; // STILL 1, because this source text already set the specifier
-// // for 'file:///app.js', a different specifier that resolves
-// // to that could still get a new namespace though
-// assert(namespace1 === namespace2);
-// ```
-
-/**
- * FIXME: this is a hack to workaround loaders being
- * single threaded for now, just ensures that the MessagePort drains
- */
-function doDrainPort() {
- let msg;
- while (msg = receiveMessageOnPort(preloadPort)) {
- onPreloadPortMessage(msg.message);
- }
-}
-
-/**
- * @param param0 message from the application context
- */
-function onPreloadPortMessage({
- mockVersion, resolved, exports
-}) {
- currentMockVersion = mockVersion;
- mockedModuleExports.set(resolved, exports);
-}
-let preloadPort;
-export function globalPreload({port}) {
- // Save the communication port to the application context to send messages
- // to it later
- preloadPort = port;
- // Every time the application context sends a message over the port
- port.on('message', onPreloadPortMessage);
- // This prevents the port that the Loader/application talk over
- // from keeping the process alive, without this, an application would be kept
- // alive just because a loader is waiting for messages
- port.unref();
-
- const insideAppContext = (getBuiltin, port, setImportMetaCallback) => {
- /**
- * This is the Map that saves *all* the mocked URL -> replacement Module
- * mappings
- * @type {Map |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |