Bug 1962454 - Pass origin instead of host/port to Windows notification r=nalexander,win-reviewers,firefox-desktop-core-reviewers ,gstoll

This is to match NotificationDB that uses origin.

Differential Revision: https://phabricator.services.mozilla.com/D236586
This commit is contained in:
Sebastian Hengst
2025-05-14 15:29:56 +00:00
committed by krosylight@mozilla.com
parent ebcb0e730a
commit b10370a112
9 changed files with 191 additions and 24 deletions

View File

@@ -1394,11 +1394,16 @@ nsDefaultCommandLineHandler.prototype = {
// window to perform the action in.
let winForAction;
if (
!tagWasHandled &&
notificationData?.launchUrl &&
!opaqueRelaunchData
) {
// Fall back to launchUrl to not break notifications opened from
// previous builds after browser updates, as such notification would
// still have the old field.
let origin = notificationData?.origin ?? notificationData?.launchUrl;
if (!tagWasHandled && origin && !opaqueRelaunchData) {
let originPrincipal =
Services.scriptSecurityManager.createContentPrincipalFromOrigin(
origin
);
// Unprivileged Web Notifications contain a launch URL and are
// handled slightly differently than privileged notifications with
// actions. If the tag was not handled, then the notification was
@@ -1406,7 +1411,9 @@ nsDefaultCommandLineHandler.prototype = {
// fallback behavior.
let { uri, principal } = resolveURIInternal(
cmdLine,
notificationData.launchUrl
// TODO(krosylight): We should handle origin suffix to open the
// relevant container. See bug 1945501.
originPrincipal.originNoSuffix
);
if (cmdLine.state != Ci.nsICommandLine.STATE_INITIAL_LAUNCH) {
// Try to find an existing window and load our URI into the current