Wireless Bluetooth Headphones
Premium noise-canceling headphones with 30-hour battery life.
Price: $79.99
package engine import ( "context" "fmt" "net/http" "net/http/httptest" "strings" "testing" ) // --------------------------------------------------------------------------- // Realistic page templates simulating common website structures. // These tests verify the lite engine produces correct accessibility snapshots // comparable to what Chrome's CDP accessibility tree would return. // --------------------------------------------------------------------------- const wikipediaStylePage = `
Go, also known as Golang, is a statically typed, compiled programming language designed at Google.
Go was designed at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson.
Go's syntax is similar to C but with memory safety, garbage collection, and CSP-style concurrency.
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Go has built-in support for concurrent programming via goroutines and channels.
| Feature | Go | Rust |
|---|---|---|
| GC | Yes | No |
| Generics | Yes (1.18+) | Yes |
Premium noise-canceling headphones with 30-hour battery life.
Price: $79.99
$45,230
1,234
| Date | Revenue | Users |
|---|---|---|
| Jan 1 | $1,200 | 89 |
| Jan 2 | $1,450 | 102 |
Deeply nested paragraph with a link inside.
Price: <$50 for dégustation menu
Japanese: 日本語
RéserverEmoji: 😀 🚀 ❤
` const emptyAndMinimalPage = `Visible paragraph
` ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") _, _ = w.Write([]byte(page)) })) defer ts.Close() lite := NewLiteEngine() defer func() { _ = lite.Close() }() _, err := lite.Navigate(context.Background(), ts.URL) if err != nil { t.Fatalf("Navigate: %v", err) } text := getText(t, lite) requireTextContains(t, text, "Content", "Visible paragraph") requireTextNotContains(t, text, "document.write", "init()", "import", "jquery") nodes := snapshotNodes(t, lite, "") for _, n := range nodes { if n.Tag == "script" { t.Error("script elements should not appear in snapshot") } } } func TestRealworld_InlineStyles(t *testing.T) { page := `Styled text
Normal text
` ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") _, _ = w.Write([]byte(page)) })) defer ts.Close() lite := NewLiteEngine() defer func() { _ = lite.Close() }() _, err := lite.Navigate(context.Background(), ts.URL) if err != nil { t.Fatalf("Navigate: %v", err) } nodes := snapshotNodes(t, lite, "") for _, n := range nodes { if n.Tag == "style" { t.Error("style elements should not appear in snapshot") } } } func TestRealworld_ClickWorkflow(t *testing.T) { // Test clicking buttons — buttons should work without navigation side effects page := `Some content here
` ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") _, _ = w.Write([]byte(page)) })) defer ts.Close() lite := NewLiteEngine() defer func() { _ = lite.Close() }() _, _ = lite.Navigate(context.Background(), ts.URL) nodes := snapshotNodes(t, lite, "interactive") // Click every interactive element — should not error or panic for _, n := range nodes { err := lite.Click(context.Background(), "", n.Ref) if err != nil { t.Errorf("Click(%s role=%s name=%q): %v", n.Ref, n.Role, n.Name, err) } } // Engine should still be usable text, err := lite.Text(context.Background(), "") if err != nil { t.Fatalf("Text after clicks: %v", err) } if !strings.Contains(text, "Some content here") { t.Errorf("unexpected text after clicks: %s", text) } } func TestRealworld_ClickLinkRecovery(t *testing.T) { // Clicking anchor links triggers gost-dom navigation which can panic // (no script engine). Verify we recover gracefully. page := `