Bug 366374 - macos: Check for profile before opening an url. r=mac-reviewers,spohl

There's windows-specific code which checks if a profile has been selected
before opening an url in a new window. This code is also useful for macos. It
fixes the bug that opens an empty window if you attempt to click a link before
a profile has been selected.

Differential Revision: https://phabricator.services.mozilla.com/D190988
This commit is contained in:
seb
2023-10-13 20:45:29 +00:00
parent fc106708d3
commit db5a2283f3

View File

@@ -1228,13 +1228,16 @@ nsDefaultCommandLineHandler.prototype = {
return; return;
} }
if (AppConstants.platform == "win") { if (AppConstants.platform == "win" || AppConstants.platform == "macosx") {
// If we don't have a profile selected yet (e.g. the Profile Manager is // Handle the case where we don't have a profile selected yet (e.g. the
// displayed) we will crash if we open an url and then select a profile. To // Profile Manager is displayed).
// prevent this handle all url command line flags and set the command line's // On Windows, we will crash if we open an url and then select a profile.
// preventDefault to true to prevent the display of the ui. The initial // On macOS, if we open an url we don't experience a crash but a broken
// command line will be retained when nsAppRunner calls LaunchChild though // window is opened.
// urls launched after the initial launch will be lost. // To prevent this handle all url command line flags and set the
// command line's preventDefault to true to prevent the display of the ui.
// The initial command line will be retained when nsAppRunner calls
// LaunchChild though urls launched after the initial launch will be lost.
if (!this._haveProfile) { if (!this._haveProfile) {
try { try {
// This will throw when a profile has not been selected. // This will throw when a profile has not been selected.