diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go new file mode 100644 index 000000000..8956bf63a --- /dev/null +++ b/internal/gui/core_budget_test.go @@ -0,0 +1,52 @@ +package gui + +import ( + "os" + "path/filepath" + "regexp" + "strings" + "testing" +) + +// What the window's core may weigh, in bytes of script: everything +// index.html loads that isn't a plugin's (assets/plugins//) and isn't +// the words (i18n.js). A page belongs in a plugin. Each page moved out +// lowers these to what is left, with about 1.5% room for the core's own work, +// so a page can't quietly grow back into the core; a change that needs more +// raises them and says why in its commit. +const ( + appScriptBudget = 1_215_000 // app.js: 1,198,239 after Usage left (P2) + coreScriptBudget = 1_377_000 // every core script: 1,358,034 after Usage left +) + +func TestCoreScriptBudget(t *testing.T) { + page, err := os.ReadFile("assets/index.html") + if err != nil { + t.Fatal(err) + } + total, n := 0, 0 + for _, m := range regexp.MustCompile(`