Skip to content

Commit

Permalink
et tu ci
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Oct 18, 2024
1 parent 87def51 commit 121605b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
12 changes: 7 additions & 5 deletions packages/ses/src-xs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions packages/ses/test/_xs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 121605b

Please sign in to comment.