[whatwg] Implementation question about Notifications

Andrew Wilson atwilson at google.com
Thu Nov 14 06:45:19 PST 2013


The notification spec (http://notifications.spec.whatwg.org/#api) says that
the Notification object has the following readonly attributes: title, dir,
lang, body, tag, icon.

Let's say I make the following calls:

var n1 = new Notification("title");
var n2 = new Notification("title", {icon: "invalid_icon_url"});
var n3 = new Notification("title", {icon: "http://non-existent-icon.com"});

What should:

n1.dir
n1.lang
n1.body
n1.tag
n1.icon

resolve to? I think that it should be:

n1.dir == "auto"
n1.lang == ""
n1.body === undefined
n1.tag === undefined
n1.icon === undefined

Do you agree? Or should it map to something different?

What about n2.icon and n3.icon - what should they read? I'm curious, given
that section 4.9.1 reads:

If the notification platform supports icons, notification's icon URL is set
> and has not yet been fetched, fetch it and wait for the resource to be
> fully downloaded.
> Once fetching has finished and the image format is supported, set
> notification's icon to the decoded resource. (Otherwise notification has no
> icon.)


I'm not certain if "set notification's icon" refers to just the visible
image within the notification, or to the *Notification.icon* attribute
itself - I'm assuming the former (since we don't want to wait for a network
fetch before setting the Notification.icon attribute) so perhaps we should
rephrase this as "set notification's icon image to the decoded resource"?

Also, step 8 in the constructor description says:

If options's icon is present, parse icon using the API base URL specified
> by the entry settings object, and if that does not return failure, set
> notification's icon URL to the return value. (Otherwise icon URL is not
> set.)


...so it seems pretty clear that Notification.icon should be undefined if
the passed NotificationOptions.icon attribute is unparseable. Agreed?

-atw


More information about the whatwg mailing list