Skip to content

Commit a105504

Browse files
sirtimidclaude
andcommitted
fix(kernel-test): update e2e tests for throw-on-unknown-global behavior
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6ae2612 commit a105504

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

packages/kernel-test/src/endowment-globals.test.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,42 +158,39 @@ describe('global endowments', () => {
158158
});
159159

160160
describe('kernel-level allowedGlobalNames restriction', () => {
161-
it('blocks a global when the kernel excludes it from allowedGlobalNames', async () => {
162-
// Kernel only allows TextEncoder/TextDecoder — vat requests URL too
161+
it('throws when a vat requests a global excluded by the kernel', async () => {
162+
// Kernel only allows TextEncoder/TextDecoder — vat also requests URL
163+
await expect(
164+
setup({
165+
globals: ['TextEncoder', 'TextDecoder', 'URL'],
166+
allowedGlobalNames: ['TextEncoder', 'TextDecoder'],
167+
}),
168+
).rejects.toThrow('unknown global "URL"');
169+
});
170+
171+
it('initializes when all vat globals are within allowedGlobalNames', async () => {
163172
const { kernel, entries } = await setup({
164-
globals: ['TextEncoder', 'TextDecoder', 'URL'],
173+
globals: ['TextEncoder', 'TextDecoder'],
165174
allowedGlobalNames: ['TextEncoder', 'TextDecoder'],
166175
});
167176

168-
// TextEncoder works (allowed by kernel)
169177
await kernel.queueMessage(v1Root, 'testTextCodec', []);
170178
await waitUntilQuiescent();
171179

172180
const logs = extractTestLogs(entries, vatId);
173181
expect(logs).toContain('textCodec: hello');
174-
175-
// URL is absent (kernel excluded it even though vat requested it)
176-
await kernel.queueMessage(v1Root, 'checkGlobal', ['URL']);
177-
await waitUntilQuiescent();
178-
179-
const logsAfter = extractTestLogs(entries, vatId);
180-
expect(logsAfter).toContain('checkGlobal: URL=false');
181182
});
182183

183184
it('allows all globals when allowedGlobalNames is omitted', async () => {
184-
// No kernel restriction — vat gets everything it asks for
185185
const { kernel, entries } = await setup({
186-
globals: ['URL', 'TextEncoder'],
186+
globals: ['URL', 'URLSearchParams'],
187187
});
188188

189-
await kernel.queueMessage(v1Root, 'checkGlobal', ['URL']);
190-
await waitUntilQuiescent();
191-
await kernel.queueMessage(v1Root, 'checkGlobal', ['TextEncoder']);
189+
await kernel.queueMessage(v1Root, 'testUrl', []);
192190
await waitUntilQuiescent();
193191

194192
const logs = extractTestLogs(entries, vatId);
195-
expect(logs).toContain('checkGlobal: URL=true');
196-
expect(logs).toContain('checkGlobal: TextEncoder=true');
193+
expect(logs).toContain('url: /path params: 10');
197194
});
198195
});
199196
});

0 commit comments

Comments
 (0)