//go:build browser // Package history holds the gallery's browser legs that need a real // back/forward cache restore or a real new-tab click: the headless // shell the cloud runner links as chromium never gives either, so // these legs need full Chromium (the Makefile's FULL_CHROMIUM), and // they are a package of their own so that cost falls on only them. package history import ( "context" "net/http" "testing" "github.com/chromedp/chromedp" "amadan.net/rastrillo/fiesta" "amadan.net/rastrillo/fiesta/internal/gallery" "amadan.net/rastrillo/fiesta/internal/gallery/galleryrig" "amadan.net/rastrillo/fiesta/internal/harness" ) // The gallery's addresses and the shared drive helpers, under the // names these legs are written with. One line each: the // implementations are galleryrig's. The page files are written here // by name, since the page-kind table is the gallery package's own. const ( mountPath = "/gallery" mountPrefix = mountPath + "/" ) func pageHref(theme, locale, file string) string { return mountPrefix + theme + "/" + locale + "/" + file } // indexHref is the Overview's address: the one page every index drive // navigates to by name. func indexHref(theme, locale string) string { return pageHref(theme, locale, "index.html") } func treeHandler(t *testing.T) http.Handler { t.Helper() files, err := gallery.Render(fiesta.FS(), gallery.Options{Mount: mountPath}) if err != nil { t.Fatalf("Render: %v", err) } return galleryrig.Tree(t, files, mountPrefix) } func addInit(js string) chromedp.Action { return galleryrig.AddInit(js) } func phoneRig(t *testing.T) *harness.Rig { t.Helper() return galleryrig.PhoneRig(t, func() http.Handler { return treeHandler(t) }) } func requireCoarse(t *testing.T, ctx context.Context) { t.Helper() galleryrig.RequireCoarse(t, ctx) } func until(t *testing.T, ctx context.Context, where, expr string) { t.Helper() galleryrig.Until(t, ctx, where, expr) }