mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 19:23:24 +00:00
* fix(browser): type CDP command replies and parse frame trees once CdpConnection.send is typed by method name. A command registered in src/browser/protocol/CdpCommands.ts has its parameters typed from the protocol table Playwright ships and its reply parsed once by its own result schema; a mismatch rejects that command with CdpMalformedReply (protocol_error, command, JSON pointer) without poisoning the connection. Playwright storage sessions admit replies through the same table. Page.getFrameTree and Page.getResourceTree are the first registered commands. Their one parser keeps per-frame facts tolerant (malformed child entries remain explicit omissions) and replaces the per-site readers: observeMainFrameUrl, mainFrameUrl, walkFrameTrees, frameTreeResources, runtimeFrameTreeSchema and the scenario storage frame schema. A reply without a frame tree used to be retried for two seconds and reported as target_not_allowed; it is now one protocol_error. A guard test counts literal CDP command names without a result schema per source file; the baseline can only shrink. * fix(browser): consume parsed CDP facts across boundaries
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
|
|
export const isolatedFixtureUrl = "rea-isolated-fixture.js";
|
|
|
|
/** Create an explicitly owned native isolated-world fixture outside REA's public operations. */
|
|
export async function createRuntimeIsolatedWorld(connection) {
|
|
const tree = await connection.send("Page.getFrameTree");
|
|
const world = await connection.send("Page.createIsolatedWorld", {
|
|
frameId: tree.root.facts.frameId,
|
|
worldName: "rea-verifier-isolated",
|
|
});
|
|
const contextId = world.executionContextId;
|
|
assert.ok(Number.isInteger(contextId));
|
|
const initialized = await connection.send("Runtime.evaluate", {
|
|
contextId,
|
|
expression: `function reaIsolatedFixture() { return 'isolated-proof'; }
|
|
//# sourceURL=${isolatedFixtureUrl}`,
|
|
});
|
|
assert.equal(initialized.exceptionDetails, undefined);
|
|
return contextId;
|
|
}
|
|
|
|
/** Invoke a known isolated callback and the selected site's callback after actual REA arming. */
|
|
export async function triggerRuntimeFixtureAction(connection, contextId) {
|
|
const proof = await connection.send("Runtime.evaluate", {
|
|
contextId,
|
|
expression: "reaIsolatedFixture()",
|
|
returnByValue: true,
|
|
});
|
|
assert.equal(proof.result.value, "isolated-proof");
|
|
return connection.send("Runtime.evaluate", {
|
|
expression: "document.querySelector('#run').click()",
|
|
});
|
|
}
|