test_linuxDesktopEntry.js fails when run locally without a desktop environment
Categories
(Firefox :: Shell Integration, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox163 | --- | fixed |
People
(Reporter: dmcintosh, Assigned: mferreiro)
References
(Regressed 1 open bug)
Details
(Whiteboard: [FIDE-engagement])
Attachments
(1 external file, 1 obsolete file)
Bug 1962880 added a call to profiler_lookup_async_signal_dump_directory into XRE_XPCShellMain. Unless MOZ_UPLOAD_DIR is set, as it is on CI, it gets the external app handling service and gets/caches the Home directory.
test_linuxDesktopEntry.js tries to change the home directory using a new directory service provider, but the directory service already cached the home directory from before. The code under test then tries to write to the real home directory, while the tests use the temporary directory, and it fails.
There's ways we can plausibly work around this in the shell service, but at least this is a regression from before. Maybe Home should always/never be cached here, to avoid CI/local differences?
Stack trace for completeness:
#0 0x00007ffff1d54a54 in GetSpecialSystemDirectory(SystemDirectories, nsIFile**) () at /home/duncan/firefox-wsl2/obj-x86_64-pc-linux-gnu/dist/bin/libxul.so
#1 0x00007ffff1cfb013 in nsDirectoryService::GetFile(char const*, bool*, nsIFile**) () at /home/duncan/firefox-wsl2/obj-x86_64-pc-linux-gnu/dist/bin/libxul.so
#2 0x00007ffff1ad6920 in FindProviderFile(nsIDirectoryServiceProvider*, FileData*) () at /home/duncan/firefox-wsl2/obj-x86_64-pc-linux-gnu/dist/bin/libxul.so
#3 0x00007ffff1ad677d in nsDirectoryService::Get(char const*, nsID const&, void**) () at /home/duncan/firefox-wsl2/obj-x86_64-pc-linux-gnu/dist/bin/libxul.so
#4 0x00007ffff2938380 in GetPreferredDownloadsDirectory(bool) () at /home/duncan/firefox-wsl2/obj-x86_64-pc-linux-gnu/dist/bin/libxul.so
#5 0x00007ffff2938049 in nsExternalHelperAppService::GetPreferredDownloadsDirectory(nsIFile**) ()
at /home/duncan/firefox-wsl2/obj-x86_64-pc-linux-gnu/dist/bin/libxul.so
#6 0x00007ffff2937b2f in profiler_lookup_async_signal_dump_directory() () at /home/duncan/firefox-wsl2/obj-x86_64-pc-linux-gnu/dist/bin/libxul.so
#7 0x00007ffff3370f91 in XRE_XPCShellMain(int, char**, char**, XREShellData const*) () at /home/duncan/firefox-wsl2/obj-x86_64-pc-linux-gnu/dist/bin/libxul.so
#8 0x00005555555cceb1 in main (argc=-13568, argv=0x1, envp=0x7fffe9a53b00) at /builds/worker/checkouts/gecko/js/xpconnect/shell/xpcshell.cpp:83
| Reporter | ||
Comment 1•4 months ago
|
||
Read the year number wrong, this would've been in-tree the whole time. Will dig a bit more.
| Reporter | ||
Comment 2•4 months ago
|
||
OK, think I have it figured out. Home is only checked as a fallback if it can't find a 'better' downloads directory. If there's a ~/.config/user_dirs.dirs file that contains at least XDG_DOWNLOAD_DIR="/tmp", then the test passes, since it doesn't need to look up Home that early. That usually is there, I think if you've ever run a desktop environment before, which I had done in WSL when I wrote the patch, but then reset it. It also passes on CI due to the MOZ_UPLOAD_DIR envvar.
nrishel, since we discussed this on Slack a little bit, thoughts on where to go next? From what I can see, options are:
- Keep the directory service provider but remove the cache like the updater does (see xpcshellUtilsAUS.js).
- Remove the provider, mock out the home directory part as I did in D314448.
- Remove the provider, mock out
_getLinuxDesktopEntryPathentirely in tests, and have a couple that check it works for whateverHomehappens to be. - Somehow modify the earlier code to not cache the result, keep the test as-is.
- ...?
Comment 3•3 months ago
|
||
My inclination would be to follow what the updater does but both this an the updater on a new bug for further discussion. Maybe wrap in :emilio as you mentioned first?
Removing regression since this was preexisting.
| Reporter | ||
Comment 4•3 months ago
|
||
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
| Assignee | ||
Updated•21 days ago
|
| Assignee | ||
Comment 5•21 days ago
|
||
Hi nrishel,
I'd like to take this over. It reproduces reliably with:
XDG_CONFIG_HOME=$(mktemp -d) ./mach xpcshell-test browser/components/shell/test/unit/test_linuxDesktopEntry.js
It runs the test but with an empty temporary folder, so the test doens´t find ~./config/user-dirs.dirs.
Proposed plan:
Before registering gDirectoryServiceProvider, undefine "Home" if it's already cached (the same way registerCustomDirProvider does for the paths it overrides in the updater tests). And then (this is important) assert that "Home" resolves to the temp directory, so the test fails early instead of writing to the real home, just in case.
With that change it passes locally both with and without user-dirs.dirs, and with MOZ_UPLOAD_DIR set as on CI.
Does that sound OK?
| Assignee | ||
Updated•21 days ago
|
Updated•21 days ago
|
| Assignee | ||
Comment 6•19 days ago
|
||
Updated•19 days ago
|
Updated•8 days ago
|
Updated•7 days ago
|
Description
•