mosaic-headless 1.34.9 → 1.36.0

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.
Files changed (37) hide show
  1. package/SKILL.md +96 -58
  2. package/assets/templates/platforms/claude-ai.json +1 -1
  3. package/assets/templates/platforms/claude-code.json +1 -1
  4. package/assets/templates/platforms/codex-cli.json +1 -1
  5. package/assets/templates/platforms/copilot.json +1 -1
  6. package/assets/templates/platforms/gemini-cli.json +1 -1
  7. package/data/component-wall-verification.csv +2 -1
  8. package/data/data-class-hierarchy.csv +6 -1
  9. package/data/default-children.csv +2 -0
  10. package/data/form-surface-verification.csv +8 -3
  11. package/data/interaction-types.csv +1 -1
  12. package/data/interaction-verification.csv +4 -0
  13. package/data/node-properties.csv +15 -10
  14. package/data/node-types.csv +7 -2
  15. package/data/node-verification.csv +7 -2
  16. package/data/placement-rules.csv +7 -2
  17. package/data/style-properties.csv +4 -4
  18. package/data/style-state-verification.csv +16 -9
  19. package/data/style-states.csv +11 -8
  20. package/data/tutorial-recipes-verification.csv +17 -0
  21. package/package.json +1 -1
  22. package/references/design-system.md +14 -0
  23. package/references/failure-modes.md +12 -4
  24. package/references/interactions.md +91 -48
  25. package/references/placement.md +5 -5
  26. package/references/tutorials.md +57 -0
  27. package/references/upgrading.md +67 -1
  28. package/scripts/check-release.mjs +7 -6
  29. package/sites/_forms.py +53 -11
  30. package/tools/build_page.py +3 -1
  31. package/tools/interactions.py +215 -0
  32. package/tools/probe_accordion.py +1 -1
  33. package/tools/sweep_components.py +1 -1
  34. package/tools/sweep_interactions.py +28 -1
  35. package/tools/sweep_style_states.py +1 -1
  36. package/tools/verify_components.py +57 -2
  37. package/tools/verify_recipes.py +307 -0
package/sites/_forms.py CHANGED
@@ -15,8 +15,14 @@ Shapes, read out of the source rather than guessed:
15
15
  choice-label its text
16
16
  radio-input or checkbox-input, carrying `value`
17
17
 
18
- select-input nameAttribute, required, multiple, size
19
- select-option value + its text
18
+ select nameAttribute, required, defaultValue (1.0.12)
19
+ select-toggle the visible box
20
+ select-placeholder > text, shown until something is picked
21
+ icon the chevron
22
+ select-options the list
23
+ select-option value, selected; its label is a CHILD (text)
24
+ listbox the native <select>: multiple, size >= 2
25
+ listbox-option value + its `text` property (a leaf)
20
26
 
21
27
  form-multi-steps
22
28
  form-multi-steps-steps > form-multi-steps-step the tab bar
@@ -82,9 +88,18 @@ def labelled(attr, text, node_type, **data):
82
88
  ])
83
89
 
84
90
 
91
+ # the toggle's default chevron, verbatim from SelectToggleElementTypeFactory
92
+ CHEVRON = ('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" '
93
+ 'fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" '
94
+ 'stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>')
95
+
96
+
85
97
  def select(attr, label, name, options, **extra):
86
98
  d = {"attrID": attr, "nameAttribute": name}
87
99
  d.update(extra)
