fix(chrome): emit every markup attribute and read checked and selected off the property

the dump emitted a fixed standard attribute set, so a spec reading data-cents or data-account-id saw undefined on the goja host and nothing at all in the trace. it now keys every attribute by the name the markup writes, derived keys overwriting. checked and selected come from the dom property rather than whatever a component left on the object, which is also what the page-side element handle now reports, so a ticked box reads as ticked instead of reporting its starting state forever.
This commit is contained in:
pj committed 2026-08-16 17:44:04 +05:30
1 parent de654334b0
commit 05c8523762
8 files changed
+605 -2

No files matched your search

+46
View File
@@ -1038,3 +1038,49 @@ func TestEvaluateExtractors_RejectsAnUnenvelopedReading(t *testing.T) {
t.Errorf("EvaluateExtractors failed with %q, want it to name the bundle mismatch", err)
}
}
// TestHierarchy_CarriesEveryMarkupAttribute covers the data the spec actually
// reads. folio-web's extractors read data-cents, data-account-id and
// data-balance off the elements they find; the dump used to emit a fixed
// standard set, so those values were absent from the goja host and from every
// stored trace, and a selector over them resolved nothing offline.
func TestHierarchy_CarriesEveryMarkupAttribute(t *testing.T) {
const html = `<body>` +
`<div id="total-balance" data-cents="125000">$1,250.00</div>` +
`<div id="card" data-testid="account-card" data-account-id="acct-7" data-balance="4200">Tim</div>` +
`</body>`
d := New()
defer d.Terminate(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
if err := d.Launch(ctx, "data:text/html,"+html, false, nil); err != nil {
t.Fatalf("Launch: %v", err)
}
dump, err := d.Hierarchy(ctx)
if err != nil {
t.Fatalf("Hierarchy: %v", err)
}
tree, err := hierarchy.Parse(dump)
if err != nil {
t.Fatalf("parse hierarchy: %v", err)
}
total := tree.Find("id:total-balance")
if total == nil {
t.Fatal("total-balance not in the dump")
}
if got := total.Attributes["data-cents"]; got != "125000" {
t.Errorf(`attrs["data-cents"] = %q, want "125000"`, got)
}
card := tree.Find(`data-account-id:acct-7`)
if card == nil {
t.Fatal("no element resolves by a data attribute the markup carries")
}
if got := card.Attributes["data-balance"]; got != "4200" {
t.Errorf(`attrs["data-balance"] = %q, want "4200"`, got)
}
if got := card.Attributes["data-testid"]; got != "account-card" {
t.Errorf(`attrs["data-testid"] = %q, want "account-card"`, got)
}
}