MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / recordHandshakeOrdering

Function recordHandshakeOrdering

e2e/scenarios/artifacts.test.ts:129–147  ·  view source on GitHub ↗
(page: Page)

Source from the content-addressed store, hash-verified

127}
128
129const recordHandshakeOrdering = async (page: Page): Promise<void> => {
130 await page.addInitScript(() => {
131 globalThis.__handshakeOrder = [];
132 const original = EventTarget.prototype.addEventListener;
133 EventTarget.prototype.addEventListener = function (type, listener, options) {
134 if (type === "message" && this === window) {
135 const frame = document.querySelector<HTMLIFrameElement>(
136 '[data-testid="artifact-shell-frame"]',
137 );
138 // No frame yet is even earlier than about:blank, so it satisfies the
139 // invariant too; "(none)" keeps that case distinguishable in a failure.
140 globalThis.__handshakeOrder?.push(
141 frame ? (frame.contentDocument?.URL ?? "(no document)") : "(none)",
142 );
143 }
144 return original.call(this, type, listener, options as never);
145 };
146 });
147};
148
149const readHandshakeOrdering = (page: Page): Promise<ReadonlyArray<string>> =>
150 page.evaluate(() => globalThis.__handshakeOrder ?? []);

Callers 1

artifacts.test.tsFile · 0.85

Calls 2

pushMethod · 0.80
callMethod · 0.80

Tested by

no test coverage detected