The chrome-launcher implementation assumes that prefs are a flat dictionary-like object.
This assumption is incorrect. Preferences are stored/read as nested properties: https://source.chromium.org/chromium/chromium/src/+/main:components/prefs/json_pref_store.cc;l=215-267;drc=34ad7f3844f882baf3d31a6bc6e300acaa0e3fc8
Here is an example:
{"download": { "open_pdf_in_system_reader": false } }
+
{"download": { "default_directory": "/tmp/" } }
Given the above example, I would expect the following:
{
"download": {
"open_pdf_in_system_reader": false,
"default_directory": "/tmp/"
}
}
The actual result, however, is as follows (because the top-level "download" key is overwritten):
{"download": { "default_directory": "/tmp/" } }
To fix this, one could replace the top-level merge with a deepmerge, at
https://github.com/GoogleChrome/chrome-launcher/blame/v1.1.1/src/chrome-launcher.ts#L247-L250 . One potential downside to this is that it becomes impossible to clear an existing value, but I don't think that this is a big deal: Because the set of meaningful pref is fixed (or at least known), anyone who cares about clearing could explicitly list all relevant prefs with the default value instead of specifying something like {"download":{}}.
The chrome-launcher implementation assumes that prefs are a flat dictionary-like object.
https://github.com/GoogleChrome/chrome-launcher/blob/v1.1.1/src/chrome-launcher.ts#L34
https://github.com/GoogleChrome/chrome-launcher/blob/v1.1.1/test/chrome-launcher-test.ts#L73-L96
prefswith existing Preferences with a top-level merge:https://github.com/GoogleChrome/chrome-launcher/blame/v1.1.1/src/chrome-launcher.ts#L247-L250
This assumption is incorrect. Preferences are stored/read as nested properties: https://source.chromium.org/chromium/chromium/src/+/main:components/prefs/json_pref_store.cc;l=215-267;drc=34ad7f3844f882baf3d31a6bc6e300acaa0e3fc8
Here is an example:
{"download": { "open_pdf_in_system_reader": false } } + {"download": { "default_directory": "/tmp/" } }Given the above example, I would expect the following:
{ "download": { "open_pdf_in_system_reader": false, "default_directory": "/tmp/" } }The actual result, however, is as follows (because the top-level
"download"key is overwritten):{"download": { "default_directory": "/tmp/" } }To fix this, one could replace the top-level merge with a deepmerge, at
https://github.com/GoogleChrome/chrome-launcher/blame/v1.1.1/src/chrome-launcher.ts#L247-L250 . One potential downside to this is that it becomes impossible to clear an existing value, but I don't think that this is a big deal: Because the set of meaningful pref is fixed (or at least known), anyone who cares about clearing could explicitly list all relevant prefs with the default value instead of specifying something like
{"download":{}}.