Closed
Bug 1265841
Opened 9 years ago
Closed 9 years ago
Implement the `notificationclose` service worker event
Categories
(Core :: DOM: Push Subscriptions, defect)
Core
DOM: Push Subscriptions
Tracking
()
RESOLVED
FIXED
mozilla49
| Tracking | Status | |
|---|---|---|
| firefox49 | --- | fixed |
People
(Reporter: lina, Assigned: lina)
References
Details
(Whiteboard: btpp-active)
Attachments
(1 file, 1 obsolete file)
We don't implement `notificationclose` (https://notifications.spec.whatwg.org/#closing-a-notification) yet, so a service worker can't know when a persistent notification is closed.
| Assignee | ||
Updated•9 years ago
|
Assignee: nobody → kcambridge
Status: NEW → ASSIGNED
Whiteboard: btpp-active
| Assignee | ||
Comment 1•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/47715/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/47715/
Attachment #8743321 -
Flags: review?(wchen)
Attachment #8743321 -
Flags: review?(amarchesini)
| Assignee | ||
Comment 2•9 years ago
|
||
https://reviewboard.mozilla.org/r/47715/#review44507
::: dom/notification/Notification.cpp:1730
(Diff revision 1)
> // The observer is wholly owned by the NotificationObserver passed to the alert service.
> - observer = new ServiceWorkerNotificationObserver(mScope, GetPrincipal(), mID);
> + nsAutoString behavior;
> + if (NS_WARN_IF(!mBehavior.ToJSON(behavior))) {
> + behavior.Truncate();
> + }
> + observer = new ServiceWorkerNotificationObserver(mScope,
It might make sense for `ServiceWorkerNotificationObserver` to just take ownership of the notification, as `{MainThread, Worker}NotificationObserver` already do.
But I'm not sure if that means we need to register a feature to keep the notification alive. It also seems like persistent notifications can be accessed from either thread; I'm assuming that's one of the reasons we release the notification and call `ConstructFromFields` when we need it again.
| Assignee | ||
Comment 3•9 years ago
|
||
Comment on attachment 8743321 [details]
MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/47715/diff/1-2/
| Assignee | ||
Comment 4•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/47941/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/47941/
Attachment #8743622 -
Flags: review?(wchen)
| Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8743321 [details]
MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/47715/diff/2-3/
| Assignee | ||
Updated•9 years ago
|
| Assignee | ||
Comment 6•9 years ago
|
||
Comment on attachment 8743321 [details]
MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/47715/diff/3-4/
| Assignee | ||
Updated•9 years ago
|
Attachment #8743622 -
Attachment is obsolete: true
Attachment #8743622 -
Flags: review?(wchen)
| Assignee | ||
Comment 7•9 years ago
|
||
I haven't been keeping up with the changes to https://notifications.spec.whatwg.org/, but it looks like notifications created via the `Notification` constructor no longer have `onshow` or `onclose` events. I guess that's because they're meant to be temporary (https://github.com/whatwg/notifications/issues/31#issuecomment-75955968), as opposed to persistent service worker notifications.
Comment 8•9 years ago
|
||
Comment on attachment 8743321 [details]
MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
https://reviewboard.mozilla.org/r/47715/#review45969
::: dom/notification/Notification.cpp:1590
(Diff revision 4)
> - return rv;
> + return rv;
> - }
> + }
>
> - nsCOMPtr<nsIServiceWorkerManager> swm =
> + nsCOMPtr<nsIServiceWorkerManager> swm =
> - mozilla::services::GetServiceWorkerManager();
> + mozilla::services::GetServiceWorkerManager();
> + if (NS_WARN_IF(!swm)) {
If swm is not available we should still remove the notification from notification storage since it's no longer around.
::: dom/workers/ServiceWorkerPrivate.cpp:1093
(Diff revision 4)
> +
> + return NS_OK;
> +}
> +
> +nsresult
> +ServiceWorkerPrivate::SendNotificationCloseEvent(const nsAString& aID,
There is a lot of duplicated code for ServiceWorkePrivate and ServiceWorkerManager. Can you refactor the function to take the event as a parameter, similar to what you did for SendNotificationEventRunnable?
Attachment #8743321 -
Flags: review?(wchen)
| Assignee | ||
Comment 9•9 years ago
|
||
Comment on attachment 8743321 [details]
MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/47715/diff/4-5/
Attachment #8743321 -
Flags: review?(wchen)
Comment 10•9 years ago
|
||
Comment on attachment 8743321 [details]
MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
https://reviewboard.mozilla.org/r/47715/#review46395
::: dom/notification/Notification.cpp:1630
(Diff revision 5)
> if (notificationStorage) {
> notificationStorage->Delete(origin, mID);
> }
> +
> + if (!NS_WARN_IF(!swm)) {
> + swm->SendNotificationCloseEvent(originSuffix,
Let's handle the nsresult from SendNotificationCloseEvent and SendNotificationClickEvent.
Attachment #8743321 -
Flags: review?(wchen) → review+
| Assignee | ||
Comment 11•9 years ago
|
||
Haitao, CCing you on this bug, since it might affect bug 1264815. If you're refactoring `ServiceWorkerNotificationObserver`, it probably makes sense to have this bug depend on yours, but it's up to you.
Comment 12•9 years ago
|
||
Comment on attachment 8743321 [details]
MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
https://reviewboard.mozilla.org/r/47715/#review53080
::: dom/notification/Notification.cpp:1600
(Diff revision 5)
> - }
> + }
>
> - nsCOMPtr<nsIServiceWorkerManager> swm =
> + nsCOMPtr<nsIServiceWorkerManager> swm =
> - mozilla::services::GetServiceWorkerManager();
> + mozilla::services::GetServiceWorkerManager();
>
> - if (swm) {
> + if (!strcmp("alertclickcallback", aTopic) && !NS_WARN_IF(!swm)) {
I prefer to have:
if (NS_WARN_IF(!swm)) {
return NS_ERROR_FAILURE;
}
::: dom/notification/Notification.cpp:1629
(Diff revision 5)
> do_GetService(NS_NOTIFICATION_STORAGE_CONTRACTID);
> if (notificationStorage) {
> notificationStorage->Delete(origin, mID);
> }
> +
> + if (!NS_WARN_IF(!swm)) {
if (NS_WARN_IF(!swm)) {
return NS_ERROR_FAILURE;
}
this if (!NS_WARN_IF(!swm)) is confusing
Attachment #8743321 -
Flags: review?(amarchesini) → review+
| Assignee | ||
Comment 13•9 years ago
|
||
Comment on attachment 8743321 [details]
MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/47715/diff/5-6/
Attachment #8743321 -
Attachment description: MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r?wchen,baku → MozReview Request: Bug 1265841 - Implement the `notificationclose` service worker event. r=wchen,baku
| Assignee | ||
Comment 14•9 years ago
|
||
Comment 15•9 years ago
|
||
Pushed by kcambridge@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/253aa0a9809b
Implement the `notificationclose` service worker event. r=wchen,baku
Comment 16•9 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in
before you can comment on or make changes to this bug.
Description
•