commit bcae93afe265d4fe48afb4217c0b8da9b92d6324
parent 64d90c3f9a4ab0b1d96b0994609fff7dd39fc28d
Author: Harsheet <hsohaney@mozilla.com>
Date: Mon, 1 Dec 2025 21:36:05 +0000
Bug 2003307 - Open the user's start page by default on restore. r=cdupuis
Differential Revision: https://phabricator.services.mozilla.com/D274631
Diffstat:
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/browser/components/backup/BackupService.sys.mjs b/browser/components/backup/BackupService.sys.mjs
@@ -3404,7 +3404,12 @@ export class BackupService extends EventTarget {
await profileSvc.asyncFlush();
if (shouldLaunch) {
- Services.startup.createInstanceWithProfile(profile);
+ // Launch with the user's default homepage instead of the last selected tab
+ // to avoid problems with the messaging system (see Bug 2002732)
+ Services.startup.createInstanceWithProfile(profile, [
+ "--url",
+ "about:home",
+ ]);
}
return profile;
diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp
@@ -1065,7 +1065,8 @@ nsAppStartup::RestartInSafeMode(uint32_t aQuitMode) {
}
NS_IMETHODIMP
-nsAppStartup::CreateInstanceWithProfile(nsIToolkitProfile* aProfile) {
+nsAppStartup::CreateInstanceWithProfile(nsIToolkitProfile* aProfile,
+ const nsTArray<nsString>& aArgs) {
if (NS_WARN_IF(!aProfile)) {
return NS_ERROR_FAILURE;
}
@@ -1098,8 +1099,15 @@ nsAppStartup::CreateInstanceWithProfile(nsIToolkitProfile* aProfile) {
NS_ConvertUTF8toUTF16 wideName(profileName);
- const char16_t* args[] = {u"-P", wideName.get()};
- rv = process->Runw(false, args, 2);
+ // Build argument list: -P <profile_name> followed by any additional args
+ AutoTArray<const char16_t*, 2> args = {u"-P", wideName.get()};
+
+ // Add optional arguments if provided
+ for (const auto& arg : aArgs) {
+ args.AppendElement(arg.get());
+ }
+
+ rv = process->Runw(false, args.Elements(), args.Length());
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
diff --git a/toolkit/components/startup/public/nsIAppStartup.idl b/toolkit/components/startup/public/nsIAppStartup.idl
@@ -73,9 +73,12 @@ interface nsIAppStartup : nsISupports
* Run a new instance of this app with a specified profile
* @param aProfile
* The profile we want to use.
+ * @param aArgs
+ * Optional command line arguments to pass to the new instance.
* @see nsIAppStartup::quit
*/
- void createInstanceWithProfile(in nsIToolkitProfile aProfile);
+ void createInstanceWithProfile(in nsIToolkitProfile aProfile,
+ [optional] in Array<AString> aArgs);
/**
* If the last startup crashed then increment a counter.