Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

test(view): count fetches a page policy blocks [N26,A2]

Corey Olsoncd617afdd48a
diff --git a/test/cockpit/local-origin.test.js b/test/cockpit/local-origin.test.js
index dfcee4b9..f9e73838 100644
--- a/test/cockpit/local-origin.test.js
+++ b/test/cockpit/local-origin.test.js
@@ -331,15 +331,19 @@ test('the hosted page says how far behind this machine\'s Pullboard is [N26,A2]'
let visit = 0;
let visitPreload;
let requestsAt = 0;
- /** The addresses one visit reached, as origin plus path for the hosted page and as origin for the local view. */
- const reached = () => [...new Set(chrome.requests.slice(requestsAt).map((asked) => new URL(asked.url)).filter((address) => address.protocol.startsWith('http'))
- .map((address) => (address.origin === HOSTED ? address.origin + address.pathname : address.origin)))].sort();
+ /** Every address one visit asked for, as origin plus path on the hosted page and as origin elsewhere. The page's own
+ * record of its fetch calls counts asks a page policy blocks before Chrome's network sees them. */
+ const reached = async () => {
+ const asked = [...chrome.requests.slice(requestsAt).map((request) => request.url), ...JSON.parse(await chrome.stable('JSON.stringify(window.__releaseFetches || [])'))];
+ return [...new Set(asked.map((url) => new URL(url, HOSTED + '/')).filter((address) => address.protocol.startsWith('http'))
+ .map((address) => (address.origin === HOSTED ? address.origin + address.pathname : address.origin)))].sort();
+ };
const open = async (version, production = false) => {
activePage = production ? productionPage : pageFor(version);
requestsAt = chrome.requests.length;
if (visitPreload) await chrome.send('Page.removeScriptToEvaluateOnNewDocument', { identifier: visitPreload });
const marker = ++visit;
- const installed = await chrome.send('Page.addScriptToEvaluateOnNewDocument', { source: `window.__releaseVisit = ${marker};` });
+ const installed = await chrome.send('Page.addScriptToEvaluateOnNewDocument', { source: `window.__releaseVisit = ${marker}; window.__releaseFetches = []; const pageFetch = window.fetch; window.fetch = function (input, init) { window.__releaseFetches.push(String(input?.url ?? input)); return pageFetch.call(this, input, init); };` });
visitPreload = installed.identifier;
await chrome.send('Page.navigate', { url: HOSTED + '/' });
await chrome.waitFor(`window.__releaseVisit === ${marker} && document.readyState === 'complete' && data?.project?.releaseNotes?.version === ${JSON.stringify(local.versionOverride)} && document.querySelector('#chain')?.textContent.includes('A board on an older Pullboard release')`, 25_000); // budget: hang ceiling for this navigation to finish the local state read before the next visit; no throughput claim.
@@ -363,7 +367,7 @@ test('the hosted page says how far behind this machine\'s Pullboard is [N26,A2]'
assert.ok(releasesBehind > 0, 'the hosted package has shipped releases after the simulated older install');
assert.equal(await bannerText(), `Pullboard 0.8.20 is installed; ${VERSION} is current, ${releasesBehind} ${releasesBehind === 1 ? 'release' : 'releases'} behind. Update with`);
assert.equal(await bannerHidden(), false, 'a new target release brings the note back');
- const behindReached = reached();
+ const behindReached = await reached();
// The production-generated page counts every numeric release heading, including 0.8.4's section with no headline.
local.versionOverride = '0.8.4';
@@ -375,7 +379,7 @@ test('the hosted page says how far behind this machine\'s Pullboard is [N26,A2]'
local.versionOverride = VERSION;
await open(VERSION, true);
assert.equal(await bannerHidden(), true, 'matching local and hosted releases show no note');
- assert.deepEqual(behindReached, reached(), 'the note costs no request: a visit that shows it reaches what a matched visit reaches');
+ assert.deepEqual(behindReached, await reached(), 'the note costs no request: a visit that shows it reaches what a matched visit reaches');
assert.deepEqual(behindReached.filter((address) => !address.startsWith(HOSTED + '/') && address !== LOCAL && address !== view.base), [],
'the page learns both versions without asking any other address');