@capagents/forgeqe 2.9.9 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/docs-site/docs/web-app/index.html +6 -2
- package/dist/forgeqe.js +1811 -1696
- package/dist/web/assets/{Agent-B0R4tnqF.js → Agent-DQeWzsWG.js} +1 -1
- package/dist/web/assets/{ApiTests-CqWPHWCs.js → ApiTests-DrQBxtra.js} +1 -1
- package/dist/web/assets/{Browse-DlbTQPA8.js → Browse-CXqsKgMN.js} +2 -2
- package/dist/web/assets/{Chat-DtI3dgGs.js → Chat-rChaK9vu.js} +1 -1
- package/dist/web/assets/{CommandPalette-BTI3Q3sc.js → CommandPalette-LNTJ2Pie.js} +1 -1
- package/dist/web/assets/{Compare-BMcHYq3I.js → Compare-CP24uSyS.js} +1 -1
- package/dist/web/assets/{Cost-BcZ6gC9M.js → Cost-Cz6F4MAu.js} +1 -1
- package/dist/web/assets/{Data-Cbl35RTK.js → Data-RSpfLC9W.js} +1 -1
- package/dist/web/assets/{Desktop-D4JLSUnE.js → Desktop-C0VftUUl.js} +1 -1
- package/dist/web/assets/{DesktopReview-vyosGOyC.js → DesktopReview-BTYnwZKB.js} +1 -1
- package/dist/web/assets/{Evidence-MDaV4ttv.js → Evidence-DxfTgGLn.js} +1 -1
- package/dist/web/assets/{Explore-yjmJHnzH.js → Explore-BKAnJ0AP.js} +1 -1
- package/dist/web/assets/{Features-kXt6Um2p.js → Features-YYcKT5mB.js} +1 -1
- package/dist/web/assets/{Flags-CdLXiacX.js → Flags-B23vWmDR.js} +1 -1
- package/dist/web/assets/{Flaky-BZx54uo3.js → Flaky-kuhde8PW.js} +1 -1
- package/dist/web/assets/{Impact-_t7bwCwP.js → Impact-DetuURYY.js} +1 -1
- package/dist/web/assets/{Jobs-D4PIAcdO.js → Jobs-BTiCqtr9.js} +1 -1
- package/dist/web/assets/{KindPage-CGfjoezZ.js → KindPage-BbL7COME.js} +1 -1
- package/dist/web/assets/{Migration-OGOnRmUX.js → Migration-CPv7gDC-.js} +1 -1
- package/dist/web/assets/{Product-DycPE2MI.js → Product-DcrBguCI.js} +1 -1
- package/dist/web/assets/{Production-DqnrcSfn.js → Production-N11W9Ckr.js} +1 -1
- package/dist/web/assets/{Quality-C__pEYpt.js → Quality-DzXW1cvp.js} +1 -1
- package/dist/web/assets/{Readiness-j22NEcwR.js → Readiness-BbHO8wa2.js} +1 -1
- package/dist/web/assets/Record-P7TKcE5d.js +2 -0
- package/dist/web/assets/{Regression-ByBOHx96.js → Regression-BOSQ2Pxp.js} +1 -1
- package/dist/web/assets/{Reports-BGs_YnwI.js → Reports-BA1VdwoC.js} +1 -1
- package/dist/web/assets/{Response-DWF22-5i.js → Response-0i0ww7OC.js} +1 -1
- package/dist/web/assets/{RunDiff-YxrBVtxF.js → RunDiff-D-4tB7Is.js} +1 -1
- package/dist/web/assets/{Runs-CP3CgO6s.js → Runs-DW7dZh2j.js} +1 -1
- package/dist/web/assets/{TestCases-BzuM4M4t.js → TestCases-BfPkdwR6.js} +1 -1
- package/dist/web/assets/{TestData-CRmYpEgE.js → TestData-DRoJc7Me.js} +1 -1
- package/dist/web/assets/{TestDebt-D3I2zyGE.js → TestDebt-ly8BsLSJ.js} +1 -1
- package/dist/web/assets/{Tosca-jVIQnyZv.js → Tosca-CzrCAhEs.js} +1 -1
- package/dist/web/assets/{WhatsNew-EKniIJ6W.js → WhatsNew-Cd8D1O1X.js} +1 -1
- package/dist/web/assets/{dataParts-DRO6c2Kb.js → dataParts-DzHf4K4-.js} +1 -1
- package/dist/web/assets/{fold-D9yUIbTt.js → fold-CyU-Mjqe.js} +1 -1
- package/dist/web/assets/{frame--ur6lpMR.js → frame-DUo0M0VF.js} +2 -2
- package/dist/web/assets/index-Bv3atkwB.js +67 -0
- package/dist/web/assets/{logos-CdIbTq_J.js → logos-cftOc5MX.js} +1 -1
- package/dist/web/assets/{palette-D5_w8xup.js → palette-D_SCreF2.js} +1 -1
- package/dist/web/assets/{qualityParts-BPBFzuHH.js → qualityParts-50E_QRTX.js} +1 -1
- package/dist/web/assets/{rows-BVHC-HKz.js → rows-JZ5MvdCQ.js} +1 -1
- package/dist/web/assets/{thread-B4g66SWA.js → thread-CrExMoMY.js} +1 -1
- package/dist/web/assets/{usePageChat-BU6VEv0K.js → usePageChat-DpnA7edC.js} +1 -1
- package/dist/web/index.html +2 -2
- package/docs/WEB_APP.md +6 -2
- package/package.json +1 -1
- package/py/forgeqe_engine/browser.py +29 -0
- package/py/forgeqe_engine/capture.py +2 -2
- package/py/forgeqe_engine/dynamic.py +8 -0
- package/py/forgeqe_engine/memory.py +33 -2
- package/py/forgeqe_engine/recordsession.py +273 -22
- package/py/forgeqe_engine/webrecord.py +165 -2
- package/py/forgeqe_engine/webrecord_page.py +197 -11
- package/dist/web/assets/Record-D7h6g_aw.js +0 -2
- package/dist/web/assets/index-GLMqsotN.js +0 -66
|
@@ -38,6 +38,9 @@ NAV_CAUSED_SECONDS = 1.5
|
|
|
38
38
|
DOUBLE_CLICK_SECONDS = 0.5
|
|
39
39
|
MAX_TEXT = 200
|
|
40
40
|
EXPECT_KINDS = ("text", "visible", "hidden", "value", "checked", "url", "title", "intent")
|
|
41
|
+
# Browser dialogs a step can answer (Page.javascriptDialogOpening's types); a dialog's message is kept one line, clipped.
|
|
42
|
+
DIALOG_KINDS = ("alert", "confirm", "prompt", "beforeunload")
|
|
43
|
+
MAX_DIALOG_MESSAGE = 300
|
|
41
44
|
# Keys recorded inside a text field; any other key there is typing.
|
|
42
45
|
FIELD_KEYS = ("Enter", "Escape")
|
|
43
46
|
AUTOCOMPLETE_KEYS = ("ArrowDown", "ArrowUp")
|
|
@@ -264,7 +267,8 @@ def describe(step: Dict[str, Any]) -> str:
|
|
|
264
267
|
if op in ("click", "dblclick", "hover"):
|
|
265
268
|
pos = step.get("position") if isinstance(step.get("position"), dict) else None
|
|
266
269
|
at = f" at {pos.get('x')},{pos.get('y')}" if pos else ""
|
|
267
|
-
|
|
270
|
+
verb = "double-click" if op == "dblclick" else "right-click" if step.get("button") == "right" else op
|
|
271
|
+
return f"{verb} {label}{at}"
|
|
268
272
|
if op == "input":
|
|
269
273
|
if step.get("text_env"):
|
|
270
274
|
return f"type ${step['text_env']} into {label}"
|
|
@@ -283,6 +287,20 @@ def describe(step: Dict[str, Any]) -> str:
|
|
|
283
287
|
return f"wait for {label}"
|
|
284
288
|
if op == "captcha":
|
|
285
289
|
return f"solve the {step.get('provider') or 'CAPTCHA'} (a person; a test turns it off)"
|
|
290
|
+
if op == "dialog":
|
|
291
|
+
return dialog_words(step)
|
|
292
|
+
if op == "scroll":
|
|
293
|
+
where = f" in {label}" if step.get("locators") else ""
|
|
294
|
+
return f"scroll {'down' if step.get('down', True) else 'up'} {step.get('pages', 1)} screen{'s' if step.get('pages', 1) != 1 else ''}{where}"
|
|
295
|
+
if op == "download":
|
|
296
|
+
changes = " (its name changes; matched by its pattern)" if step.get("file_pattern") else ""
|
|
297
|
+
return f"the file {step.get('file')!r} downloads{changes}"
|
|
298
|
+
if op == "drag":
|
|
299
|
+
to = step.get("to") if isinstance(step.get("to"), dict) else None
|
|
300
|
+
if to:
|
|
301
|
+
return f"drag {label} onto {to.get('label') or 'element'}"
|
|
302
|
+
off = step.get("offset") if isinstance(step.get("offset"), dict) else {}
|
|
303
|
+
return f"drag {label} by {off.get('x', 0)},{off.get('y', 0)}"
|
|
286
304
|
if op == "upload":
|
|
287
305
|
names = list(step.get("files") or []) + [os.path.basename(f) for f in step.get("run_files") or []]
|
|
288
306
|
return f"{'drop' if step.get('drop') else 'upload'} {', '.join(names)} {'onto' if step.get('drop') else 'into'} {label}"
|
|
@@ -306,6 +324,39 @@ def describe(step: Dict[str, Any]) -> str:
|
|
|
306
324
|
return op
|
|
307
325
|
|
|
308
326
|
|
|
327
|
+
MAX_FILE_NAME = 200
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def download_name(raw: Any) -> str:
|
|
331
|
+
"""
|
|
332
|
+
A downloaded file's name as a step keeps it: the page's suggestion, its last part only (never a folder), one line
|
|
333
|
+
of plain characters, clipped; "" for none. It is data: a replay compares it, and saves the file by its own name.
|
|
334
|
+
"""
|
|
335
|
+
name = re.split(r"[\\/]", str(raw or ""))[-1]
|
|
336
|
+
name = "".join(ch for ch in name if ch.isprintable()).strip().strip(".")
|
|
337
|
+
return name[:MAX_FILE_NAME]
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def dialog_message(raw: Any) -> str:
|
|
341
|
+
"""A dialog's message as a step keeps it: page text, one line, clipped (never markup or a command)."""
|
|
342
|
+
text = " ".join(str(raw or "").split())
|
|
343
|
+
return text if len(text) <= MAX_DIALOG_MESSAGE else text[: MAX_DIALOG_MESSAGE - 1] + "…"
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def dialog_words(step: Dict[str, Any]) -> str:
|
|
347
|
+
"""A dialog step in words: what the page asked and how it was answered."""
|
|
348
|
+
kind, ok = step.get("kind"), bool(step.get("accept"))
|
|
349
|
+
said = f" {step['message']!r}" if step.get("message") else ""
|
|
350
|
+
if kind == "beforeunload":
|
|
351
|
+
return "leave the page when it asks" if ok else "stay on the page when it asks"
|
|
352
|
+
if kind == "alert":
|
|
353
|
+
return f"close the alert{said}"
|
|
354
|
+
if kind == "prompt" and ok:
|
|
355
|
+
given = f"${step['text_env']}" if step.get("text_env") else repr(step.get("text") or "")
|
|
356
|
+
return f"answer the prompt{said} with {given}"
|
|
357
|
+
return f"answer the {kind}{said} with {'OK' if ok else 'Cancel'}"
|
|
358
|
+
|
|
359
|
+
|
|
309
360
|
@dataclass
|
|
310
361
|
class WebRecorder:
|
|
311
362
|
start_url: str
|
|
@@ -357,11 +408,20 @@ class WebRecorder:
|
|
|
357
408
|
self._add({"op": "navigate", "url": url})
|
|
358
409
|
return f"open {url}"
|
|
359
410
|
|
|
360
|
-
def on_click(self, t: Target, *, hover: Optional[Target] = None) -> Optional[str]:
|
|
411
|
+
def on_click(self, t: Target, *, hover: Optional[Target] = None, right: bool = False) -> Optional[str]:
|
|
361
412
|
if self.paused:
|
|
362
413
|
return None
|
|
363
414
|
at = self.clock()
|
|
364
415
|
self._last_action = at
|
|
416
|
+
if right:
|
|
417
|
+
# A right-click (the page's own context menu): never half of a double-click.
|
|
418
|
+
self._last_click = None
|
|
419
|
+
if hover is not None and hover.key != t.key:
|
|
420
|
+
prev = self.steps[-1]
|
|
421
|
+
if not (prev.get("op") == "hover" and _same(prev, hover)):
|
|
422
|
+
self._add({**element_step("hover", hover), "inferred": True})
|
|
423
|
+
self._add({**element_step("click", t), "button": "right"})
|
|
424
|
+
return describe(self.steps[-1])
|
|
365
425
|
last = self._last_click
|
|
366
426
|
if last is not None and last[0] == t.key and at - last[1] <= DOUBLE_CLICK_SECONDS and self.steps[-1].get("op") == "click":
|
|
367
427
|
self.steps[-1] = {**self.steps[-1], "op": "dblclick"}
|
|
@@ -375,6 +435,39 @@ class WebRecorder:
|
|
|
375
435
|
self._last_click = (t.key, at)
|
|
376
436
|
return describe(self.steps[-1])
|
|
377
437
|
|
|
438
|
+
def on_scroll(self, down: bool, pages: float, box: Optional[Target] = None) -> Optional[str]:
|
|
439
|
+
"""
|
|
440
|
+
The page (or `box`, a list that scrolls on its own) scrolled by the person, by screens: one step for scrolls
|
|
441
|
+
one after another the same way in the same place. A replay scrolls as far, so what loads on a scroll loads.
|
|
442
|
+
"""
|
|
443
|
+
if self.paused or not 0 < pages <= 50:
|
|
444
|
+
return None
|
|
445
|
+
self._last_action = self.clock()
|
|
446
|
+
self._last_click = None
|
|
447
|
+
prev = self.steps[-1]
|
|
448
|
+
same_place = (box is None and not prev.get("locators")) or (box is not None and _same(prev, box))
|
|
449
|
+
if prev.get("op") == "scroll" and bool(prev.get("down", True)) == down and same_place:
|
|
450
|
+
prev["pages"] = round(min(50.0, float(prev.get("pages") or 0) + pages), 1)
|
|
451
|
+
return describe(prev)
|
|
452
|
+
step: Dict[str, Any] = {**(element_step("scroll", box) if box is not None else {"op": "scroll", "page": page_id(self.url) or self.url}), "down": down, "pages": round(pages, 1)}
|
|
453
|
+
self._add(step)
|
|
454
|
+
return describe(step)
|
|
455
|
+
|
|
456
|
+
def on_hover(self, t: Target, *, inferred: bool = False) -> Optional[str]:
|
|
457
|
+
"""
|
|
458
|
+
A hover kept as a step: by the hover command (the element the pointer is on), or before a check of what only a
|
|
459
|
+
hover shows (`inferred`). Once: never right after the same hover.
|
|
460
|
+
"""
|
|
461
|
+
if self.paused:
|
|
462
|
+
return None
|
|
463
|
+
prev = self.steps[-1]
|
|
464
|
+
if prev.get("op") == "hover" and _same(prev, t):
|
|
465
|
+
return None
|
|
466
|
+
self._last_action = self.clock()
|
|
467
|
+
self._last_click = None
|
|
468
|
+
self._add({**element_step("hover", t), **({"inferred": True} if inferred else {})})
|
|
469
|
+
return describe(self.steps[-1])
|
|
470
|
+
|
|
378
471
|
def on_captcha(self, provider: str) -> Optional[str]:
|
|
379
472
|
"""
|
|
380
473
|
Something done in a CAPTCHA: one `captcha` step for it, however many clicks it took (the checkbox, the pictures,
|
|
@@ -389,6 +482,70 @@ class WebRecorder:
|
|
|
389
482
|
self._add({"op": "captcha", "provider": provider, "page": page_id(self.url) or self.url})
|
|
390
483
|
return describe(self.steps[-1])
|
|
391
484
|
|
|
485
|
+
def on_download(self, name: Any, size: Optional[int] = None) -> Optional[str]:
|
|
486
|
+
"""
|
|
487
|
+
A file the page downloaded after the step before (an "Export CSV" button): a step that checks a file of that
|
|
488
|
+
name arrives, by a pattern when part of the name changes on each run (a date, an id), and is not empty.
|
|
489
|
+
"""
|
|
490
|
+
if self.paused:
|
|
491
|
+
return None
|
|
492
|
+
file = download_name(name)
|
|
493
|
+
if not file:
|
|
494
|
+
return None
|
|
495
|
+
self._last_action = self.clock()
|
|
496
|
+
self._last_click = None
|
|
497
|
+
step: Dict[str, Any] = {"op": "download", "file": file, "page": page_id(self.url) or self.url}
|
|
498
|
+
pattern = dynamic.pattern_of(file, anchored=True)
|
|
499
|
+
if pattern:
|
|
500
|
+
step["file_pattern"] = pattern
|
|
501
|
+
if isinstance(size, int) and not isinstance(size, bool) and size >= 0:
|
|
502
|
+
step["bytes"] = size
|
|
503
|
+
self._add(step)
|
|
504
|
+
return describe(step)
|
|
505
|
+
|
|
506
|
+
def on_dialog(self, kind: str, message: Any, accept: bool, text: Any = None) -> Optional[str]:
|
|
507
|
+
"""
|
|
508
|
+
A browser dialog the page showed (an alert, a confirm, a prompt, or "leave this page?") and how the person answered
|
|
509
|
+
it: OK or Cancel, and a prompt's typed text. The step comes after the one that made the page ask; a replay answers
|
|
510
|
+
the dialog the same way when that step runs. Its message is page text: kept as data, one line.
|
|
511
|
+
"""
|
|
512
|
+
if self.paused or kind not in DIALOG_KINDS:
|
|
513
|
+
return None
|
|
514
|
+
self._last_action = self.clock()
|
|
515
|
+
self._last_click = None
|
|
516
|
+
step: Dict[str, Any] = {"op": "dialog", "kind": kind, "message": dialog_message(message), "accept": bool(accept), "page": page_id(self.url) or self.url}
|
|
517
|
+
if kind == "prompt" and accept:
|
|
518
|
+
value = _clip(" ".join(str(text or "").split()))
|
|
519
|
+
env = next((k for k, v in self.login_values.items() if v and value == v), None)
|
|
520
|
+
if env:
|
|
521
|
+
step.update(text="", text_env=env)
|
|
522
|
+
else:
|
|
523
|
+
var = next((k for k, v in self.variables.items() if v and value == v), None)
|
|
524
|
+
step["text"] = "{{%s}}" % var if var else value
|
|
525
|
+
self._add(step)
|
|
526
|
+
return describe(step)
|
|
527
|
+
|
|
528
|
+
def on_drag(self, t: Target, to: Optional[Target], offset: Optional[Dict[str, int]]) -> Optional[str]:
|
|
529
|
+
"""
|
|
530
|
+
An element the tester dragged: `t` the one taken (its position the point it was taken by), `to` the one it was let
|
|
531
|
+
go on (with the point), none when that is the same element (a slider's thumb, a pin that moves with the pointer),
|
|
532
|
+
and `offset` how far the pointer moved. A replay drags it with the mouse onto `to`, or by `offset`.
|
|
533
|
+
"""
|
|
534
|
+
if self.paused:
|
|
535
|
+
return None
|
|
536
|
+
self._last_action = self.clock()
|
|
537
|
+
self._last_click = None
|
|
538
|
+
step = element_step("drag", t)
|
|
539
|
+
if to is not None and not _same_element(t, to):
|
|
540
|
+
dst = element_step("drag", to)
|
|
541
|
+
step["to"] = {k: dst[k] for k in ("label", "best_locator", "position", "shadow", "locators", "locator", "frame", "frames") if dst.get(k)}
|
|
542
|
+
if offset:
|
|
543
|
+
step["offset"] = dict(offset)
|
|
544
|
+
if "to" not in step and "offset" not in step:
|
|
545
|
+
return None
|
|
546
|
+
self._add(step)
|
|
547
|
+
return describe(step)
|
|
548
|
+
|
|
392
549
|
def on_dblclick(self, t: Target) -> Optional[str]:
|
|
393
550
|
"""The browser's own double-click event: the two clicks before it on the element become one double-click."""
|
|
394
551
|
if self.paused:
|
|
@@ -738,6 +895,12 @@ def _name_hint(facts: Dict[str, Any]) -> str:
|
|
|
738
895
|
return str(facts.get("name") or "") if facts.get("tag") in ("input", "select", "textarea") else ""
|
|
739
896
|
|
|
740
897
|
|
|
898
|
+
def _same_element(a: Target, b: Target) -> bool:
|
|
899
|
+
"""Whether two targets are the same element: the same page, frames and best locator (wherever in it)."""
|
|
900
|
+
best = lambda t: (t.locators[0].get("type"), t.locators[0].get("value")) if t.locators else (None, None) # noqa: E731
|
|
901
|
+
return (a.url, a.frames, best(a)) == (b.url, b.frames, best(b))
|
|
902
|
+
|
|
903
|
+
|
|
741
904
|
def _same(step: Dict[str, Any], t: Target) -> bool:
|
|
742
905
|
"""Whether a recorded step acted on target `t`: the same page and the same best locator."""
|
|
743
906
|
locs = step.get("locators") or []
|
|
@@ -14,6 +14,8 @@ from __future__ import annotations
|
|
|
14
14
|
import json
|
|
15
15
|
from typing import Any, Dict
|
|
16
16
|
|
|
17
|
+
from .memory import STATE_CLASS
|
|
18
|
+
|
|
17
19
|
# The leader key, then one letter: what each letter does, as the key bar and the panel's hint show it.
|
|
18
20
|
COMMAND_KEYS = (
|
|
19
21
|
("a", "assert", "check an element"),
|
|
@@ -21,6 +23,7 @@ COMMAND_KEYS = (
|
|
|
21
23
|
("w", "wait", "wait for an element"),
|
|
22
24
|
("d", "data", "last typed value is test data"),
|
|
23
25
|
("n", "note", "add a note"),
|
|
26
|
+
("h", "hover", "hover the element under the pointer"),
|
|
24
27
|
("p", "pause", "pause / resume"),
|
|
25
28
|
("z", "undo", "undo last step"),
|
|
26
29
|
("s", "stop", "stop recording"),
|
|
@@ -137,7 +140,8 @@ RECORDER_JS = r"""(() => {
|
|
|
137
140
|
const attrs = {};
|
|
138
141
|
for (const k of CFG.kept) { const v = e.getAttribute(k); if (v) attrs[k] = v; }
|
|
139
142
|
const name = accName(e);
|
|
140
|
-
|
|
143
|
+
// Never a state class (active, selected, is-open): it moves to another element (memory.py STATE_CLASS).
|
|
144
|
+
const classes = [...e.classList].filter((c) => /^[A-Za-z_-][\w-]*$/.test(c) && !STATE_CLASS.test(c)).slice(0, 4);
|
|
141
145
|
return { tag: e.tagName.toLowerCase(), attributes: attrs, classes, xpath: xpath(e), role: e.getAttribute('role') || implicitRole(e), name: name.slice(0, 120), text: name ? '' : textOf(e).slice(0, 120) };
|
|
142
146
|
};
|
|
143
147
|
// How many elements each kind of locator for `e` matches right now, counted at the event: ForgeQE checks locators
|
|
@@ -152,14 +156,15 @@ RECORDER_JS = r"""(() => {
|
|
|
152
156
|
for (const [k, v] of Object.entries(f.attributes)) out.attr[k] = count('[' + k + '=' + q(v) + ']', rs);
|
|
153
157
|
if (f.attributes.name) out.name = count(f.tag + '[name=' + q(f.attributes.name) + ']', rs);
|
|
154
158
|
if (f.attributes.href) out.href = count('a[href=' + q(f.attributes.href) + ']', rs);
|
|
155
|
-
|
|
159
|
+
// The selector counted too: ForgeQE uses the count only for that same selector.
|
|
160
|
+
if (f.classes.length) { out.css_sel = f.tag + f.classes.slice(0, 2).map((c) => '.' + c).join(''); out.css = count(out.css_sel, rs); }
|
|
156
161
|
const t = f.text || f.name;
|
|
157
162
|
if (t) out.text = deepAll('*', rs).filter((x) => visible(x) && norm(x.textContent) === t && ![...x.children].some((c) => norm(c.textContent) === t)).length;
|
|
158
163
|
if (f.role && f.name) {
|
|
159
164
|
const same = deepAll(ROLE_SEL, rs).filter((x) => visible(x) && (x.getAttribute('role') || implicitRole(x)) === f.role);
|
|
160
165
|
out.role = same.filter((x) => accName(x) === f.name).length;
|
|
161
166
|
// The names of the others with this role, for a locator by part of the name, counted after the page is gone.
|
|
162
|
-
if (/\d/.test(f.name)) out.role_names = same.slice(0, 400).map((x) => accName(x).slice(0, 160));
|
|
167
|
+
if (/\d/.test(f.name) || f.name.length > 80) out.role_names = same.slice(0, 400).map((x) => accName(x).slice(0, 160));
|
|
163
168
|
}
|
|
164
169
|
if (f.name) out.label = deepAll('input, select, textarea, [aria-label]', rs).filter((x) => labelText(x) === f.name).length;
|
|
165
170
|
return out;
|
|
@@ -185,7 +190,9 @@ RECORDER_JS = r"""(() => {
|
|
|
185
190
|
if (x.tagName === 'FIELDSET') return 'group';
|
|
186
191
|
return '';
|
|
187
192
|
};
|
|
188
|
-
const stableClass = (c) => /^[A-Za-z][\w-]{2,40}$/.test(c) && !/\d{3,}|__|^(?:css|sc|jsx|svelte|emotion)-/i.test(c);
|
|
193
|
+
const stableClass = (c) => /^[A-Za-z][\w-]{2,40}$/.test(c) && !/\d{3,}|__|^(?:css|sc|jsx|svelte|emotion)-/i.test(c) && !STATE_CLASS.test(c);
|
|
194
|
+
// A class a page sets for a state (the item under the pointer, the one chosen, a menu open): it moves between elements.
|
|
195
|
+
const STATE_CLASS = new RegExp(CFG.stateClass, 'i');
|
|
189
196
|
const containerCss = (x) => { const c = [...x.classList].find(stableClass); return c ? x.tagName.toLowerCase() + '.' + c : ''; };
|
|
190
197
|
const lowText = (x) => norm(x.textContent).toLowerCase();
|
|
191
198
|
// The texts that could tell this container from the others: its headings, then its labels, then short texts of its own.
|
|
@@ -495,11 +502,21 @@ RECORDER_JS = r"""(() => {
|
|
|
495
502
|
const MENU = '[role=menu], [role=menubar] [role=menu], [role=listbox], ul ul, .dropdown-menu, .submenu, .sub-menu, [class*="dropdown"], [class*="submenu"], [class*="flyout"], [class*="mega"]';
|
|
496
503
|
const revealed = [];
|
|
497
504
|
let hovered = null;
|
|
505
|
+
// What shows soon after a press (a click's doing: a list of results, the fields a choice opens) is not a hover's.
|
|
506
|
+
let pressedAt = 0;
|
|
507
|
+
window.addEventListener('pointerdown', (ev) => { if (ev.isTrusted && !ours(ev)) pressedAt = Date.now(); }, true);
|
|
508
|
+
// Any element the pointer is on (an info icon, an abbreviation): what shows while it rests there is its tooltip or
|
|
509
|
+
// hover card. Kept apart ("loose") from a menu's trigger: a check of what it shows starts with hovering it.
|
|
510
|
+
let pointed = null;
|
|
498
511
|
const onReveal = (list) => {
|
|
499
|
-
if (
|
|
512
|
+
if (Date.now() - pressedAt < 1500) return;
|
|
513
|
+
const by = hovered && Date.now() - hovered.at <= 1500 ? hovered : null;
|
|
514
|
+
const loose = !by && pointed && Date.now() - pointed.at <= 1500 ? pointed : null;
|
|
515
|
+
if (!by && !loose) return;
|
|
516
|
+
const at = (by || loose).el;
|
|
500
517
|
for (const m of list) {
|
|
501
518
|
const n = m.type === 'childList' ? [...m.addedNodes].find((x) => x.nodeType === 1) : m.target;
|
|
502
|
-
if (n && n.nodeType === 1 && !deepContains(n,
|
|
519
|
+
if (n && n.nodeType === 1 && !deepContains(n, at) && n !== host && !deepContains(n, host)) revealed.push({ by: at, root: n, at: Date.now(), ...(loose ? { loose: true } : {}) });
|
|
503
520
|
}
|
|
504
521
|
if (revealed.length > 50) revealed.splice(0, revealed.length - 50);
|
|
505
522
|
};
|
|
@@ -520,18 +537,51 @@ RECORDER_JS = r"""(() => {
|
|
|
520
537
|
for (const type of ['mouseover', 'focusin', 'pointerdown']) window.addEventListener(type, (ev) => { if (ev.isTrusted && !ours(ev)) watchRoots(ev); }, true);
|
|
521
538
|
window.addEventListener('mouseover', (ev) => {
|
|
522
539
|
if (!ev.isTrusted || picking || ours(ev)) return;
|
|
540
|
+
const p = deep(ev);
|
|
541
|
+
if (p && p.nodeType === 1 && (!pointed || p !== pointed.el)) pointed = { el: p, at: Date.now() };
|
|
523
542
|
const t = deepClosest(deep(ev), TRIGGER);
|
|
524
543
|
if (t && (!hovered || t !== hovered.el)) hovered = { el: t, at: Date.now() };
|
|
525
544
|
}, true);
|
|
545
|
+
// Showing on the page now: a menu's trigger a person still points at, not one gone with its list.
|
|
546
|
+
const shows = (e) => { const r = e.getBoundingClientRect(); if (r.width < 1 || r.height < 1) return false; const cs = getComputedStyle(e); return cs.visibility !== 'hidden' && cs.display !== 'none'; };
|
|
547
|
+
// The hover command: a step that hovers what the pointer is on now (what shows then can be checked after it).
|
|
548
|
+
const hoverNow = () => {
|
|
549
|
+
if (paused) return;
|
|
550
|
+
const e = pointed && pointed.el;
|
|
551
|
+
if (!e || !e.isConnected || e === document.documentElement || e === document.body || e.tagName === 'IFRAME') {
|
|
552
|
+
say([[0, 'Point at the element to hover first, then press the keys']], 4000);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
if (dirty) flush();
|
|
556
|
+
send({ kind: 'hover', ...describeEl(hoverable(e)) });
|
|
557
|
+
};
|
|
558
|
+
// The element a hover is kept for: the control around what the pointer is on, else the nearest one a tooltip names
|
|
559
|
+
// (aria-describedby, a title, a test id, an id, a label), else that element.
|
|
560
|
+
const hoverable = (e) => {
|
|
561
|
+
for (let x = e, i = 0; x && x.nodeType === 1 && i <= 4 && x !== document.body; x = up(x), i++) {
|
|
562
|
+
if (actionable(x) || x.hasAttribute('aria-describedby') || x.hasAttribute('title') || x.hasAttribute('data-tooltip') || named(x)) return x;
|
|
563
|
+
}
|
|
564
|
+
return e;
|
|
565
|
+
};
|
|
566
|
+
// What a check of an element that shows only on a hover (a tooltip, a hover card) hovers first: the element the
|
|
567
|
+
// pointer rested on when it showed, still on the page.
|
|
568
|
+
const hoverForCheck = (c) => {
|
|
569
|
+
for (let i = revealed.length - 1; i >= 0; i--) {
|
|
570
|
+
const r = revealed[i];
|
|
571
|
+
if (deepContains(r.root, c) && r.by !== c && !deepContains(r.by, c) && r.by.isConnected && shows(r.by) && Date.now() - r.at < 60000) return hoverable(r.by);
|
|
572
|
+
}
|
|
573
|
+
return null;
|
|
574
|
+
};
|
|
526
575
|
const hoverFor = (c) => {
|
|
527
576
|
for (let i = revealed.length - 1; i >= 0; i--) {
|
|
528
577
|
const r = revealed[i];
|
|
529
|
-
if (deepContains(r.root, c) && r.by !== c && !deepContains(r.by, c) && r.by.isConnected && Date.now() - r.at < 60000) return r.by;
|
|
578
|
+
if (!r.loose && deepContains(r.root, c) && r.by !== c && !deepContains(r.by, c) && r.by.isConnected && shows(r.by) && Date.now() - r.at < 60000) return r.by;
|
|
530
579
|
}
|
|
531
580
|
for (let e = up(c), i = 0; e && e !== document.body && i < 8; e = up(e), i++) {
|
|
532
581
|
if (!e.matches(MENU)) continue;
|
|
533
582
|
const owner = up(e);
|
|
534
|
-
|
|
583
|
+
// A menu placed straight in the page (a context menu, a popup): its siblings are the page, not its trigger.
|
|
584
|
+
if (!owner || owner === document.body || owner === document.documentElement || !owner.matches(':hover')) continue;
|
|
535
585
|
const trig = [...owner.children].find((x) => x !== e && !deepContains(x, c) && (x.matches(TRIGGER) || (x.querySelector && x.querySelector('a, button'))));
|
|
536
586
|
if (trig) return trig.matches(TRIGGER) ? trig : trig.querySelector('a, button');
|
|
537
587
|
}
|
|
@@ -590,13 +640,16 @@ RECORDER_JS = r"""(() => {
|
|
|
590
640
|
let lastLabel = null;
|
|
591
641
|
window.addEventListener('click', (ev) => {
|
|
592
642
|
if (!ev.isTrusted || ours(ev)) return;
|
|
643
|
+
// The click a browser fires where a mouse drag ended: part of the drag.
|
|
644
|
+
if (!picking && Date.now() - dragClick < 400) { dragClick = 0; return; }
|
|
593
645
|
if (picking) {
|
|
594
646
|
ev.preventDefault(); ev.stopImmediatePropagation();
|
|
595
647
|
const e = pickable(pickTarget(ev));
|
|
596
648
|
const purpose = picking.purpose;
|
|
597
649
|
endPick();
|
|
598
650
|
if (!e) return;
|
|
599
|
-
|
|
651
|
+
const h = hoverForCheck(e);
|
|
652
|
+
send({ kind: 'pick', purpose, ...describeEl(e), text: shown(e), password: isPassword(e), checked: 'checked' in e ? !!e.checked : null, field: e.tagName === 'INPUT' || e.tagName === 'TEXTAREA' || e.tagName === 'SELECT', ...(h ? { hover: describeEl(h) } : {}) });
|
|
600
653
|
return;
|
|
601
654
|
}
|
|
602
655
|
if (paused) return;
|
|
@@ -611,12 +664,144 @@ RECORDER_JS = r"""(() => {
|
|
|
611
664
|
const h = hoverFor(c);
|
|
612
665
|
send({ kind: 'click', ...describeEl(c), field: isField(c), ...(h ? { hover: describeEl(h) } : {}), ...where(c, ev) });
|
|
613
666
|
}, true);
|
|
667
|
+
// ---- scrolls: the page, or a box that scrolls on its own (a list that loads more at its end), by the person's wheel
|
|
668
|
+
// or keys (never one the page made: an anchor, its own script). One step when it settles, if it went half a screen.
|
|
669
|
+
const SCROLL_KEYS = new Set(['PageDown', 'PageUp', 'ArrowDown', 'ArrowUp', 'End', 'Home', ' ']);
|
|
670
|
+
let scrollBy = 0, scrolled = null;
|
|
671
|
+
window.addEventListener('wheel', (ev) => { if (ev.isTrusted && !ours(ev)) scrollBy = Date.now(); }, { capture: true, passive: true });
|
|
672
|
+
window.addEventListener('keydown', (ev) => { if (ev.isTrusted && !ours(ev) && SCROLL_KEYS.has(ev.key) && !isField(deep(ev))) scrollBy = Date.now(); }, true);
|
|
673
|
+
const scrollTop = (box) => (box ? box.scrollTop : (document.scrollingElement || document.documentElement).scrollTop);
|
|
674
|
+
const endScroll = () => {
|
|
675
|
+
const s = scrolled;
|
|
676
|
+
scrolled = null;
|
|
677
|
+
if (!s || paused || picking) return;
|
|
678
|
+
const height = s.box ? s.box.clientHeight : innerHeight;
|
|
679
|
+
const dy = scrollTop(s.box) - s.top;
|
|
680
|
+
if (!height || Math.abs(dy) < height / 2) return;
|
|
681
|
+
if (s.box && !s.box.isConnected) return;
|
|
682
|
+
send({ kind: 'scroll', down: dy > 0, pages: Math.round(Math.abs(dy) / height * 10) / 10, ...(s.box ? { box: describeEl(s.box) } : {}) });
|
|
683
|
+
};
|
|
684
|
+
window.addEventListener('scroll', (ev) => {
|
|
685
|
+
if (!ev.isTrusted || paused || picking || Date.now() - scrollBy > 1500) return;
|
|
686
|
+
const t = ev.target;
|
|
687
|
+
const box = !t || t === document || t === document.documentElement || t === document.body || t.nodeType !== 1 ? null : t;
|
|
688
|
+
if (box && (box === host || ours(ev))) return;
|
|
689
|
+
if (scrolled && scrolled.box !== box) { clearTimeout(scrolled.timer); endScroll(); }
|
|
690
|
+
if (!scrolled) scrolled = { box, top: scrollTop(box) - 0, timer: 0 };
|
|
691
|
+
clearTimeout(scrolled.timer);
|
|
692
|
+
scrolled.timer = setTimeout(endScroll, 700);
|
|
693
|
+
}, true);
|
|
694
|
+
// A right-click (a page's own context menu): a click with the right button, on the control it was on.
|
|
695
|
+
window.addEventListener('contextmenu', (ev) => {
|
|
696
|
+
if (!ev.isTrusted || picking || ours(ev) || paused || ev.button !== 2) return;
|
|
697
|
+
const c = control(deep(ev));
|
|
698
|
+
if (!c || c === document.documentElement || c === document.body) return;
|
|
699
|
+
if (dirty) flush();
|
|
700
|
+
send({ kind: 'click', button: 'right', ...describeEl(c), ...where(c, ev) });
|
|
701
|
+
}, true);
|
|
614
702
|
window.addEventListener('dblclick', (ev) => {
|
|
615
703
|
if (!ev.isTrusted || picking || ours(ev) || paused) return;
|
|
616
704
|
const c = control(deep(ev));
|
|
617
705
|
if (c && !isField(c)) send({ kind: 'dblclick', ...describeEl(c), ...where(c, ev) });
|
|
618
706
|
}, true);
|
|
619
|
-
|
|
707
|
+
// ---- drags: an element moved with the mouse (a list's item, a card, a slider's thumb, a map's pin), or dragged the
|
|
708
|
+
// browser's own way (draggable): one step, from where it was taken to where it was let go. The element let go on, a
|
|
709
|
+
// point in each (from its top left), and how far the pointer moved; the click a browser fires after it is not a step.
|
|
710
|
+
const DRAG_MIN = 8;
|
|
711
|
+
const DRAG_TAKE = new Set(['listitem', 'option', 'row', 'treeitem', 'gridcell', 'slider', 'img', 'button', 'link', 'tab']);
|
|
712
|
+
const DRAG_DROP = new Set(['listitem', 'list', 'listbox', 'row', 'grid', 'table', 'region', 'group', 'tabpanel', 'tree', 'treeitem', 'gridcell', 'cell', 'application', 'img']);
|
|
713
|
+
const roleOf = (e) => (e.getAttribute && e.getAttribute('role')) || implicitRole(e);
|
|
714
|
+
// The element that moves or that takes it: the nearest one a test can name (draggable, a role of a list or a table, a
|
|
715
|
+
// test id, an id, a label), else the one under the pointer.
|
|
716
|
+
const named = (e) => e.hasAttribute('data-testid') || e.hasAttribute('data-test') || e.hasAttribute('data-cy') || !!e.id || e.hasAttribute('aria-label');
|
|
717
|
+
const dragEnd = (node, roles, tags) => {
|
|
718
|
+
let e = node && node.nodeType === 1 ? node : node && node.parentElement;
|
|
719
|
+
for (let i = 0, c = e; c && i <= 6 && c !== document.body && c !== document.documentElement; i++, c = up(c)) {
|
|
720
|
+
if (c.getAttribute('draggable') === 'true' || roles.has(roleOf(c)) || tags.test(c.tagName) || named(c)) return c;
|
|
721
|
+
}
|
|
722
|
+
return e;
|
|
723
|
+
};
|
|
724
|
+
const taken = (n) => dragEnd(n, DRAG_TAKE, /^(LI|TR|IMG|CANVAS|INPUT)$/);
|
|
725
|
+
const takes = (n) => dragEnd(n, DRAG_DROP, /^(LI|UL|OL|TR|TD|TABLE|SECTION|CANVAS|IMG)$/);
|
|
726
|
+
const at = (e, x, y) => { const r = e.getBoundingClientRect(); const w = Math.max(0, Math.round(r.width)), h = Math.max(0, Math.round(r.height)); return { x: Math.min(w, Math.max(0, Math.round(x - r.left))), y: Math.min(h, Math.max(0, Math.round(y - r.top))) }; };
|
|
727
|
+
// What is under the pointer, through open shadow roots, leaving out the element that moves (and what is inside it).
|
|
728
|
+
const atPoint = (x, y, skip) => {
|
|
729
|
+
let scope = document, found = null;
|
|
730
|
+
for (let d = 0; d < 8 && scope; d++) {
|
|
731
|
+
const hit = (scope.elementsFromPoint ? scope.elementsFromPoint(x, y) : []).find((e) => e !== document.documentElement && e !== document.body && !(skip && (e === skip || skip.contains(e))));
|
|
732
|
+
if (!hit || hit === found) break;
|
|
733
|
+
found = hit;
|
|
734
|
+
scope = hit.shadowRoot || null;
|
|
735
|
+
}
|
|
736
|
+
return found;
|
|
737
|
+
};
|
|
738
|
+
const sendDrag = (src, sx, sy, dst, x, y, native) => {
|
|
739
|
+
if (!src || !src.isConnected) return;
|
|
740
|
+
// Let go on the element itself or on what holds it (a slider's track): moved by the offset only.
|
|
741
|
+
const apart = (e) => e && e !== src && !src.contains(e) && !e.contains(src);
|
|
742
|
+
const to = apart(dst) && apart(takes(dst)) ? takes(dst) : null;
|
|
743
|
+
send({ kind: 'drag', native: !!native, source: { ...describeEl(src), position: at(src, sx, sy) }, ...(to && to !== src ? { target: { ...describeEl(to), position: at(to, x, y) } } : {}), offset: { x: Math.round(x - sx), y: Math.round(y - sy) } });
|
|
744
|
+
};
|
|
745
|
+
let press = null, dragged = null, dragClick = 0;
|
|
746
|
+
window.addEventListener('pointerdown', (ev) => {
|
|
747
|
+
press = null;
|
|
748
|
+
if (!ev.isTrusted || ours(ev) || paused || picking || ev.button !== 0 || !ev.isPrimary) return;
|
|
749
|
+
const t = deep(ev);
|
|
750
|
+
// Selecting text in a field, or the page's scroll bar, is not a drag.
|
|
751
|
+
if (!t || isField(t) || t.tagName === 'SELECT' || t.tagName === 'OPTION') return;
|
|
752
|
+
// On the page itself: never a drag, but the click after a sweep is not a step either.
|
|
753
|
+
if (t === document.documentElement || t === document.body) { press = { el: t, x: ev.clientX, y: ev.clientY, moved: false, src: null }; return; }
|
|
754
|
+
const src = taken(t);
|
|
755
|
+
const r = src.getBoundingClientRect();
|
|
756
|
+
press = { el: t, x: ev.clientX, y: ev.clientY, moved: false, src, left: r.left, top: r.top };
|
|
757
|
+
}, true);
|
|
758
|
+
// A mouse drag is a step only on an element that moves: one the drag moved, one the page says can be moved (a grab or
|
|
759
|
+
// move cursor, draggable), or an item of a list or a table, a slider, an image or a canvas. A sweep over a page is not.
|
|
760
|
+
const MOVE_CURSOR = /^(grab|grabbing|move|all-scroll|[nsew]{1,2}-resize|col-resize|row-resize)$/;
|
|
761
|
+
const movable = (p) => {
|
|
762
|
+
const r = p.src.getBoundingClientRect();
|
|
763
|
+
if (Math.abs(r.left - p.left) >= 4 || Math.abs(r.top - p.top) >= 4) return true;
|
|
764
|
+
for (let e = p.el, i = 0; e && e.nodeType === 1 && i <= 6; e = up(e), i++) {
|
|
765
|
+
if (e.getAttribute('draggable') === 'true' || MOVE_CURSOR.test(getComputedStyle(e).cursor)) return true;
|
|
766
|
+
if (e === p.src) break;
|
|
767
|
+
}
|
|
768
|
+
const role = roleOf(p.src);
|
|
769
|
+
return ['listitem', 'option', 'row', 'treeitem', 'slider', 'img'].includes(role) || /^(LI|TR|IMG|CANVAS)$/.test(p.src.tagName) || (p.src.tagName === 'INPUT' && (p.src.getAttribute('type') || '').toLowerCase() === 'range');
|
|
770
|
+
};
|
|
771
|
+
window.addEventListener('pointermove', (ev) => {
|
|
772
|
+
if (press && !press.moved && ev.isTrusted && (ev.buttons & 1) && Math.hypot(ev.clientX - press.x, ev.clientY - press.y) >= DRAG_MIN) press.moved = true;
|
|
773
|
+
}, true);
|
|
774
|
+
window.addEventListener('pointercancel', () => { if (!dragged) press = null; }, true);
|
|
775
|
+
window.addEventListener('pointerup', (ev) => {
|
|
776
|
+
const p = press;
|
|
777
|
+
press = null;
|
|
778
|
+
if (!p || !p.moved || !ev.isTrusted || ours(ev) || paused || picking || dragged) return;
|
|
779
|
+
// A press that moved is not a click a person meant: the click the browser fires after it is no step either way.
|
|
780
|
+
dragClick = Date.now();
|
|
781
|
+
// Text selected by the drag: a person selecting text, not moving an element.
|
|
782
|
+
const sel = window.getSelection && window.getSelection();
|
|
783
|
+
if (sel && !sel.isCollapsed && String(sel).trim()) return;
|
|
784
|
+
if (!p.src || !movable(p)) return;
|
|
785
|
+
if (dirty) flush();
|
|
786
|
+
sendDrag(p.src, p.x, p.y, atPoint(ev.clientX, ev.clientY, p.src), ev.clientX, ev.clientY, false);
|
|
787
|
+
}, true);
|
|
788
|
+
// The browser's own drag (a draggable element): from dragstart to the drop the page took.
|
|
789
|
+
window.addEventListener('dragstart', (ev) => {
|
|
790
|
+
if (!ev.isTrusted || paused || picking || ours(ev)) return;
|
|
791
|
+
const p = press;
|
|
792
|
+
const t = deep(ev);
|
|
793
|
+
dragged = { el: t && t.nodeType === 1 ? (t.getAttribute('draggable') === 'true' ? t : taken(t)) : null, x: p ? p.x : ev.clientX, y: p ? p.y : ev.clientY };
|
|
794
|
+
press = null;
|
|
795
|
+
}, true);
|
|
796
|
+
window.addEventListener('drop', (ev) => {
|
|
797
|
+
const d = dragged;
|
|
798
|
+
if (!d || !ev.isTrusted || paused || picking || ours(ev)) return;
|
|
799
|
+
if (ev.dataTransfer && ev.dataTransfer.files && ev.dataTransfer.files.length) return;
|
|
800
|
+
dragged = null;
|
|
801
|
+
if (dirty) flush();
|
|
802
|
+
sendDrag(d.el, d.x, d.y, deep(ev), ev.clientX, ev.clientY, true);
|
|
803
|
+
}, true);
|
|
804
|
+
window.addEventListener('dragend', () => { dragged = null; }, true);
|
|
620
805
|
// Files dropped on the page from this computer (a drop zone): an upload. The files are kept here, by number, for
|
|
621
806
|
// ForgeQE to read their paths through the DevTools protocol (the page itself only sees their names).
|
|
622
807
|
const drops = [];
|
|
@@ -649,6 +834,7 @@ RECORDER_JS = r"""(() => {
|
|
|
649
834
|
ev.preventDefault(); ev.stopImmediatePropagation();
|
|
650
835
|
tip.style.display = 'none';
|
|
651
836
|
const hit = CFG.commands.find(([k]) => k === ev.key.toLowerCase());
|
|
837
|
+
if (hit && hit[1] === 'hover') { hoverNow(); return true; }
|
|
652
838
|
if (hit) { if (dirty) flush(); picks(hit[1]); send({ kind: 'command', cmd: hit[1] }); }
|
|
653
839
|
return true;
|
|
654
840
|
}
|
|
@@ -709,5 +895,5 @@ RECORDER_JS = r"""(() => {
|
|
|
709
895
|
|
|
710
896
|
def recorder_js(binding: str, kept: Any, *, leader: Dict[str, Any], badge: bool = False) -> str:
|
|
711
897
|
"""The page script; ``badge``: no panel, only a badge that says it records (a recording started from the web app)."""
|
|
712
|
-
config = {"binding": binding, "kept": list(kept), "leader": leader, "commands": [list(c) for c in COMMAND_KEYS], "badge": bool(badge)}
|
|
898
|
+
config = {"binding": binding, "kept": list(kept), "leader": leader, "commands": [list(c) for c in COMMAND_KEYS], "badge": bool(badge), "stateClass": STATE_CLASS}
|
|
713
899
|
return RECORDER_JS.replace("__CONFIG__", json.dumps(config))
|