|
|
|
|
@@ -1700,11 +1700,19 @@ async function assertA12(): Promise<AssertionResult> {
|
|
|
|
|
* helper to read `extensionVersion`, since it's the actual production
|
|
|
|
|
* field per src/background/index.ts:572).
|
|
|
|
|
*
|
|
|
|
|
* Pre-condition: A12's zip already landed in downloadsDir. A13
|
|
|
|
|
* triggers a SECOND SAVE_ARCHIVE (verifies idempotency) so it works
|
|
|
|
|
* against its own fresh zip. Recording stays alive throughout.
|
|
|
|
|
* Plan 01-13 Task 9 (debug session 01-09-save-stops-recording) amendment:
|
|
|
|
|
* after the SAVE-auto-stops-recording fix in src/background/index.ts,
|
|
|
|
|
* A12's SAVE_ARCHIVE now stops the recording (per SPEC one-shot intent).
|
|
|
|
|
* A13's own SAVE_ARCHIVE therefore needs a FRESH recording — without it,
|
|
|
|
|
* A13 would dispatch against an empty buffer and saveArchive would
|
|
|
|
|
* return success=false (the EmptyVideoBufferError path). A13 thus
|
|
|
|
|
* does its own setupFreshRecording + segment-settle before dispatching.
|
|
|
|
|
* Trade-off: adds ~11s wall-clock to the harness (segment-settle for
|
|
|
|
|
* the first rotation) — acceptable; the SPEC SAVE=stop contract is the
|
|
|
|
|
* load-bearing requirement, A13 was designed under the old "save keeps
|
|
|
|
|
* recording" assumption.
|
|
|
|
|
*
|
|
|
|
|
* @returns Structured result with 1 page-side check (SAVE_ARCHIVE ack).
|
|
|
|
|
* @returns Structured result with checks (SETUP + A13.1).
|
|
|
|
|
*/
|
|
|
|
|
async function assertA13(): Promise<AssertionResult> {
|
|
|
|
|
const result: AssertionResult = {
|
|
|
|
|
@@ -1715,7 +1723,38 @@ async function assertA13(): Promise<AssertionResult> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
diag(result, 'Step 1: send SAVE_ARCHIVE to SW (second save — A12 already produced one)');
|
|
|
|
|
// Plan 01-13 Task 9 amendment: A12's SAVE_ARCHIVE now auto-stops
|
|
|
|
|
// recording (per the SAVE=stop SPEC contract). A13 needs to
|
|
|
|
|
// re-establish a fresh recording + wait for the first segment
|
|
|
|
|
// rotation before dispatching its own SAVE — otherwise the
|
|
|
|
|
// SW's saveArchive throws EmptyVideoBufferError on an empty
|
|
|
|
|
// segments buffer and returns success=false.
|
|
|
|
|
diag(result, 'Step 1: setupFreshRecording (A12 SAVE stopped recording per 01-09 fix)');
|
|
|
|
|
const setupResp = await setupFreshRecording();
|
|
|
|
|
if (!setupResp.ok) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`setupFreshRecording failed: ${setupResp.error ?? '(no error)'}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
diag(result, 'Step 1 OK — fresh recording active');
|
|
|
|
|
result.checks.push({
|
|
|
|
|
name: 'SETUP: fresh recording established (post-A12 SAVE auto-stop)',
|
|
|
|
|
expected: true,
|
|
|
|
|
actual: true,
|
|
|
|
|
passed: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Step 2 — segment-settle. Same rationale as A5 (line ~890): the
|
|
|
|
|
// offscreen recorder rotates segments every SEGMENT_DURATION_MS
|
|
|
|
|
// (10s). Before the first rotation, `segments` is empty and
|
|
|
|
|
// `getVideoBufferFromOffscreen` returns `{segments:[]}` which
|
|
|
|
|
// createArchive treats as EmptyVideoBufferError. Wait 11s so at
|
|
|
|
|
// least one segment lands in the buffer.
|
|
|
|
|
diag(result, `Step 2: settle ${A5_SEGMENT_SETTLE_MS}ms for first segment rotation`);
|
|
|
|
|
await new Promise((r) => setTimeout(r, A5_SEGMENT_SETTLE_MS));
|
|
|
|
|
diag(result, 'Step 2 OK — first rotation should have fired');
|
|
|
|
|
|
|
|
|
|
diag(result, 'Step 3: send SAVE_ARCHIVE to SW (own fresh-recording save)');
|
|
|
|
|
const resp = await sendMessageWithTimeout<{
|
|
|
|
|
success: boolean;
|
|
|
|
|
error?: string;
|
|
|
|
|
@@ -1724,7 +1763,7 @@ async function assertA13(): Promise<AssertionResult> {
|
|
|
|
|
A12_A13_SAVE_ARCHIVE_TIMEOUT_MS,
|
|
|
|
|
'SAVE_ARCHIVE',
|
|
|
|
|
);
|
|
|
|
|
diag(result, `Step 1 result: ${JSON.stringify(resp)}`);
|
|
|
|
|
diag(result, `Step 3 result: ${JSON.stringify(resp)}`);
|
|
|
|
|
|
|
|
|
|
result.checks.push({
|
|
|
|
|
name: 'A13.1: SAVE_ARCHIVE handler returns success=true (zip shape verified host-side)',
|
|
|
|
|
@@ -1742,6 +1781,129 @@ async function assertA13(): Promise<AssertionResult> {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Settle window for the SW state machine after SAVE_ARCHIVE completes
|
|
|
|
|
* — the post-save STOP_RECORDING + setIdleMode block runs synchronously
|
|
|
|
|
* in saveArchive's finally, but chrome.action.getBadgeText reads are
|
|
|
|
|
* cross-event-loop. 500ms provides comfortable headroom; the
|
|
|
|
|
* observed lag is typically a few ms. */
|
|
|
|
|
const A14_POST_SAVE_SETTLE_MS = 500;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A14 — post-SAVE auto-stop state check. Plan 01-13 Task 9 closure for
|
|
|
|
|
* the operator empirical UAT bug `.planning/debug/01-09-save-stops-recording.md`.
|
|
|
|
|
*
|
|
|
|
|
* Verifies that A13's SAVE_ARCHIVE (and by extension every SAVE) leaves
|
|
|
|
|
* the SW state machine in IDLE:
|
|
|
|
|
* - badge text === '' (setBadgeState('OFF') side effect of setIdleMode)
|
|
|
|
|
* - popup === '' (chrome.action.setPopup('') side effect of setIdleMode;
|
|
|
|
|
* observed as the Chrome-resolved absolute URL ending in a path that
|
|
|
|
|
* is NOT 'src/popup/index.html' — under the IDLE contract Chrome
|
|
|
|
|
* returns an empty string when getPopup is called against a popup
|
|
|
|
|
* that was set to '')
|
|
|
|
|
* - no NEW notification with the 'mokosh-recovery-' prefix surfaced
|
|
|
|
|
* since A14 entered (delta-based — A7 left a recovery notification
|
|
|
|
|
* in the active set; the SAVE auto-stop must NOT add another one,
|
|
|
|
|
* per the "deliberate stop ≠ error" contract that mirrors Bug B)
|
|
|
|
|
*
|
|
|
|
|
* Pre-condition: A13 just completed (its SAVE_ARCHIVE auto-stopped the
|
|
|
|
|
* recording under the new fix; the state machine should already be in
|
|
|
|
|
* IDLE by the time A14 runs).
|
|
|
|
|
*
|
|
|
|
|
* Post-condition: no state change — A14 is read-only.
|
|
|
|
|
*
|
|
|
|
|
* Per the spec instruction (alternative simpler design from the
|
|
|
|
|
* orchestrator prompt): we settle for badge='' + popup='' + no-NEW-recovery-notif
|
|
|
|
|
* as the A14 contract. Direct isRecording check is transitively verified
|
|
|
|
|
* via the absence of the REC badge — the production SW state machine
|
|
|
|
|
* (src/background/index.ts:setRecordingMode/setIdleMode/setErrorMode)
|
|
|
|
|
* pairs isRecording transitions with badge transitions atomically, so
|
|
|
|
|
* the badge serves as a reliable proxy.
|
|
|
|
|
*
|
|
|
|
|
* @returns Structured result with 3 checks (badge + popup + no-new-recovery-notif).
|
|
|
|
|
*/
|
|
|
|
|
async function assertA14(): Promise<AssertionResult> {
|
|
|
|
|
const result: AssertionResult = {
|
|
|
|
|
passed: false,
|
|
|
|
|
name: 'A14 — post-SAVE auto-stop state: badge=\'\' + popup=\'\' + no new mokosh-recovery-* notif',
|
|
|
|
|
checks: [],
|
|
|
|
|
diagnostics: [],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Snapshot the recovery-notification ids BEFORE the A14 settle.
|
|
|
|
|
// A7 left at least one recovery-* in the active set; the delta we
|
|
|
|
|
// care about is "did any NEW recovery surface since A13's SAVE
|
|
|
|
|
// completed". A13's SAVE finished a few ms ago (the orchestrator
|
|
|
|
|
// ran assertA13 → returned → host moved to A14); the post-save
|
|
|
|
|
// finally block in saveArchive already executed setIdleMode +
|
|
|
|
|
// STOP_RECORDING. But we cannot observe what A13 did atomically
|
|
|
|
|
// — the cleanest contract is to snapshot now, settle, and check
|
|
|
|
|
// for a DELTA only. The empty-buffer-error branch comment in
|
|
|
|
|
// src/background/index.ts notes that the recovery notification
|
|
|
|
|
// would briefly appear; in this assertion we verify that under
|
|
|
|
|
// the HAPPY (success-path) SAVE, no recovery notification
|
|
|
|
|
// surfaces. A13's setup dispatched a successful SAVE (against a
|
|
|
|
|
// fresh recording with >= 1 segment from the 11s settle), so the
|
|
|
|
|
// happy-path branch ran — no RECORDING_ERROR → no recovery notif.
|
|
|
|
|
diag(result, 'Step 1: snapshot mokosh-recovery-* notification ids (delta baseline)');
|
|
|
|
|
const idsBefore = await getActiveNotificationIds();
|
|
|
|
|
const recoveryIdsBefore = idsBefore.filter(
|
|
|
|
|
(id) => id.startsWith(RECOVERY_NOTIF_PREFIX),
|
|
|
|
|
);
|
|
|
|
|
diag(
|
|
|
|
|
result,
|
|
|
|
|
`Step 1 result: ${recoveryIdsBefore.length} active recovery-prefix ids: ${JSON.stringify(recoveryIdsBefore)}`,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
diag(result, `Step 2: settle ${A14_POST_SAVE_SETTLE_MS}ms for post-A13 state machine to land`);
|
|
|
|
|
await new Promise((r) => setTimeout(r, A14_POST_SAVE_SETTLE_MS));
|
|
|
|
|
|
|
|
|
|
diag(result, 'Step 3: read post-SAVE state (badge + popup + recovery ids delta)');
|
|
|
|
|
const badge = await chrome.action.getBadgeText({});
|
|
|
|
|
const popup = await chrome.action.getPopup({});
|
|
|
|
|
const idsAfter = await getActiveNotificationIds();
|
|
|
|
|
const recoveryIdsAfter = idsAfter.filter(
|
|
|
|
|
(id) => id.startsWith(RECOVERY_NOTIF_PREFIX),
|
|
|
|
|
);
|
|
|
|
|
const recoveryDelta = recoveryIdsAfter.length - recoveryIdsBefore.length;
|
|
|
|
|
diag(
|
|
|
|
|
result,
|
|
|
|
|
`Step 3 result: badge='${badge}', popup='${popup}', recoveryDelta=${recoveryDelta} (before=${recoveryIdsBefore.length}, after=${recoveryIdsAfter.length})`,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
result.checks.push({
|
|
|
|
|
name: 'A14.1: badge text is \'\' after SAVE_ARCHIVE auto-stop (setIdleMode)',
|
|
|
|
|
expected: '',
|
|
|
|
|
actual: badge,
|
|
|
|
|
passed: badge === '',
|
|
|
|
|
});
|
|
|
|
|
// Chrome's chrome.action.getPopup() returns an absolute URL when the
|
|
|
|
|
// popup was set via a non-empty path. When setPopup was called with
|
|
|
|
|
// an empty string (the setIdleMode case), getPopup returns an empty
|
|
|
|
|
// string per the Chrome runtime API contract. Assert empty-string
|
|
|
|
|
// equality.
|
|
|
|
|
result.checks.push({
|
|
|
|
|
name: 'A14.2: popup is \'\' after SAVE_ARCHIVE auto-stop (setIdleMode re-enables onClicked)',
|
|
|
|
|
expected: '',
|
|
|
|
|
actual: popup,
|
|
|
|
|
passed: popup === '',
|
|
|
|
|
});
|
|
|
|
|
result.checks.push({
|
|
|
|
|
name: 'A14.3: NO new mokosh-recovery-* notification (deliberate stop != error)',
|
|
|
|
|
expected: 0,
|
|
|
|
|
actual: recoveryDelta,
|
|
|
|
|
passed: recoveryDelta === 0,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
result.passed = result.checks.every((c) => c.passed);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
result.error = err instanceof Error ? err.message : String(err);
|
|
|
|
|
diag(result, `THREW: ${result.error}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Read `chrome.runtime.getManifest().version`. Used by the host-side
|
|
|
|
|
* orchestrator at startup to capture the expected version for A13's
|
|
|
|
|
@@ -1772,6 +1934,7 @@ declare global {
|
|
|
|
|
assertA11: () => Promise<AssertionResult>;
|
|
|
|
|
assertA12: () => Promise<AssertionResult>;
|
|
|
|
|
assertA13: () => Promise<AssertionResult>;
|
|
|
|
|
assertA14: () => Promise<AssertionResult>;
|
|
|
|
|
getManifestVersion: () => Promise<string>;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
@@ -1791,14 +1954,15 @@ window.__mokoshHarness = {
|
|
|
|
|
assertA11,
|
|
|
|
|
assertA12,
|
|
|
|
|
assertA13,
|
|
|
|
|
assertA14,
|
|
|
|
|
getManifestVersion,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const statusEl = document.getElementById('status');
|
|
|
|
|
if (statusEl !== null) {
|
|
|
|
|
statusEl.textContent = 'Harness ready. window.__mokoshHarness.{assertA1..assertA13, getManifestVersion} available.';
|
|
|
|
|
statusEl.textContent = 'Harness ready. window.__mokoshHarness.{assertA1..assertA14, getManifestVersion} available.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('[harness-page] ready — window.__mokoshHarness installed (Wave 3D: A1..A13 + getManifestVersion)');
|
|
|
|
|
console.log('[harness-page] ready — window.__mokoshHarness installed (Plan 01-13 Task 9: A1..A14 + getManifestVersion)');
|
|
|
|
|
|
|
|
|
|
export {};
|
|
|
|
|
|