« first day (962 days earlier)      last day (269 days later) » 

5:28 PM
in The Bridge on The Stack Exchange Network Chat, 1 hour ago, by Yi Jiang's Evil Clone
https://bugzilla.mozilla.org/show_bug.cgi?id=594543#c49
Support for Notification has landed in Firefox nightly, it looks like Chrome (at least dev) supports the same interface. Chat should probably consider updating to use window.Notification in the near future.
 
nice
how long does FF usually take from nightly to stable?
 
I'm not sure, I'm not a big FF user.
Hmm, I'm also trying to figure out when Chrome implemented the W3C notification spec.
 
they haven't
 
Hmm? It's in dev.
 
hmm, maybe I'm misunderstanding the spec
 
5:43 PM
I'm not sure if it's fully conformant, but it's spec-like enough to be consistent for general use across Firefox/Chrome once the changes land in stable.
 
the thing I'm confused about is Notification.permission. The spec calls that static, which to me means that you should have access without creating a notification object. If you can't -- and that's what the chrome version suggests -- it means that you can't check whether you have notification permissions without actually showing one (because the constructor immediately shows it).
Which would be horribly stupid, and unusable for us.
 
Hmmm, yes...that does seem dumb.
Let's see...
 
okay, this hack works I guess
new Notification("").onshow = function () { console.log("I have permission"); this.close(); }
at least if the browser doesn't queue any animation
 
Ah..
Yeah, if you deny permission in Chrome, Notification.requestPermission() doesn't prompt the user again and just returns "denied" to the callback, but it's kind of stupid you can't determine the permission without risking that they might be prompted.
 
5:59 PM
at least they don't let creating a notification cause a prompt
 
Oh
This is apparently a V8 bug
The permission attribute is supposed to be on the constructor, but it ends up on the instance instead.
 
well, at least that means I read the spec right :)
 
You can query the permission using the existing WebKit-specific implementation though, so something like Notification.permission === 'granted' || (window.webkitNotifications && webkitNotifications.checkPermissions() === 0) would suffice as a workaround.
Or you could always get real fancy and just stub out the property. :P
if (!Notification.permission && window.webkitNotifications) {
    Object.defineProperty(window.Notification, "permission", {
        get: function () {
            return ["granted", "denied", "default"][webkitNotifications.checkPermission()];
        }
    });
}
 
6:46 PM
...Except with "denied" and "default" switched because I can't read.
 

« first day (962 days earlier)      last day (269 days later) »