100
+ prompt = "請選擇"
101
+ if options and options[0][0] == "":
102
+ prompt, options = options[0][1], options[1:]
88
103
  return _field(attr, [
89
104
  {"type": "label", "data": {"attrID": attr + "-lab", "forInput": attr},
90
105
  "style": {"&": {"_": {"fontFamily": MONO, "fontSize": "10px",
@@ -92,15 +107,42 @@ def select(attr, label, name, options, **extra):
92
107
  "color": {"token": "--mk-faint"}},
93
108
  "_t": {"fontSize": "12px"}}},
94
109
  "children": [{"type": "wysiwyg-text", "data": {"text": label}}]},
95
- {"type": "select-input", "data": d, "style": FIELD_STYLE,
110
+ # 1.0.12 replaced the native <select> (`select-input`, whose options were
111
+ # leaves carrying a `text` property) with a buildable one, rendered as
112
+ # <mosaic-select>: a combobox button plus a listbox, and a hidden input
113
+ # that carries the value into the submission. The shape is the factory
114
+ # defaults (SelectElementTypeFactory), the same one the 1.0.12 data
115
+ # upgrade wrote over the old select on this page:
116
+ # select > select-toggle > (select-placeholder > text, icon chevron)
117
+ # > select-options > select-option > text (any children)
118
+ # The visible box is the TOGGLE, so the field chrome goes there; the root
119
+ # keeps the width and the font the options inherit. An empty-valued first
120
+ # option is what a native select used as its prompt - here that is the
121
+ # placeholder's job. The native control survives as `listbox`
122
+ # (multiple / size > 1), whose `listbox-option` is still a leaf with `text`.
123
+ {"type": "select", "data": d,
124
+ "style": {"&": {"_": {"width": "100%", "fontFamily": CJK, "fontSize": "14px"}}},
96
125
  "children": [
97
- # `select-option` is a LEAF. Its label is the `text` property, not
98
- # a child - commit a wysiwyg-text under it and the option renders
99
- # with an empty label and the dropdown looks blank. Its other
100
- # properties are `value`, `selected` and `disabled`.
101
- {"type": "select-option",
102
- "data": {"attrID": "%s-o%d" % (attr, i), "value": v, "text": t}}
103
- for i, (v, t) in enumerate(options)]},
126
+ {"type": "select-toggle", "data": {}, # the root's attrID lands here as the id
127
+ "style": {"&": {"_": dict(FIELD_STYLE["&"]["_"], **{
128
+ "display": "flex", "justifyContent": "space-between",
129
+ "alignItems": "center", "columnGap": "10px"})},
130
+ "focus-visible": FIELD_STYLE["focus-visible"]},
131
+ "children": [
132
+ {"type": "select-placeholder", "data": {},
133
+ "children": [{"type": "wysiwyg-text", "data": {"text": prompt}}]},
134
+ {"type": "icon", "data": {"svg": CHEVRON}}]},
135
+ {"type": "select-options", "data": {"attrID": attr + "-list"},
136
+ "style": {"&": {"_": {"backgroundColor": {"token": "--mk-paper"},
137
+ "customDeclarations": "border:1px solid rgba(22,24,28,.3);"}}},
138
+ "children": [
139
+ {"type": "select-option",
140
+ "data": {"attrID": "%s-o%d" % (attr, i), "value": v},
141
+ "style": {"&": {"_": {"paddingTop": "10px", "paddingBottom": "10px",
142
+ "paddingLeft": "14px", "paddingRight": "14px"}}},
143
+ "children": [{"type": "wysiwyg-text", "data": {"text": t}}]}
144
+ for i, (v, t) in enumerate(options, 1)]},
145
+ ]},
104
146
  ])
105
147
 
106
148
 
