//go:build browser
package check
import (
"context"
"encoding/json"
"fmt"
"math"
"strconv"
"strings"
"sync"
"testing"
"time"
"github.com/chromedp/cdproto/emulation"
"github.com/chromedp/cdproto/input"
"github.com/chromedp/cdproto/tracing"
"github.com/chromedp/chromedp"
"amadan.net/rastrillo/fiesta/internal/harness"
)
// lightDoc is the depth fixture plus the light.js tag. sizingDoc never
// links it, so every other drive stays static (a lesson learned: a
// clock-driven light moved shadows under the static card test).
func lightDoc(t *testing.T) map[string]string {
t.Helper()
pages := depthDoc(t)
pages["/"] = strings.Replace(pages["/"], ``, ``, 1)
return pages
}
// lightFollows reads the mode the shipped file is in (the FOLLOW fallback
// flips it), so the drives assert the behaviour of the file that ships.
func lightFollows() bool { return strings.Contains(string(lightJS()), "var FOLLOW = true") }
// lightModeDoc is the depth fixture with light.js in the mode asked
// for: the shipped file when it is in that mode, otherwise the shipped
// file with its FOLLOW flag flipped, served inline. Both modes are
// driven whichever one ships, so flipping the flag later cannot leave
// the other mode's root light untested.
func lightModeDoc(t *testing.T, follow bool) map[string]string {
t.Helper()
if follow == lightFollows() {
return lightDoc(t)
}
from, to := "var FOLLOW = false", "var FOLLOW = true"
if !follow {
from, to = to, from
}
js := strings.Replace(string(lightJS()), from, to, 1)
pages := depthDoc(t)
pages["/"] = strings.Replace(pages["/"], `