Bug 1805514 - Part 1: Support launch_action in Windows native toast notifications. r=barret
`launch_action` is both top-level (when the toast is clicked) and per-action (when a button is clicked). Differential Revision: https://phabricator.services.mozilla.com/D182312
This commit is contained in:
@@ -59,6 +59,22 @@
|
||||
"type": "string",
|
||||
"format": "moz-url-format"
|
||||
},
|
||||
"launch_action": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The launch action to be performed when Firefox is launched."
|
||||
},
|
||||
"data": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"requireInteraction": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the toast notification should remain active until the user clicks or dismisses it, rather than closing automatically."
|
||||
@@ -92,6 +108,22 @@
|
||||
"windowsSystemActivationType": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to have Windows process the given `action`."
|
||||
},
|
||||
"launch_action": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The launch action to be performed when Firefox is launched."
|
||||
},
|
||||
"data": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
@@ -993,6 +993,22 @@
|
||||
"type": "string",
|
||||
"format": "moz-url-format"
|
||||
},
|
||||
"launch_action": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The launch action to be performed when Firefox is launched."
|
||||
},
|
||||
"data": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"requireInteraction": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the toast notification should remain active until the user clicks or dismisses it, rather than closing automatically."
|
||||
@@ -1026,6 +1042,22 @@
|
||||
"windowsSystemActivationType": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to have Windows process the given `action`."
|
||||
},
|
||||
"launch_action": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The launch action to be performed when Firefox is launched."
|
||||
},
|
||||
"data": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
@@ -32,6 +32,20 @@
|
||||
"type": "string",
|
||||
"format": "moz-url-format"
|
||||
},
|
||||
"launch_action": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The launch action to be performed when Firefox is launched."
|
||||
},
|
||||
"data": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": ["type"],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"requireInteraction": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the toast notification should remain active until the user clicks or dismisses it, rather than closing automatically."
|
||||
@@ -65,6 +79,20 @@
|
||||
"windowsSystemActivationType": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to have Windows process the given `action`."
|
||||
},
|
||||
"launch_action": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The launch action to be performed when Firefox is launched."
|
||||
},
|
||||
"data": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": ["type"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"required": ["action", "title"],
|
||||
|
||||
@@ -576,6 +576,44 @@ const MESSAGES = () => [
|
||||
trigger: { id: "backgroundTaskMessage" },
|
||||
frequency: { lifetime: 3 },
|
||||
},
|
||||
{
|
||||
id: "TEST_TOAST_NOTIFICATION2",
|
||||
weight: 100,
|
||||
template: "toast_notification",
|
||||
content: {
|
||||
title: "Launch action on toast click and on action button click",
|
||||
body: "Body",
|
||||
image_url:
|
||||
"https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/a3c640c8-7594-4bb2-bc18-8b4744f3aaf2.gif",
|
||||
launch_action: {
|
||||
type: "OPEN_URL",
|
||||
data: { args: "https://mozilla.org", where: "window" },
|
||||
},
|
||||
requireInteraction: true,
|
||||
actions: [
|
||||
{
|
||||
action: "dismiss",
|
||||
title: "Dismiss",
|
||||
windowsSystemActivationType: true,
|
||||
},
|
||||
{
|
||||
action: "snooze",
|
||||
title: "Snooze",
|
||||
windowsSystemActivationType: true,
|
||||
},
|
||||
{
|
||||
action: "private",
|
||||
title: "Private Window",
|
||||
launch_action: { type: "OPEN_PRIVATE_BROWSER_WINDOW" },
|
||||
},
|
||||
],
|
||||
tag: "test_toast_notification",
|
||||
},
|
||||
groups: ["panel-test-provider"],
|
||||
targeting: "!hasActiveEnterprisePolicies",
|
||||
trigger: { id: "backgroundTaskMessage" },
|
||||
frequency: { lifetime: 3 },
|
||||
},
|
||||
{
|
||||
id: "MR2022_BACKGROUND_UPDATE_TOAST_NOTIFICATION",
|
||||
weight: 100,
|
||||
|
||||
@@ -102,12 +102,28 @@ const ToastNotification = {
|
||||
action.title
|
||||
);
|
||||
}
|
||||
if (action.launch_action) {
|
||||
action.opaqueRelaunchData = JSON.stringify(action.launch_action);
|
||||
delete action.launch_action;
|
||||
}
|
||||
}
|
||||
alert.actions = actions;
|
||||
}
|
||||
|
||||
if (content.launch_url) {
|
||||
alert.launchURL = Services.urlFormatter.formatURL(content.launch_url);
|
||||
// Populate `opaqueRelaunchData`, prefering `launch_action` if given,
|
||||
// falling back to `launch_url` if given.
|
||||
let relaunchAction = content.launch_action;
|
||||
if (!relaunchAction && content.launch_url) {
|
||||
relaunchAction = {
|
||||
type: "OPEN_URL",
|
||||
data: {
|
||||
args: content.launch_url,
|
||||
where: "tab",
|
||||
},
|
||||
};
|
||||
}
|
||||
if (relaunchAction) {
|
||||
alert.opaqueRelaunchData = JSON.stringify(relaunchAction);
|
||||
}
|
||||
|
||||
let shownPromise = lazy.PromiseUtils.defer();
|
||||
|
||||
@@ -25,7 +25,7 @@ add_task(async function test_PanelTestProvider() {
|
||||
whatsnew_panel_message: 7,
|
||||
spotlight: 3,
|
||||
pb_newtab: 2,
|
||||
toast_notification: 2,
|
||||
toast_notification: 3,
|
||||
};
|
||||
|
||||
const EXPECTED_TOTAL_MESSAGE_COUNT = Object.values(
|
||||
|
||||
Reference in New Issue
Block a user