@@ -475,7 +517,7 @@ TREE = {"type": "div", "data": {"attrID": "fm-page"},
475
517
  "children": [
476
518
  HEAD,
477
519
  band("fm-main", "ENQUIRY / 專案洽詢",
478
- "fieldset › label + text-input / select-input › select-option / "
520
+ "fieldset › label + text-input / select › toggle + options › option / "
479
521
  "choice-field › choice › radio-input + checkbox-input / "
480
522
  "fileupload-input / form-error / submit-loading",
481
523
  full_form(), bg="--mk-panel"),
@@ -436,7 +436,9 @@ def flatten(node, parent_id, master_id, surface, force, ordering="a0",
436
436
  data = dict(node.get("data") or {})
437
437
  style = to_style(node.get("style"))
438
438
  if style:
439
- data["style"] = style
439
+ # merge, not replace: data.style may already carry universalClasses or a
440
+ # variant, which the states from node["style"] must not wipe out
441
+ data["style"] = dict(data.get("style") or {}, **style)
440
442
  # A node that names a component becomes an INSTANCE of it, and an instance's
441
443
  # type carries the component's id after a slash - the factory splits on it, and
442
444
  # a bare `component-instance` has no id to read and fatals. `overrides` is not
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env python3
2
+ """Build Mosaic interactions in the shape the editor itself stores.
3
+
4
+ from interactions import tween, on, set_cookie, cookie_is, mode_switch, hide_at_end
5
+
6
+ reveal = on("elementScrollIntoView", [tween([("opacity", "0%", "100%")],
7
+ children=class_target(child_cls))],
8
+ trigger=class_target(section_cls), slot="in")
9
+
10
+ Every shape here was authored by hand in the 1.0.11 editor, read back out of
11
+ wp_mosaic_nodes, then written headlessly and checked against `var mosaicInteractions`
12
+ in the delivered page and in Chromium (data/interaction-verification.csv,
13
+ data/tutorial-recipes-verification.csv). The three rules that made animation values
14
+ bind, after every earlier attempt stored the timing and lost the values:
15
+
16
+ - `initial` and each keyframe's `properties` are keyed by the property META's
17
+ `uuid`, never by the property name;
18
+ - values are CSS strings with their unit - "0%", "40px" - not bare numbers;
19
+ - on a timed trigger (pageLoad, click, hover...) the keyframe carries `duration`
20
+ (and `delay`) in ms; on a progress trigger (scrollIntoView, pointerMove) it
21
+ carries `progressData` {delay, duration} as 0-100.
22
+
23
+ A bare number or a name key is accepted by the commit and silently dropped - the
24
+ negative controls in the sweep show both.
25
+ """
26
+ import uuid
27
+
28
+ # the 16 trigger ids; the editor's "Scroll into view" is elementScrollIntoView and
29
+ # its "While scrolling" is scrollIntoView (references/interactions.md)
30
+ PROGRESS = {"scrollIntoView", "pointerMove"}
31
+
32
+
33
+ def _id():
34
+ return str(uuid.uuid4())
35
+
36
+
37
+ def element(node_id):
38
+ return {"type": "element", "uuid": node_id}
39
+
40
+
41
+ def class_target(class_id):
42
+ """A universal class (the editor's "Class") as trigger or modifier target."""
43
+ return {"type": "universalClass", "uuid": class_id}
44
+
45
+
46
+ def variant_target(variant_id):
47
+ return {"type": "variant", "uuid": variant_id}
48
+
49
+
50
+ def _settings(target=None, children=None):
51
+ s = {}
52
+ if target:
53
+ s["target"] = target
54
+ if children:
55
+ s["targetModifiers"] = [{"uuid": _id(), "type": "children", "data": children}]
56
+ return s
57
+
58
+
59
+ def tween(props, duration=600, delay=0, target=None, children=None, progress=False,
60
+ easing=None):
61
+ """An animation action. props: [(property, initial, to)], values as CSS strings;
62
+ initial may be None. Property names are data/animatable-properties.csv.
63
+
64
+ target None means the element that fired the trigger - with a class trigger,
65
+ each element animates on its own. children narrows that to matching children."""
66
+ metas, initial, frame_props = [], {}, {}
67
+ for name, start, end in props:
68
+ mid = _id()
69
+ metas.append({"type": "predefined", "timelineKey": "_",
70
+ "predefinedOptions": {"name": name}, "uuid": mid})
71
+ if start is not None:
72
+ initial[mid] = start
73
+ frame_props[mid] = end
74
+ frame = {"uuid": _id(), "properties": frame_props}
75
+ if easing:
76
+ frame["easing"] = easing # "linear", "ease" (the server's default)...
77
+ if progress:
78
+ frame["progressData"] = {"delay": delay, "duration": duration}
79
+ else:
80
+ frame["duration"] = duration
81
+ if delay:
82
+ frame["delay"] = delay
83
+ opts = {"propertyMetas": metas, "keyframes": [frame]}
84
+ if initial:
85
+ opts["initial"] = initial
86
+ action = {"type": "animation", "uuid": _id(), "animationOptions": opts}
87
+ s = _settings(target, children)
88
+ if s:
89
+ action["settings"] = s
90
+ return action
91
+
92
+
93
+ def display(start=None, end=None, duration=0, target=None):
94
+ """Display at the start and/or end of the timeline: display(start="flex") opens
95
+ an off-canvas panel, display(end="none") takes it out once it has slid away."""
96
+ opts = {}
97
+ if start:
98
+ opts["startDisplay"] = start
99
+ if end:
100
+ opts["endDisplay"] = end
101
+ action = {"type": "animation", "uuid": _id(), "animationOptions": {
102
+ "propertyMetas": [{"type": "display", "timelineKey": "_",
103
+ "displayOptions": opts, "uuid": _id()}],
104
+ "keyframes": [{"uuid": _id(), "duration": duration}]}}
105
+ s = _settings(target)
106
+ if s:
107
+ action["settings"] = s
108
+ return action
109
+
110
+
111
+ def hide_at_end(duration=0, target=None):
112
+ """display:none once the timeline ends - what lets a faded overlay stop
113
+ catching clicks. Not keyframe specific: the meta carries the value."""
114
+ action = {"type": "animation", "uuid": _id(), "animationOptions": {
115
+ "propertyMetas": [{"type": "display", "timelineKey": "_",
116
+ "displayOptions": {"endDisplay": "none"}, "uuid": _id()}],
117
+ "keyframes": [{"uuid": _id(), "duration": duration}]}}
118
+ s = _settings(target)
119
+ if s:
120
+ action["settings"] = s
121
+ return action
122
+
123
+
124
+ def mode_switch(collection_id, mode_id, target):
125
+ """Variables > Variable modes: switch a collection to a mode on target - the
126
+ `document` node for the whole page. Compiles to every variable of the collection
127
+ at that mode's value."""
128
+ mid = _id()
129
+ return {"type": "animation", "uuid": _id(), "animationOptions": {
130
+ "propertyMetas": [{"type": "collectionMode", "timelineKey": "_",
131
+ "collectionModeOptions": {"id": collection_id}, "uuid": mid}],
132
+ "keyframes": [{"uuid": _id(), "duration": 0, "properties": {mid: mode_id}}]},
133
+ "settings": _settings(target)}
134
+
135
+
136
+ def set_cookie(name, value):
137
+ """A session cookie - gone when the browser closes."""
138
+ return {"type": "setCookie", "uuid": _id(),
139
+ "setCookieOptions": {"settings": {"name": name, "value": value}}}
140
+
141
+
142
+ def suspend(ix_id=None, target=None):
143
+ """Pause the interaction with Interaction ID ix_id on target (default: the
144
+ trigger element). Without ix_id it pauses EVERY interaction there - including
145
+ the hover that is running it, whose "out" then never fires to resume."""
146
+ return _simple("interactionSuspend", ix_id, target)
147
+
148
+
149
+ def resume(ix_id=None, target=None):
150
+ return _simple("interactionResume", ix_id, target)
151
+
152
+
153
+ def _simple(kind, ix_id, target):
154
+ # The editor groups these fields under an opt-group named after the action
155
+ # ("suspend", "setCookie"...), but stores them under `settings` - a key named
156
+ # after the group is accepted and dropped, and the ID falls back to "all".
157
+ action = {"type": kind, "uuid": _id(),
158
+ "%sOptions" % kind: {"settings": {"interactionID": ix_id}} if ix_id else {}}
159
+ s = _settings(target)
160
+ if s:
161
+ action["settings"] = s
162
+ return action
163
+
164
+
165
+ def player_play(target):
166
+ """Video / Vimeo / YouTube element: play. Shape from the source
167
+ (InteractionSimpleActionPlayerPlayAbstract); not driven in a browser yet."""
168
+ return {"type": "playerPlay", "uuid": _id(), "settings": _settings(target)}
169
+
170
+
171
+ def player_pause(target):
172
+ return {"type": "playerPause", "uuid": _id(), "settings": _settings(target)}
173
+
174
+
175
+ def cookie_is(name, value, operator="equals"):
176
+ """One condition group: run only when cookie `name` compares true to value."""
177
+ return {"uuid": _id(), "evaluationUnits": [{
178
+ "uuid": _id(), "type": "browserCondition",
179
+ "browserConditionOptions": {"subject": {
180
+ "type": "httpCookie", "httpCookieOptions": {
181
+ "settings": {"name": name},
182
+ "comparator": {"type": "text", "textOptions": {
183
+ "operator": operator, "settings": {"value": value}}}}}}}]}
184
+
185
+
186
+ def on(trigger_type, actions, trigger=None, slot=None, ix_id=None, loop=False,
187
+ out_of_view=None, conditions=None, settings=None):
188
+ """One interaction. slot defaults to the trigger's own id (pageLoad, click...);
189
+ elementScrollIntoView uses "in"/"out". ix_id is the Interaction ID other
190
+ interactions suspend/resume by ([a-z0-9_]+). out_of_view: "0" keep running,
191
+ "1" suspend, "2" reset. settings: the trigger's own options, e.g. for
192
+ scrollIntoView {"startWhen": "startEntering", "endWhen": ...} (see the
193
+ `defaultSettings` each type prints into the page). click has three slots -
194
+ "click" every click, "odd", "even" - add the second with add_slot()."""
195
+ opts = {"actionSlots": {slot or trigger_type: {"actions": actions}}}
196
+ if loop:
197
+ opts["actionSlots"][slot or trigger_type]["options"] = {"isLoop": "1"}
198
+ if trigger:
199
+ opts["trigger"] = trigger
200
+ if ix_id:
201
+ opts["ID"] = ix_id
202
+ if out_of_view is not None:
203
+ opts["outOfView"] = out_of_view
204
+ if conditions:
205
+ opts["conditions"] = conditions
206
+ if settings:
207
+ opts["settings"] = settings
208
+ return {"type": trigger_type, "uuid": _id(), "%sOptions" % trigger_type: opts}
209
+
210
+
211
+ def add_slot(interaction, slot, actions):
212
+ """A second slot on the same interaction: hover "out", click "even"..."""
213
+ opts = interaction["%sOptions" % interaction["type"]]
214
+ opts["actionSlots"][slot] = {"actions": actions}
215
+ return interaction
@@ -71,7 +71,7 @@ def fetch(url):
71
71
 
72
72
  def place(client, cfg, surface, slug, post, node, label):
73
73
  """Build a page carrying exactly one tree, and hand back its HTML."""
74
- master = build_shell(client, cfg, {"pages": [], "shell": {}}, surface)
74
+ master, _header, _footer = build_shell(client, cfg, {"pages": [], "shell": {}}, surface)
75
75
  template = bind_page(client, cfg, master, slug, post)
76
76
  inst = "templateDocumentInstance/%s/%s" % (master, template)
77
77
  doc = unwrap(client.get(inst), "templateDocumentInstance")
@@ -176,7 +176,7 @@ def main():
176
176
  if refused else "it ACCEPTED a write it documents as not allowed")
177
177
 
178
178
  # ── 6. two instances on a real page, and the page must show both ─────────
179
- master = build_shell(client, cfg, {"pages": [], "shell": {}}, surface)
179
+ master, _header, _footer = build_shell(client, cfg, {"pages": [], "shell": {}}, surface)
180
180
  template = bind_page(client, cfg, master, a.slug, a.post)
181
181
  tinst = "templateDocumentInstance/%s/%s" % (master, template)
182
182
  tdoc = unwrap(client.get(tinst), "templateDocumentInstance")
@@ -153,6 +153,33 @@ def candidates():
153
153
  "progressData": {"delay": 50, "duration": 50},
154
154
  "properties": {OPACITY: 0.35}}]})))
