Notification clicks are not treated as user input handlers
Categories
(WebExtensions :: Frontend, defect, P3)
Tracking
(Not tracked)
People
(Reporter: me, Unassigned, Mentored)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
Steps to reproduce:
My extension downloads a file and sends a notification when the download is complete:
chrome.notifications.create("", {
type: "basic",
title: "NoPlugin",
message: filename + " has finished downloading. Click here to open it.",
iconUrl: "img/icon128.png"
}, function(id) {
myNotificationID = id;
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
}
});
chrome.notifications.onClicked.addListener(function(notifId, btnIdx) {
if (notifId === myNotificationID) {
chrome.downloads.open(videoID);
}
});
Actual results:
Clicking the notification does nothing, and this message appears in the console:
Unchecked lastError value: Error: downloads.open may only be called from a user input handler
Expected results:
Clicking the notification should open the downloaded file. It seems Firefox doesn't recognize clicking a notification as a user gesture.
Updated•7 years ago
|
Updated•7 years ago
|
Updated•7 years ago
|
Comment 1•7 years ago
|
||
To fix this, we need to add inputHandling: true, to the EventManager at https://searchfox.org/mozilla-central/rev/9eb30227b21e0aa40d51d9f9b08bb0b113c5fadb/toolkit/components/extensions/parent/ext-notifications.js#136
and a unit test to verify that a notification click counts as a user interaction.
Comment 2•7 years ago
|
||
Its a little more complicated than that -- browser.permissions.request() requires that when it is invoked (which must be during a user input handler), that it can find the <browser> where the interaction occurred so that it can figure out the appropriate place to display the doorhanger. A click on a desktop notification is not actually an interaction with the browser so we need to decide what to use here. This highlights a probably unlikely but possible situation: a user could click on a notification when there are no visible browser windows. The simplest thing would probably be for permissions.request() to just fail in that case. That would be frustrating for extension authors, but I can't think offhand of anything better...
Comment 3•7 years ago
|
||
Hello. I am new to Open source programming. Is this bug still open? If so I would like to try my hand at working on this with some mentoring. Thank you.
Comment 4•7 years ago
|
||
Hi ithompson4, this bug is no longer a good-first-bug because we need to evaluate whether we want to count clicking on a notification as a user interaction, since it is not obvious how we should associate a notification click with a UI element in the browser window (e.g. tab). This is because notifications are not necessarily associated with tabs, and some APIs that rely on user input assume that user interaction is associated with a <browser> element (usually a tab).
If you wish to make a contribution, I suggest to pick another bug from https://codetribute.mozilla.org/projects/webextensions .
Out of the many options on the list, I would say that bug 1520058 and/or bug 1517993 are good for new contributors such as you. If you want to start with either of them, just comment in the respective bug.
Comment 5•7 years ago
|
||
Apparently we already had an older bug for this - bug 1402612
Description
•