SOURCE / PINNED RELEASE
Made of little things.
DOOM
- Release
- f8a5db646fdc…
- Author-recorded commit
- d8e055796675…
- License
- LICENSE
- Author’s source reference
- nostr://npub182jczunncwe0jn6frpqwq3e0qjws7yqqnc3auccqv9nte2dnd63scjm4rf/wss%3A%2F%2Fgit.napplet.soy%2F/n-37af437f0e6
Archive hash verified: 66555ff880270ca9…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import { readFile, mkdir } from 'node:fs/promises';
const require = createRequire(import.meta.url);
const { chromium } = createRequire(
require.resolve('@napplet/conformance-cli/package.json'),
)('playwright');
const previewUrl = process.argv[2];
if (!previewUrl) throw new Error('Pass the URL printed by soyli dev.');
const browser = await chromium.launch({ headless: true });
const results = [];
await mkdir('.napplet-space/testing', { recursive: true });
try {
for (const [width, height, touch] of [
[200, 160, false],
[320, 560, true],
[900, 600, false],
[1440, 900, false],
[390, 844, true],
[360, 640, true],
[844, 390, true],
]) {
const ctx = await browser.newContext({
viewport: {
width: Math.max(width, 1000),
height: Math.max(height + 250, 1000),
},
hasTouch: touch,
isMobile: touch,
});
const page = await ctx.newPage();
const errors = [];
page.on('pageerror', (e) => errors.push(String(e)));
await page.goto(previewUrl);
const iframe = page.locator('iframe');
await iframe.waitFor();
// This override controls the actual sandbox dimensions, including the tiny frame below soyLI's 300px minimum.
await iframe.evaluate(
(e, size) => {
e.style.cssText = `width:${size[0]}px!important;height:${size[1]}px!important;min-height:0!important;min-width:0!important;flex:none!important`;
},
[width, height],
);
const frame = page.frames().find((f) => f.url() === 'about:srcdoc');
await frame.locator('#start').waitFor({ state: 'attached' });
await page.waitForTimeout(300);
assert.deepEqual(await frame.evaluate(() => [innerWidth, innerHeight]), [
width,
height,
]);
if (width < 300) {
assert.equal(await frame.locator('#small-notice').isVisible(), true);
await iframe.screenshot({
path: `.napplet-space/testing/${width}x${height}.png`,
});
await ctx.close();
continue;
}
await iframe.screenshot({
path: `.napplet-space/testing/${width}x${height}-launch.png`,
});
await frame.locator('#start').click();
await page.waitForTimeout(950);
assert.equal(await frame.locator('#overlay').isVisible(), false);
const checkBounds = async () =>
frame.evaluate(() =>
[...document.querySelectorAll('#toolbar button,#touch-deck button')]
.filter((e) => e.getClientRects().length)
.map((e) => {
const r = e.getBoundingClientRect();
return {
id: e.id || e.getAttribute('aria-label') || e.textContent,
w: r.width,
h: r.height,
x: r.x,
y: r.y,
right: r.right,
bottom: r.bottom,
};
}),
);
const bounds = await checkBounds();
for (const b of bounds) {
assert.ok(
b.x >= 0 &&
b.y >= 0 &&
b.right <= width + 0.5 &&
b.bottom <= height + 0.5,
JSON.stringify(b),
);
if (touch) assert.ok(b.w >= 44 && b.h >= 44, JSON.stringify(b));
}
await iframe.screenshot({
path: `.napplet-space/testing/${width}x${height}.png`,
});
const color = await frame
.locator('#app')
.evaluate((e) => getComputedStyle(e).backgroundImage);
await page.emulateMedia({ colorScheme: 'dark', reducedMotion: 'reduce' });
assert.equal(
await frame
.locator('#app')
.evaluate((e) => getComputedStyle(e).backgroundImage),
color,
);
await page.emulateMedia({ colorScheme: 'light' });
assert.equal(
await frame
.locator('#app')
.evaluate((e) => getComputedStyle(e).backgroundImage),
color,
);
if (touch) {
const cdp = await ctx.newCDPSession(page);
const a = await frame.locator('[data-key="up"]').boundingBox(),
b = await frame.locator('[data-key="fire"]').boundingBox();
await cdp.send('Input.dispatchTouchEvent', {
type: 'touchStart',
touchPoints: [
{ id: 1, x: a.x + a.width / 2, y: a.y + a.height / 2 },
{ id: 2, x: b.x + b.width / 2, y: b.y + b.height / 2 },
],
});
await page.waitForTimeout(300);
assert.equal(await frame.locator('.held').count(), 2);
await cdp.send('Input.dispatchTouchEvent', {
type: 'touchCancel',
touchPoints: [],
});
assert.equal(await frame.locator('.held').count(), 0);
}
await frame.locator('#pause').click();
await frame.locator('#pause-help').click();
assert.equal(await frame.locator('#help-panel').isVisible(), true);
await frame.locator('#help-back').click();
await frame.locator('#resume').click();
await frame.locator('#run').click();
assert.equal(
await frame.locator('#run').getAttribute('aria-pressed'),
'true',
);
await frame.locator('#run').click();
assert.equal(
await frame.locator('#run').getAttribute('aria-pressed'),
'false',
);
await frame.locator('#game').focus();
await page.keyboard.press('Escape');
assert.equal(await frame.locator('#pause-panel').isVisible(), true);
await page.keyboard.press('Escape');
assert.equal(await frame.locator('#overlay').isVisible(), false);
assert.deepEqual(errors, []);
results.push({
width,
height,
touch,
checks: 'bounds, input, pause/help/back, run, Escape, themes',
});
await ctx.close();
}
// Same built artifact, with optional domains absent or refusing calls. This is a test fixture, not an independent shell.
const html = await readFile('dist/index.html', 'utf8');
for (const mode of ['missing', 'denied', 'write-denied', 'hung']) {
const ctx = await browser.newContext({
viewport: { width: 900, height: 650 },
});
const page = await ctx.newPage();
const errors = [];
page.on('pageerror', (e) => errors.push(String(e)));
const prefix =
mode === 'write-denied'
? '<script>window.napplet={storage:{getItem:()=>Promise.resolve(null),setItem:()=>{throw new Error("denied")}}};<\/script>'
: mode === 'hung'
? '<script>window.napplet={storage:{getItem:()=>new Promise(()=>{})}};<\/script>'
: mode === 'denied'
? '<script>window.napplet={storage:{getItem:()=>Promise.reject(new Error("denied")),setItem:()=>Promise.reject(new Error("denied"))}};<\/script>'
: '';
await page.setContent(
'<iframe sandbox="allow-scripts" style="width:900px;height:600px;border:0"></iframe>',
);
await page
.locator('iframe')
.evaluate((e, html) => (e.srcdoc = html), prefix + html);
await page.waitForTimeout(300);
const frame = page.frames().find((f) => f.url() === 'about:srcdoc');
await frame.locator('#start').click();
await page.waitForTimeout(950);
await frame.locator('#pause').click();
if (mode !== 'write-denied')
assert.match(
await frame.locator('#save-status').innerText(),
/Session-only/,
);
await frame.locator('#save').click();
await page.waitForTimeout(2400);
assert.equal(await frame.locator('#load').isEnabled(), true);
assert.match(
await frame.locator('#save-status').innerText(),
/Session-only/,
);
assert.deepEqual(errors, []);
results.push({ mode, checks: 'play, session checkpoint, no crash' });
await ctx.close();
}
console.log(JSON.stringify(results, null, 2));
} finally {
await browser.close();
}