155
155
 
156
+ # The shape the editor itself stores (1.0.11, an opacity tween authored by hand and
157
+ # read back from wp_mosaic_nodes): values keyed by the META's uuid, written as CSS
158
+ # strings with their unit, and on a timed trigger the timing sits on the keyframe
159
+ # as `duration` rather than in `progressData`.
160
+ def editor_like(values, keyed_by_uuid=True, trigger="pageLoad", progress=False):
161
+ mid = str(uuid.uuid4())
162
+ key = mid if keyed_by_uuid else OPACITY
163
+ kf = {"uuid": str(uuid.uuid4()), "properties": {key: values[1]}}
164
+ kf.update({"progressData": {"delay": 0, "duration": 100}} if progress
165
+ else {"duration": 1000})
166
+ return interaction({"propertyMetas": [meta(OPACITY, mid)],
167
+ "initial": {key: values[0]}, "keyframes": [kf]},
168
+ trigger=trigger)
169
+
170
+ cases.append(("editor-shape-pageload",
171
+ "as the editor stores it: uuid keys, '0%'/'80%', duration on the keyframe",
172
+ editor_like(("0%", "80%"))))
173
+ cases.append(("editor-shape-numbers",
174
+ "NEGATIVE CONTROL - editor shape but bare numbers 0 / 0.8",
175
+ editor_like((0, 0.8))))
176
+ cases.append(("editor-shape-name-keys",
177
+ "NEGATIVE CONTROL - editor shape but keyed by 'opacity'",
178
+ editor_like(("0%", "80%"), keyed_by_uuid=False)))
179
+ cases.append(("editor-shape-scroll",
180
+ "uuid keys and '%' strings on the progress family (scrollIntoView)",
181
+ editor_like(("0%", "80%"), trigger="scrollIntoView", progress=True)))
182
+
156
183
  cases.append(("timed-trigger",
157
184
  "the timed family rather than the progress family",
158
185
  interaction({
@@ -294,7 +321,7 @@ def main():
294
321
  cases = candidates()
295
322
 
296
323
  site = {"pages": [], "shell": {}}
297
- master = build_shell(client, cfg, site, surface)
324
+ master, _header, _footer = build_shell(client, cfg, site, surface)
298
325
  template = bind_page(client, cfg, master, a.slug, a.post)
299
326
  n, _uses = build_page_document(client, cfg, master, template, probe_tree(cases), surface)
300
327
 
@@ -155,7 +155,7 @@ def main():
155
155
  site = {"pages": [], "shell": {}}
156
156
  cls_of, rules_of, page_ok = {}, {}, {}
157
157
  for host in order:
158
- master = build_shell(client, cfg, site, surface)
158
+ master, _header, _footer = build_shell(client, cfg, site, surface)
159
159
  template = bind_page(client, cfg, master, a.slug, a.post)
160
160
  build_page_document(client, cfg, master, template,
161
161
  tree_for(batches[host]), surface)
@@ -157,8 +157,8 @@ def main():
157
157
  "required is set on %d of them" % sum(1 for f in real if f["req"]))
158
158
  check("FORM/honeypot", bool(honeypot),
159
159
  "Mosaic adds its own spam trap: %s" % honeypot)
160
- # a <select> whose options have no text renders as a blank dropdown:
161
- # `select-option` is a LEAF and its label is the `text` PROPERTY
160
+ # a native <select> (1.0.12: `listbox`) whose options have no text renders blank:
161
+ # `listbox-option` is a LEAF and its label is the `text` PROPERTY
162
162
  opts = p.evaluate("""(id) => [...document.querySelectorAll('#' + id + ' option')]
163
163
  .map(o => o.textContent.trim())""", a.form)
164
164
  if opts:
@@ -167,6 +167,61 @@ def main():
167
167
  else "blank labels - `text` is a property, not a child")
168
168
  else:
169
169
  skip("FORM/option_labels", "no select on this form")
170
+ # 1.0.12's Select is not a <select>: <mosaic-select> holds a combobox
171
+ # button, a role=listbox of buildable options and a hidden input that
172
+ # carries the value. Drive it the way a visitor does.
173
+ sel = p.evaluate("""(id) => { const s = document.querySelector('#' + id + ' mosaic-select');
174
+ return s ? s.querySelector('.m-select-toggle').id : null; }""", a.form)
175
+ if not sel:
176
+ skip("FORM/select", "no custom select on this form")
177
+ else:
178
+ st = lambda: p.evaluate("""(t) => { const b = document.getElementById(t),
179
+ s = b.closest('mosaic-select'), l = s.querySelector('[role=listbox]'),
180
+ i = s.querySelector('input.m-select-input'), r = l.getBoundingClientRect();
181
+ return {exp: b.getAttribute('aria-expanded'), shown: r.height > 2
182
+ && getComputedStyle(l).visibility !== 'hidden'
183
+ && getComputedStyle(l).display !== 'none',
184
+ value: i.value, name: i.name, label: b.innerText.trim(),
185
+ opts: [...l.querySelectorAll('[role=option]')].map(o =>
186
+ [o.dataset.value ?? '', o.textContent.trim()])}; }""", sel)
187
+ closed = st()
188
+ # the hidden input is not what fails validation: a submit with
189
+ # nothing picked marks the TOGGLE aria-invalid, which is what the
190
+ # field's invalid state selectors key on in 1.0.12
191
+ p.click("#%s [type=submit]" % a.form)
192
+ p.wait_for_timeout(600)
193
+ inv = p.evaluate("(t) => document.getElementById(t).getAttribute('aria-invalid')", sel)
194
+ check("FORM/select_required", inv == "true",
195
+ "submit with nothing picked: toggle aria-invalid=%r" % inv)
196
+ check("FORM/select_labels", closed["opts"] and all(t for _v, t in closed["opts"]),
197
+ "%d options, labels are child text nodes: %s"
198
+ % (len(closed["opts"]), [t for _v, t in closed["opts"]][:4]))
199
+ p.click("#" + sel)
200
+ p.wait_for_timeout(400)
201
+ opened = st()
202
+ check("FORM/select_opens", opened["exp"] == "true" and opened["shown"]
203
+ and not closed["shown"],
204
+ "toggle click: aria-expanded %s -> %s, list shown %s -> %s"
205
+ % (closed["exp"], opened["exp"], closed["shown"], opened["shown"]))
206
+ want_v, want_t = closed["opts"][1]
207
+ p.click("#%s ~ [role=listbox] [role=option] >> nth=1" % sel)
208
+ p.wait_for_timeout(400)
209
+ picked = st()
210
+ check("FORM/select_picks", picked["value"] == want_v
211
+ and want_t in picked["label"] and picked["exp"] == "false",
212
+ "picked %r: input %s=%r, toggle shows %r, closed=%s"
213
+ % (want_t, picked["name"], picked["value"], picked["label"],
214
+ picked["exp"] == "false"))
215
+ # keyboard: open, one row down, Enter picks the next option
216
+ p.focus("#" + sel)
217
+ p.keyboard.press("ArrowDown")
218
+ p.keyboard.press("ArrowDown")
219
+ p.keyboard.press("Enter")
220
+ p.wait_for_timeout(400)
221
+ keyed = st()
222
+ check("FORM/select_keyboard", keyed["value"] not in ("", picked["value"])
223
+ and keyed["exp"] == "false",
224
+ "ArrowDown, ArrowDown, Enter: %r -> %r" % (picked["value"], keyed["value"]))
170
225
  # the browser's own validation has to stop an empty required form
171
226
  p.evaluate("(id) => document.getElementById(id).reset()", a.form)
172
227
  invalid = p.evaluate("""(id) => [...document.getElementById(id)