// Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // SPDX-License-Identifier: GPL-3.0-or-later package app import ( "errors" "log/slog" "testing" "git.stormux.org/storm/cthulhu/internal/atspi" "git.stormux.org/storm/cthulhu/internal/review" ) func TestBrowserActivationResultsStaySilent(t *testing.T) { for _, activationErr := range []error{nil, review.ErrNoCurrent, atspi.ErrStaleObject, errors.New("action refused")} { queue := &fakeSpeechQueue{spoken: make(chan string, 8), interrupt: make(chan struct{}, 8)} focus := atspi.Snapshot{BusName: ":1.42", Path: "/clickable", Role: "section"} browser := newBrowserModeController(nil, &modeKeys{}, nil) browser.ready, browser.mode, browser.focus = true, review.BrowseMode, focus.ID() state := &eventLoopState{} state.current = focus handler := eventReviewHandler{state: state, logger: slog.New(slog.DiscardHandler), speech: queue, objectReview: &review.Worker{}, browser: browser, focusGate: &focusGate{}, syncForeground: func() {}} handler.handle(review.Result{DocumentActivate: true, DocumentFocus: focus.ID(), Err: activationErr}) if len(queue.spoken) != 0 || len(queue.interrupt) != 0 { t.Fatalf("activation %v produced feedback or interrupted page speech", activationErr) } } } func TestBrowserNavigationDoesNotSuppressLiveNames(t *testing.T) { browser := newBrowserModeController(nil, &modeKeys{}, nil) browser.navigation = atspi.NewObjectID(":1.42", "/heading") browser.navigationDocument = atspi.NewObjectID(":1.42", "/document") event := atspi.NewEvent(atspi.AccessibleNameEvent, atspi.Snapshot{ BusName: ":1.42", Path: "/status", Role: "status bar", Name: "Download complete", LiveRegion: true}) if browser.suppressNavigationEcho(event) { t.Fatal("reader navigation swallowed a live-region name update") } }