From aca33ea3472c5e946d3843751a26ac8af8c9ff88 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Thu, 17 Oct 2024 22:40:24 -0700 Subject: [PATCH] et tu ci --- packages/ses/src-xs/index.js | 12 +++++++----- packages/ses/test/_xs.js | 15 ++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/ses/src-xs/index.js b/packages/ses/src-xs/index.js index 29f4443df7..ad26c6f830 100644 --- a/packages/ses/src-xs/index.js +++ b/packages/ses/src-xs/index.js @@ -66,7 +66,7 @@ const adapterFunctions = { evaluate(source, options) { const fields = weakmapGet(privateFields, this); if (fields === undefined) { - throw new TypeError('this is not a compartment'); + throw new TypeError('compartment.evaluate: this is not a compartment'); } const { transforms, delegateNative, nativeEval } = fields; for (const transform of transforms) { @@ -83,7 +83,7 @@ const adapterFunctions = { await null; const fields = weakmapGet(privateFields, this); if (fields === undefined) { - throw new TypeError('this is not a compartment'); + throw new TypeError('compartment.import: this is not a compartment'); } const { noNamespaceBox, delegateNative } = fields; const delegateImport = delegateNative ? nativeImport : shimImport; @@ -94,7 +94,7 @@ const adapterFunctions = { importNow(specifier) { const fields = weakmapGet(privateFields, this); if (fields === undefined) { - throw new TypeError('this is not a compartment'); + throw new TypeError('compartment.importNow: this is not a compartment'); } const { delegateNative } = fields; const delegateImportNow = delegateNative ? nativeImportNow : shimImportNow; @@ -127,7 +127,9 @@ defineProperty(NativeCompartment.prototype, 'globalThis', { get() { const fields = weakmapGet(privateFields, this); if (fields === undefined) { - throw new TypeError('this is not a compartment'); + throw new TypeError( + 'get compartment.globalThis: this is not a compartment', + ); } const { delegateNative } = fields; const delegateGetGlobalThis = delegateNative @@ -143,7 +145,7 @@ defineProperty(NativeCompartment.prototype, 'name', { get() { const fields = weakmapGet(privateFields, this); if (fields === undefined) { - throw new TypeError('this is not a compartment'); + throw new TypeError('get compartment.name: this is not a compartment'); } const { name } = fields; return name; diff --git a/packages/ses/test/_xs.js b/packages/ses/test/_xs.js index 21bacc3e1e..4946fd32a3 100644 --- a/packages/ses/test/_xs.js +++ b/packages/ses/test/_xs.js @@ -22,7 +22,7 @@ lockdown(); // spot checks assert(Object.isFrozen(Object)); -// import a precompiled module source in a shim compartment +print('# shim compartment can import a shim precompiled module source'); { const shimCompartment = new Compartment({ __options__: true, @@ -39,7 +39,7 @@ assert(Object.isFrozen(Object)); ); } -// import a native module source in a native compartment +print('# native compartment can import a native ModuleSource'); { const nativeCompartment = new Compartment({ __options__: true, @@ -59,6 +59,7 @@ assert(Object.isFrozen(Object)); ); } +print('# shim compartment cannot import a native ModuleSource'); // fail to import a native module source in a shim compartment { let threw = null; @@ -80,7 +81,7 @@ assert(Object.isFrozen(Object)); ); } -// fail to import a precompiled module source in a native compartment +print('# native compartment cannot import a shim precompiled module source'); { let threw = null; try { @@ -102,7 +103,7 @@ assert(Object.isFrozen(Object)); ); } -// can link shim compartments +print('# shim compartment can link to another shim compartment'); { const shimCompartment1 = new Compartment({ __options__: true, @@ -128,7 +129,7 @@ assert(Object.isFrozen(Object)); ); } -// can link native compartments +print('# native compartment can link to another native compartment'); { const nativeCompartment1 = new Compartment({ __options__: true, @@ -158,7 +159,7 @@ assert(Object.isFrozen(Object)); ); } -// cannot link native from shim compartment +print('# shim compartment cannot link a native compartment'); { const nativeCompartment = new Compartment({ __options__: true, @@ -189,7 +190,7 @@ assert(Object.isFrozen(Object)); assert(threw, 'cannot link native from shim compartment'); } -// cannot link shim from native compartment +print('# native compartment cannot link shim compartment'); { const shimCompartment = new Compartment({ __options__: true,