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

Function recordHandshakeOrdering

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

Source from the content-addressed store, hash-verified

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