Smoke test
Use when verifying or testing changes to page.html (the single self-saving editable page with margin comments). Drives it through agent-browser to check the comment UI and save invariants, and proves the cross-generation fixed point. Also documents the agent-browser gaps, the picker-stub pattern, and why byte-stability across saves is the real correctness test. Run after any change to serialize() or the comment code.From its SKILL.md
npx -y skills add rnorth/editable-page --skill smoke-testAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
7.8 KB, as published. Nobody here has run it
Smoke-testing page.html
page.html is one self-contained, self-saving HTML file. Two things make it fiddly
to test, and everything below follows from them:
- It overwrites itself. On ⌘S it serializes its own live DOM and writes the result back over its own file, which is then reopened later. So correctness is a property across save generations, not within one.
- The save ends in a native file dialog that cannot be automated.
window.showSaveFilePicker()opens an OS dialog that no tool can drive; triggering it for real hangs the tab indefinitely.
Run it
bash .claude/skills/smoke-test/smoke-test.sh
Exit 0 and ✅ smoke test passed means the comment UI, the serialize() invariants,
and the generational fixed point all hold. Any FAIL line names the broken check.
Re-run after any change to serialize() or the comment code.
Stage 1 (stage1-ui.js) exercises create → view → delete, the selection guards
(multi-block and overlap must suppress the icon), and the save invariants (empty
anchors GC-d, transient UI stripped, status/dirty reset). Stage 2
(stage2-structure.js) mangles the block structure and asserts a save repairs it.
Stage 3 seeds two comments, mangles the document, saves three generations, and asserts
gen2 == gen3 byte-for-byte.
Structural damage is browser-specific — assert the damage happened
plaintext-only stops the user typing markup; it does not stop the browser rebuilding
the block it owns, and serialize() normalises #doc back to a flat list of blocks
because of it. Which edits do damage is not obvious, so stage 2 uses one mangle Chrome
makes for real and one taken verbatim from the bug report:
- select-all + retype several lines →
<h1>one</h1><div>two</div><div>three</div>. Chrome keeps the first line's block and wraps the rest in<div>s. - delete a selection spanning two
<p>s + retype → comes back clean. An obvious choice for this test, and it would have proved nothing.
So stage 2 asserts mangle1_browserMadeDivs before asserting the repair — otherwise a
future Chrome that stopped producing soup would turn the whole mangle into a no-op that
still reads as a pass. Same reflex as the empty-result guards: a check whose setup
silently didn't happen is a vacuous pass.
A green run must mean the checks actually ran. Both stages assert this, because
the natural failure mode of a browser harness is producing nothing rather than
producing something wrong — and nothing trivially satisfies both comparisons (two
empty files are byte-identical; an empty result dict has no failing checks). So a
failed capture leaves no file behind and aborts the stage, every generation is
checked against a size floor of half page.html before the next is opened, and stage
1 fails outright if it reports no checks.
agent-browser gaps — work around these or waste hours
agent-browser (Playwright/CDP) is the only tool that can drive the page. Its gaps:
keyboard type/keyboard inserttextare broken — CDP rejects every input, plain ASCII included. To type into the editable#doc, usedocument.execCommand("insertText", false, "...")inside aneval; it fires realbeforeinput/inputevents, so the dirty flag and revision counter update as with genuine typing. (Into a<textarea>, just set.value.)- Page-world state does not survive between separate
evalcalls. A stub you assign towindow.*in one call may be gone by the next, and the browser sometimes silently restarts between bash invocations. Arm + act + assert must live in a singleeval— this is whystage1-ui.jsis one big Promise. evaldouble-JSON-encodes its result. ReturnJSON.stringify(obj)and the CLI wraps it in quotes again; decode twice. To capture a large payload (the serialized page) to disk, returnJSON.stringify({ html })and pipe to apython3 -cthat decodes and writes — don't split output on a literal space, the shell eats it.timeoutdoes not exist in this fish shell —timeout 15 agent-browser …fails as command-not-found, and silently does nothing if you sent stderr to/dev/null. Don't use it.- A dirty page blocks automated navigation via its
beforeunloadguard, which can hangagent-browser open. Runagent-browser closebefore re-opening (the harness does this between every generation). requestAnimationFramestops firing when the display sleeps or Chrome's window is fully covered.document.visibilityStatestill reports"visible"andhasFocus()istrue, so there is no signal except that anything awaiting a frame never resolves — stage 1 hangs on its firstawait rAFuntil CDP times out, and the run reports "browser returned nothing". Restarting the daemon does not help; waking the display does. The harness now preflights this and says so. To confirm it is the cause, prependwindow.requestAnimationFrame = (cb) => setTimeout(() => cb(performance.now()), 16);to the script — diagnosis only, never in a real run, since the page lays its margin previews out in rAF and the shim would stop the stub checks testing anything.
Never let a test reach the real file picker
To exercise the real save() path, stub the picker inside the same eval that
triggers the save, capturing what would be written:
let written = null;
window.showSaveFilePicker = async () => ({
name: "page.html",
createWritable: async () => ({ write: (t) => { written = t; }, close: async () => {} }),
});
// ...trigger save (⌘S keydown or click #save), await, then read `written`.
This covers everything except the actual bytes-to-disk write — which only Chrome/Edge can do for real, and only a human can confirm through the dialog.
Assert against the DOM, not the source text
The serialized file contains a <style> and <script> that mention .cmt,
cmt-icon, data-dirty, class="comment" etc. as CSS selectors and JS strings. A
substring/grep check on the saved text will match those and give false positives
(this has bitten us repeatedly). Parse the output with DOMParser and count real
elements, as stage1-ui.js does.
Why same-session idempotence is not enough
Saving twice in one session and comparing is too weak — it has passed while real bugs were live. Only the generational test (save → reload the saved file → save again → the two must be byte-for-byte identical) caught:
- a trailing newline after
</html>the parser reparented into<body>, growing the file one byte per save; - a
disabled=""baked into the Save button, dead on every reload; - a comment body kept alive by a hollow
<span class="cmt">its text was edited out of.
Compare bytes, not characters — multibyte UTF-8 (⌘, —, …) makes len() and
byte-count differ legitimately.
Manual ad-hoc checks
To poke at one behaviour by hand, one self-contained eval (arm + act + assert), e.g.
to confirm a fresh in-block selection offers the icon:
agent-browser open "file://$PWD/page.html"
agent-browser eval '(() => {
const doc = document.getElementById("doc");
const p = doc.querySelector("p");
const r = document.createRange(); r.setStart(p.firstChild, 0); r.setEnd(p.firstChild, 5);
const s = getSelection(); s.removeAllRanges(); s.addRange(r);
doc.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));
return !!document.querySelector(".cmt-icon");
})()'