-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DBW: Audit for notification permissions on start #1064
DBW: Audit for notification permissions on start #1064
Conversation
8c33c16
to
8a88506
Compare
8a88506
to
3e9ece0
Compare
Note: this doesn't seem to work when the permissions request comes from a different domain from within an iframe (test url: https://developer.mozilla.org/en-US/docs/Web/API/Notification) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Looks ripe for an "audit helper" now that we have duplication between gatherers. I'd imagine we'll eventually have a few more of these permission gatherers (media apis, etc.)
}).catch(err => { | ||
this.artifact = { | ||
value: -1, | ||
debugString: err && err.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
geolocation uses e.message
. Can we make them consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, do we want to standardize on message and not include the error name then? would have benefit of accepting non-Error
objects I suppose too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err.toString()
might be more noise in the html report. Not sure how that will look.
afterPass(options) { | ||
return options.driver.evaluateAsync(`(${queryNotificationPermission.toString()}())`) | ||
.then(state => { | ||
if (state === 'granted' || state === 'denied') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add || state === 'denied'
to the geolocation audit too? It only checks state === 'granted'
atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Can you file a bug for that? I suspect that also applies to the geolocation audit and we'll need to think of a solution. |
/* global navigator */ | ||
|
||
/* istanbul ignore next */ | ||
function queryNotificationPermission() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it would be great to pull this out into driver.queryPermissionStatus
or whatever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do
*/ | ||
queryPermissionState(name) { | ||
const expressionToEval = ` | ||
(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to wrap? navigator.permissions.query({name: ${name}}).then(result => result.state)
is also an expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, any specific reason for the JSON.stringify
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh I guess no wrap necessary, and just in case name
contained a '
or "
didn't want an inscrutable error message
@@ -433,12 +433,14 @@ class Driver { | |||
* See https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query. | |||
*/ | |||
queryPermissionState(name) { | |||
if (['geolocation', 'notifications', 'midi', 'push'].indexOf(name) === -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah @ebidel this was to remove the JSON.stringify
in response to @brendankenny's feedback since a malformed name wouldn't ever reach the friendly message. i'd lean toward my original stringify and let Chrome handle the enum check but I don't feel terribly strongly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too concerned about protecting against all errors like this. Shouldn't exceptionDetails
/when we land #1037 catch syntax errors like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. I think leaving off JSON.stringify
is ok since we'll be the ones writing the majority of audits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, shuttle wifi catch up! @brendankenny said the same thing :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright fair enough
PTAL :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ⏱🍿👮:no_good_man:
@patrickhulce whoops, totally missed that the notification-on-start audit doesn't have any tests. Should be fairly fast, can basically just copy the geolocation one |
Addresses #1060