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

Function recordHandshakeOrdering

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

Source from the content-addressed store, hash-verified

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