test(e2e): add a real mouse drag step to the CDP and BiDi drivers
A step may carry drag [[x0, y0], [x1, y1]]: after its keys and before its probe the driver presses the left mouse button at the first viewport point, moves to the second and releases (Input.dispatchMouseEvent in cdp.mjs, input.performActions in bidi.mjs). Synthetic PointerEvents cannot take pointer capture, so steer() and swipe handlers need trusted input. Proven by the hub sky e2e (feature/orchestrator-cosmos), green in Chromium and Firefox at 1920/1366/390; the Match swipe e2e builds on it. 🎯 Fix: 93 % 💥 Break: 3 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 90 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cbaedb4fbb
commit
e8a652a5a5
2 files changed
+19
-4
No files matched your search
+8
-2
@@ -4,8 +4,8 @@ import {createServer} from "node:net";
|
||||
import {tmpdir} from "node:os";
|
||||
import {join} from "node:path";
|
||||
|
||||
// Args: <firefox binary> <plan.json>; the plan lists steps {width, height, url, wait, keys, probe, shot, gesture} and an
|
||||
// optional init like cdp.mjs.
|
||||
// Args: <firefox binary> <plan.json>; the plan lists steps {width, height, url, wait, keys, drag, probe, shot, gesture} and
|
||||
// an optional init like cdp.mjs.
|
||||
// Prints {results, errors}: one probe value per step and every JavaScript error the page logged.
|
||||
const [binary, planFile] = process.argv.slice(2);
|
||||
const plan = JSON.parse(readFileSync(planFile, "utf8"));
|
||||
@@ -86,6 +86,12 @@ try {
|
||||
await send("input.performActions", {context, actions: [{type: "key", id: "keyboard", actions: [{type: "keyDown", value: KEYS[key]}, {type: "keyUp", value: KEYS[key]}]}]});
|
||||
await sleep(250);
|
||||
}
|
||||
if (step.drag) {
|
||||
const [[x0, y0], [x1, y1]] = step.drag;
|
||||
const moves = [{type: "pointerMove", x: x0, y: y0}, {type: "pointerDown", button: 0}, {type: "pointerMove", x: x1, y: y1}, {type: "pointerUp", button: 0}];
|
||||
await send("input.performActions", {context, actions: [{type: "pointer", id: "mouse", parameters: {pointerType: "mouse"}, actions: moves}]});
|
||||
await sleep(250);
|
||||
}
|
||||
let value = null;
|
||||
if (step.probe) {
|
||||
const answer = await send("script.evaluate", {expression: `(async () => JSON.stringify(await ${step.probe}))()`, target: {context}, awaitPromise: true, resultOwnership: "none", userActivation: Boolean(step.gesture)});
|
||||
|
||||
Reference in new issue
Block a user