- From: Andrew Wilson <atwilson@google.com>
- Date: Tue, 11 Jun 2013 10:04:36 +0200
- To: Justin DeWitt <dewittj@google.com>
- Cc: WG <public-web-notification@w3.org>
- Message-ID: <CAArhhiur9-hY-1VZWu1ywf_1F2oR99u5CKjP+ccN5jLHPRDytQ@mail.gmail.com>
I don't think this is an issue, since JS event handlers don't fire until you've re-entered the event loop. On Mon, Jun 10, 2013 at 7:16 PM, Justin DeWitt <dewittj@google.com> wrote: > Hi, > > In continuing to read the spec, I came across the example in Section > 6.1[1] where the notification is created using the constructor and then > event handlers are attached in the next few lines. Doesn't this introduce > a race between the JS context and the user agent? I could imagine this > causing an issue if the notification were shown immediately, since the > "show" event could fire before the "onshow" event handler was attached. > > Can we update the constructor to accept the various event handlers in the > options dictionary? I suppose it would be something like updating the API > section [2] to include the following text (steps 9-12 are new): > > The Notification(title, options) constructor must run these steps: > > 1. Let notification be a new notification<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#concept-notification> represented > by a Notification<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#notification> > object. > 2. Set notification's title<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#title> > to title. > 3. Set notification's direction<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#direction> > to options's dir. > 4. If options's lang is a valid BCP 47 language tag, or the empty > string, set notification's language<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#language> > to options's lang, or set it to the empty string otherwise. [LANG]<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#refsLANG> > 5. Set notifications's origin<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#origin> to > the current origin<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#origin> > . > 6. If options's body is present, set notification's body<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#body> > to body. > 7. If options's tag is present, set notification's tag<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#tag> > to tag. > 8. If options's icon is present, resolve<http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#resolve-a-url> > icon against the entry script<http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#entry-script> > 's base URL<http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#script's-base-url>, > and if that does not fail, set notification's icon URL<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#icon-url> to > the resulting absolute URL<http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#absolute-url>. > (Otherwise icon URL<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#icon-url> is > not set.) > 9. If *options*'s onshow is present, set *notification*'s onshow<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#handler-onshow>handler to > onshow. > 10. If *options*'s onclose is present, set *notification*'s onclose<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#handler-onclose>handler to > onclose. > 11. If *options*'s onerror is present, set *notification*'s onerror<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#handler-onerror>handler to > onerror. > 12. If *options*'s onclick is present, set *notification*'s onclick<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#handler-onclick>handler to > onclick. > 13. Return notification, but continue running these steps > asynchronouusly. > 14. If the notification platform supports icons, the user agent may > start fetching<http://www.whatwg.org/specs/web-apps/current-work/multipage/fetching-resources.html#fetch> > notification's icon URL<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#icon-url> at > this point, if icon URL<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#icon-url> is > set. > 15. Run the show steps<https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#show-steps> > for notification. > > > Alternately, there could be a handlers object in *options* that contains > all the event handlers. > > Justin > > [1] > https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#using-events > [2] https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html#api >
Received on Tuesday, 11 June 2013 08:05:07 UTC