Open Bug 1402612 Opened 7 years ago Updated 2 years ago

notifications.onClicked is not a "user input handler"

Categories

(WebExtensions :: General, defect, P3)

58 Branch
defect

Tracking

(firefox57 wontfix)

UNCONFIRMED
Tracking Status
firefox57 --- wontfix

People

(Reporter: moniseat101, Unassigned, NeedInfo)

References

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0
Build ID: 20170923100045

Steps to reproduce:

Platform: Firefox Nightly 2017-9-23 64-bit for linux

Create a webextension which uses "notifications", "downloads", and "downloads.open" - see code below. Download anything then click the notification which pops up when the download completes.

```
function onNotifClicked(notificationId)
{
    var downloadId = parseInt(notificationId);

    var opening = browser.downloads.open(downloadId);
    opening.then(function (){}, function (error){console.log(`error = ${error}`)});
}


function dlComplete(download_list)
{
    download = download_list[0];

    if (download.state != browser.downloads.State.COMPLETE)
    {
        return
    }

    var notif = browser.notifications.create(download.id.toString(), {
                    "type": "basic",
                    "title": "wow. such notification",
                    "message": "many click"
                });

}


function onDlChange(download)
{
        if ((download.state.previous != browser.downloads.State.IN_PROGRESS) ||
                (download.state.current == browser.downloads.State.IN_PROGRESS))
        {
            return;
        }
        var query = browser.downloads.search({"id": download.id});
        query.then(dlComplete, function (error){console.log(`error = ${error}`)});
}

browser.downloads.onChanged.addListener(onDlChange);
browser.notifications.onClicked.addListener(onNotifClicked);
```


Actual results:

error = Error: downloads.open may only be called from a user input handler


Expected results:

I expected that browser.notifications.onClicked would be considered a "user input handler". Thus, the downloads.open command should be carried out rather than rejected.
This sounds reasonable to me. Marking as a P3 but wontfix for 57.
Priority: -- → P3
Product: Toolkit → WebExtensions

FYI bug 1523523 has some discussion on the implementation aspects of this.

(In reply to Rob Wu [:robwu] from https://bugzilla.mozilla.org/show_bug.cgi?id=1523523#c4)

[...] 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).

:robwu from the closed bug you mentioned above, this seems like the first thing to decide if we ever want to fix this bug. The potential patch for this will likely impact various WE APIs not just the download one (e.g., permissions.request()).

Flags: needinfo?(rob)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.