mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(web-runtime): enforce pressKey allowlist in factory
The factory accepted any string while randomPressKey only emitted
enter/tab/escape/arrows. A spec emitting pressKey({key:"home"}) would
flow through to the chrome driver, which rejects unsupported keys with
a runtime error mid-step. Reject at the factory so the spec author
sees the failure where it originates.
This commit is contained in:
1 parent
9722839339
commit
ba9a456659
1 file changed
+5
@@ -336,6 +336,11 @@ const runtime = {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
pressKey(p: { key: string }): unknown {
|
pressKey(p: { key: string }): unknown {
|
||||||
|
if (!WEB_PRESS_KEYS.includes(p.key)) {
|
||||||
|
throw new Error(
|
||||||
|
`pressKey: unsupported key ${JSON.stringify(p.key)} (allowed: ${WEB_PRESS_KEYS.join(", ")})`,
|
||||||
|
);
|
||||||
|
}
|
||||||
return { kind: "PressKey", key: p.key };
|
return { kind: "PressKey", key: p.key };
|
||||||
},
|
},
|
||||||
wait(p: { durationMillis: number }): unknown {
|
wait(p: { durationMillis: number }): unknown {
|
||||||
|
|||||||
Reference in new issue
Block a user