From 2df38aad49aa1bb4af0ea4215cb1616357386159 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Fri, 1 May 2026 08:02:08 +0200 Subject: [PATCH] Add firefox settings to the result JSON Issue #1622. Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com Change-Id: Iae4ec16f1885be7e0d139122852fd404e636a8be --- lib/core/engine/index.js | 26 ++++++++++++++++++++++++-- lib/core/engine/iteration.js | 8 ++++++++ lib/firefox/webdriver/builder.js | 14 ++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/core/engine/index.js b/lib/core/engine/index.js index 64c927b64e..cec75ba8c6 100644 --- a/lib/core/engine/index.js +++ b/lib/core/engine/index.js @@ -386,12 +386,34 @@ export class Engine { result.info.browser.name = extras.har.log.browser.name; result.info.browser.version = extras.har.log.browser.version; if (options.browser === 'firefox' && options.firefox) { - result.info.browser.args = options.firefox.args; + // Issue #1622 — surface the full set of args/preferences/binary + // that browsertime applied to Firefox, not just what the user + // passed via --firefox.args / --firefox.preference. Captured by + // configureBuilder; see lib/firefox/webdriver/builder.js. + if (options.recordedBrowserSettings) { + const recorded = options.recordedBrowserSettings; + result.info.browser.args = recorded.args; + result.info.browser.preferences = recorded.preferences; + if (recorded.binary) { + result.info.browser.binary = recorded.binary; + } + if (recorded.profile) { + result.info.browser.profile = recorded.profile; + } + if (recorded.androidPackage) { + result.info.browser.androidPackage = recorded.androidPackage; + } + if (recorded.androidActivity) { + result.info.browser.androidActivity = recorded.androidActivity; + } + } else { + result.info.browser.args = options.firefox.args; + result.info.browser.preference = options.firefox.preference; + } if (options.firefox.geckoProfiler === true) { result.info.browser.geckProfilerFeatures = options.firefox.geckoProfilerParams.features; } - result.info.browser.preference = options.firefox.preference; } else if (options.browser === 'chrome') { if (options.chrome) { result.info.browser.args = options.chrome.args; diff --git a/lib/core/engine/iteration.js b/lib/core/engine/iteration.js index c343ca09aa..c09f2f15c8 100644 --- a/lib/core/engine/iteration.js +++ b/lib/core/engine/iteration.js @@ -224,6 +224,14 @@ export class Iteration { await engineDelegate.beforeBrowserStart(); await browser.start(); + // The runner deep-merges options into a fresh object before passing them + // to the browser-specific builder, so anything the builder records there + // never reaches the engine. Copy it back to the engine's options object + // so result.info.browser can pick it up. Issue #1622. + if (browser.options && browser.options.recordedBrowserSettings) { + this.options.recordedBrowserSettings = + browser.options.recordedBrowserSettings; + } await engineDelegate.afterBrowserStart(browser); } diff --git a/lib/firefox/webdriver/builder.js b/lib/firefox/webdriver/builder.js index 337c7b5914..f437f4050f 100644 --- a/lib/firefox/webdriver/builder.js +++ b/lib/firefox/webdriver/builder.js @@ -266,4 +266,18 @@ export async function configureBuilder(builder, baseDir, options) { } builder.setFirefoxOptions(ffOptions); + + // Snapshot every argument / preference / capability we just applied so it + // can be surfaced in the result JSON for debugging — issue #1622. The + // runner deep-merges options into a fresh container before this is called, + // so iteration.js threads it back to the engine after browser.start(). + const ffInternals = ffOptions.firefoxOptions_(); + options.recordedBrowserSettings = { + args: [...(ffInternals.args || [])], + preferences: { ...ffInternals.prefs }, + binary: ffInternals.binary, + profile: ffInternals.profile, + androidPackage: ffInternals.androidPackage, + androidActivity: ffInternals.androidActivity + }; }