Keep summaries in browse mode, focus splitters, speak checked tree items
Adopt three current Orca web behaviors: - A native <summary> no longer forces focus mode, so its expanded details can be read without switching back (Orca issue #543). ARIA disclosure buttons keep focus mode. - A focusable separator is a splitter and uses focus mode so arrow keys resize the panes. Static separators stay in browse mode. - Checkable tree items present checked, not checked or partially checked on focus and on state change (Orca issue #777). The web-widgets native proof records Chromium's exposure of each widget. Verified live in Brave with tests/browser-web-widgets.html. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
996685539a
commit
210e949f76
7 files changed
+142
-2
No files matched your search
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// Authors: Storm Dragon, Angus Kola
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package atspi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Records how the browser exposes the widgets behind three web mode and
|
||||
// presentation rules: a native disclosure summary, a focusable splitter, and
|
||||
// checkable tree items. The reader's rules depend on these exact traits.
|
||||
func TestNativeBrowserWebWidgetTraits(t *testing.T) {
|
||||
if os.Getenv("CTHULHU_NATIVE_BROWSER") != "1" {
|
||||
t.Skip("requires private browser session")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
adapter := New()
|
||||
if err := adapter.Start(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer adapter.Stop(context.Background())
|
||||
if _, err := adapter.CaptureDesktop(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Browse mode decides from document captures, which carry HTML tags.
|
||||
// Anchor the capture on the page's own focused button.
|
||||
if out, err := exec.CommandContext(ctx, "xdotool", "key", "--clearmodifiers", "Tab").CombinedOutput(); err != nil {
|
||||
t.Fatalf("move focus: %v %s", err, out)
|
||||
}
|
||||
var focus ObjectID
|
||||
for !focus.Valid() {
|
||||
select {
|
||||
case event := <-adapter.Events():
|
||||
if (event.Type == FocusedStateEvent || event.Type == FocusEvent) && event.Detail1 == 1 && event.Source.Name == "Disclosure summary" {
|
||||
focus = event.Source.ID()
|
||||
}
|
||||
case <-ctx.Done():
|
||||
t.Fatal("focus event in the page missing")
|
||||
}
|
||||
}
|
||||
document, err := adapter.CaptureDocument(ctx, focus)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
resolve := func(name string) Snapshot {
|
||||
t.Helper()
|
||||
snapshot, err := document.Resolve(findNamedReference(t, document, name))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("%s: role=%q tag=%q focusable=%v expandable=%v expanded=%v checkable=%v checked=%v xml-roles=%q",
|
||||
name, snapshot.Role, snapshot.HTMLTag, snapshot.Focusable, snapshot.Expandable, snapshot.Expanded,
|
||||
snapshot.Checkable, snapshot.Checked, snapshot.XMLRoles)
|
||||
return snapshot
|
||||
}
|
||||
if summary := resolve("Disclosure summary"); summary.HTMLTag != "summary" || summary.Role != "toggle button" || !summary.Focusable || !summary.Expandable {
|
||||
t.Errorf("summary traits: %+v", summary)
|
||||
}
|
||||
if splitter := resolve("Pane splitter"); splitter.Role != "separator" || !splitter.Focusable {
|
||||
t.Errorf("splitter traits: %+v", splitter)
|
||||
}
|
||||
if static := resolve("Static separator"); static.Role != "separator" || static.Focusable {
|
||||
t.Errorf("static separator traits: %+v", static)
|
||||
}
|
||||
if checked := resolve("Checked option"); checked.Role != "tree item" || !checked.Checkable || !checked.Checked {
|
||||
t.Errorf("checked tree item traits: %+v", checked)
|
||||
}
|
||||
if unchecked := resolve("Unchecked option"); !unchecked.Checkable || unchecked.Checked {
|
||||
t.Errorf("unchecked tree item traits: %+v", unchecked)
|
||||
}
|
||||
if plain := resolve("Plain option"); plain.Checkable {
|
||||
t.Errorf("plain tree item reported checkable: %+v", plain)
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,12 @@ func controlValue(snapshot atspi.Snapshot) string {
|
||||
|
||||
func controlStates(snapshot atspi.Snapshot) []string {
|
||||
var states []string
|
||||
switch snapshot.ControlRole() {
|
||||
role := snapshot.ControlRole()
|
||||
if role == "tree item" && snapshot.Checkable {
|
||||
// aria-checked tree items (checkbox trees) report their checked state.
|
||||
role = "check box"
|
||||
}
|
||||
switch role {
|
||||
case "check box", "check menu item":
|
||||
switch {
|
||||
case snapshot.Indeterminate:
|
||||
|
||||
@@ -38,6 +38,10 @@ func TestFocusTextPresentsControlStates(t *testing.T) {
|
||||
{name: "toggle pressed", snapshot: atspi.Snapshot{Name: "Bold", Role: "toggle button", Checked: true}, want: "Bold, toggle button, pressed"},
|
||||
{name: "collapsed item", snapshot: atspi.Snapshot{Name: "Documents", Role: "tree item", Expandable: true}, want: "Documents, tree item, collapsed"},
|
||||
{name: "expanded selected item", snapshot: atspi.Snapshot{Name: "Documents", Role: "tree item", Expandable: true, Expanded: true, Selected: true}, want: "Documents, tree item, expanded, selected"},
|
||||
{name: "checked tree item", snapshot: atspi.Snapshot{Name: "Backups", Role: "tree item", Checkable: true, Checked: true}, want: "Backups, tree item, checked"},
|
||||
{name: "unchecked tree item", snapshot: atspi.Snapshot{Name: "Backups", Role: "tree item", Checkable: true}, want: "Backups, tree item, not checked"},
|
||||
{name: "mixed tree item", snapshot: atspi.Snapshot{Name: "Backups", Role: "tree item", Checkable: true, Indeterminate: true}, want: "Backups, tree item, partially checked"},
|
||||
{name: "plain tree item", snapshot: atspi.Snapshot{Name: "Backups", Role: "tree item"}, want: "Backups, tree item"},
|
||||
{name: "selected menu item", snapshot: atspi.Snapshot{Name: "Open", Role: "menu item", Selected: true}, want: "Open, menu item"},
|
||||
{name: "unchecked generic menu", snapshot: atspi.Snapshot{Name: "Updates", Role: "menu item", Checkable: true}, want: "Updates, check menu item, not checked"},
|
||||
{name: "checked generic menu without marker", snapshot: atspi.Snapshot{Name: "Updates", Role: "menu item", Checked: true}, want: "Updates, check menu item, checked"},
|
||||
@@ -67,6 +71,8 @@ func TestEventTextPresentsOnlyChangedState(t *testing.T) {
|
||||
{name: "checked", event: atspi.NewEvent("object:state-changed:checked", atspi.Snapshot{Name: "Updates", Role: "check box", Checked: true}), want: "checked"},
|
||||
{name: "generic menu checked", event: atspi.NewEvent("object:state-changed:checked", atspi.Snapshot{Name: "Updates", Role: "menu item", Checkable: true, Checked: true}), want: "checked"},
|
||||
{name: "generic menu unchecked without marker", event: atspi.NewEvent("object:state-changed:checked", atspi.Snapshot{Name: "Updates", Role: "menu item"}), want: "not checked"},
|
||||
{name: "tree item checked", event: atspi.NewEvent("object:state-changed:checked", atspi.Snapshot{Name: "Backups", Role: "tree item", Checkable: true, Checked: true}), want: "checked"},
|
||||
{name: "tree item unchecked", event: atspi.NewEvent("object:state-changed:checked", atspi.Snapshot{Name: "Backups", Role: "tree item", Checkable: true}), want: "not checked"},
|
||||
{name: "expanded", event: atspi.NewEvent("object:state-changed:expanded", atspi.Snapshot{Name: "Files", Role: "tree item", Expanded: true}), want: "expanded"},
|
||||
{name: "menu selection omitted", event: atspi.NewEvent("object:state-changed:selected", atspi.Snapshot{Name: "Open", Role: "menu item", Selected: true}), want: ""},
|
||||
{name: "tree selection", event: atspi.NewEvent("object:state-changed:selected", atspi.Snapshot{Name: "Files", Role: "tree item", Selected: true}), want: "selected"},
|
||||
|
||||
@@ -152,7 +152,13 @@ func (state *DocumentModeState) decide(input ModeInput, settings ModeSettings) D
|
||||
func focusModeWidget(input ModeInput) bool {
|
||||
object := input.Context.Ancestors[0]
|
||||
traits := input.Traits
|
||||
if object.Editable || object.Expandable && object.Focusable && object.Role != "link" {
|
||||
// A native <summary> stays in browse mode so its expanded details can be
|
||||
// read without switching back (Orca issue #543).
|
||||
if object.Editable || object.Expandable && object.Focusable && object.Role != "link" && object.HTMLTag != "summary" {
|
||||
return true
|
||||
}
|
||||
// A focusable separator is a splitter: arrow keys resize the panes.
|
||||
if object.Role == "separator" && object.Focusable {
|
||||
return true
|
||||
}
|
||||
switch object.Role {
|
||||
|
||||
@@ -217,3 +217,26 @@ func TestDocumentModeUnknownStates(t *testing.T) {
|
||||
t.Fatalf("recaptured states did not restore mode: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDocumentModeSummaryAndSplitter(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
snapshot atspi.Snapshot
|
||||
want DocumentMode
|
||||
}{
|
||||
{"native summary", atspi.Snapshot{Role: "toggle button", HTMLTag: "summary", Focusable: true, Expandable: true, Expanded: true}, BrowseMode},
|
||||
{"aria disclosure button", atspi.Snapshot{Role: "toggle button", HTMLTag: "div", Focusable: true, Expandable: true}, FocusMode},
|
||||
{"focusable splitter", atspi.Snapshot{Role: "separator", HTMLTag: "div", Focusable: true}, FocusMode},
|
||||
{"static separator", atspi.Snapshot{Role: "separator", HTMLTag: "hr"}, BrowseMode},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
input := modeInput(t, test.snapshot.Role)
|
||||
test.snapshot.StatesKnown = true
|
||||
input.Context.Ancestors[0] = test.snapshot
|
||||
var state DocumentModeState
|
||||
if got := state.Update(input, DefaultModeSettings()); got != test.want {
|
||||
t.Fatalf("got %v, want %v", got, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user