From c2e8d4f6bc341dca0790821c89e92130e432b973 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 10 Oct 2024 13:30:57 -0400 Subject: [PATCH] Improve developerMode updateURL (#431) - Simplify the tag/suite/suites selection code by always deleting all searchParams first - Don't use tags if there is only one selected suite (previously selecting "React-Stockcharts-SVG" currently sets the "svg" tag which is a bit unexpected) - Compare against defaultParams for "measurementMethod" using the existing method for bool values --- resources/developer-mode.mjs | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/resources/developer-mode.mjs b/resources/developer-mode.mjs index 86dd41728..166aea977 100644 --- a/resources/developer-mode.mjs +++ b/resources/developer-mode.mjs @@ -240,13 +240,10 @@ function updateURL() { // to comma separate only the selected const selectedSuites = Suites.filter((suite) => !suite.disabled); - if (!selectedSuites.length) { - url.searchParams.delete("tags"); - url.searchParams.delete("suites"); - url.searchParams.delete("suite"); - } else { - url.searchParams.delete("tags"); - url.searchParams.delete("suite"); + url.searchParams.delete("tags"); + url.searchParams.delete("suites"); + url.searchParams.delete("suite"); + if (selectedSuites.length) { // Try finding common tags that would result in the current suite selection. let commonTags = new Set(selectedSuites[0].tags); for (const suite of Suites) { @@ -255,26 +252,18 @@ function updateURL() { else commonTags = new Set(suite.tags.filter((tag) => commonTags.has(tag))); } - if (commonTags.size) { + if (selectedSuites.length > 1 && commonTags.size) { const tags = [...commonTags][0]; - if (tags === "default") - url.searchParams.delete("tags"); - else + if (tags !== "default") url.searchParams.set("tags", tags); url.searchParams.delete("suites"); } else { - url.searchParams.delete("tags"); url.searchParams.set("suites", selectedSuites.map((suite) => suite.name).join(",")); } } - if (params.measurementMethod !== "raf") - url.searchParams.set("measurementMethod", "timer"); - else - url.searchParams.delete("measurementMethod"); - - const boolParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync"]; - for (const paramKey of boolParamKeys) { + const defaultParamKeys = ["measurementMethod", "iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync"]; + for (const paramKey of defaultParamKeys) { if (params[paramKey] !== defaultParams[paramKey]) url.searchParams.set(paramKey, params[paramKey]); else