Open Bug 1364971 Opened 7 years ago Updated 2 years ago

Allow WebExtensions to disable popups

Categories

(WebExtensions :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: bsilverberg, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: triaged[browserSettings])

This will use browserSetting [1] to manage which extension has control over the pref. This does not really belong in privacy so will go into the browserSettings API.

According to the notes in [2], this would make use of the `dom.disable_open_during_load`, which seems to be accurate looking at m-c code. That is a boolean, so this can be browser.browserSettings.popupsEnabled.

[1] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/privacy/BrowserSetting
[2] https://docs.google.com/document/d/1HZiI-dqFATzLpmTtN1Bg6tD8y4N0Ne3D74LEWWgttOk/edit#
This is yet another pref that is exposed via the preferences UI, so before we consider implementing this we need to address the issue of if and how we are going to give WebExtensions access to settings that are also available via the UI. This is being discussed in more detail in bug 1361364.
Depends on: 1368537
Rob, as the author of the doc that originally asked for this, I am seeking some clarification from you. The discussion that we're having in bug 1339550 seems to indicate that if we want to actually disable all popups, we should both set `dom.disable_open_during_load` to "true" and also set `dom.popup_allowed_events` to "". In fact, `dom.disable_open_during_load` is set to "true" by default, so it seems odd that developers are asking for an API that only sets that pref to "true" if it's usually "true" anyway.

Can you please confirm whether the use cases you were looking at would also require setting `dom.popup_allowed_events` to "", or whether they are only concerned with setting `dom.disable_open_during_load` to "true"?
Flags: needinfo?(rob)
(In reply to Bob Silverberg [:bsilverberg] from comment #2)
> Rob, as the author of the doc that originally asked for this, I am seeking
> some clarification from you. The discussion that we're having in bug 1339550
> seems to indicate that if we want to actually disable all popups, we should
> both set `dom.disable_open_during_load` to "true" and also set
> `dom.popup_allowed_events` to "". In fact, `dom.disable_open_during_load` is
> set to "true" by default, so it seems odd that developers are asking for an
> API that only sets that pref to "true" if it's usually "true" anyway.

Popups can be enabled and disabled.
 
> Can you please confirm whether the use cases you were looking at would also
> require setting `dom.popup_allowed_events` to "", or whether they are only
> concerned with setting `dom.disable_open_during_load` to "true"?

I don't think that dom.popup_allowed_events should be touched, because not opening popups in response to a user gesture would break the web.

The meaning of "block popups" should be the same as "block popups" in Firefox settings.
Flags: needinfo?(rob)
We will use the default permission pref (once implemented) for this.
Depends on: 1313939
No longer depends on: 1368537
Hi
I want to know when this bug will resolved?
I talk about this bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1339550
Please write some information about it.
It will implement? or not?
I need this :
dom.popup_allowed_events
to changed via my addon.
(In reply to Mojtaba Daneshi from comment #7)
> I need this :
> dom.popup_allowed_events
> to changed via my addon.

I'm not sure when it will get resolved. It now depends on bug 1313939 as we will be using permissions for this. I believe that the permission approach will work for you as well, and you will not need to toggle "popup_allowed_events" because if the default permission for pop-ups is set to "false" then pop-ups should be blocked by default.
Keep in mind I talk about popups that firefox could NOT blocks them,
They fire after mouse click.
So dom.disable_open_during_load is not enough for me.
Just need to empty events that fire popups with "popup_allowed_events" prefs.
It should has a options to revert prefs after addons uninstalled.
currently we can just set a url when addon become uninstalled and there is not any callback same as onInstalled in web extensions.
So that's better to implement a callback for onUninstalled too.
(In reply to Mojtaba Daneshi from comment #9)
> Keep in mind I talk about popups that firefox could NOT blocks them,
> They fire after mouse click.
> So dom.disable_open_during_load is not enough for me.
> Just need to empty events that fire popups with "popup_allowed_events" prefs.

I'm not sure that you actually need that. If the permission for pop-ups for a page is set to "false" I would have thought that would be enough to block these pop-ups even after mouse clicks. Can you test that, by manually setting the permission yourself, and see if that is the case?
I tested it.
Sites can open popups ever permission set to Block.
Please do not change my bug.
Popups Just will blocked when "popup_allowed_events" set to empty.
My bug was about it.
You can test it 
http://www.mehrsamweb.ir/
set permission to Block popups for this page,then just click on that page.
I need it, If you won't implement it let me know to change my way.
Sincerely
(In reply to Mojtaba Daneshi from comment #11)
> I tested it.
> Sites can open popups ever permission set to Block.
> Please do not change my bug.
> Popups Just will blocked when "popup_allowed_events" set to empty.
> My bug was about it.
> You can test it 
> http://www.mehrsamweb.ir/
> set permission to Block popups for this page,then just click on that page.
> I need it, If you won't implement it let me know to change my way.
> Sincerely

Thanks Mojtaba. Yes, that seems to be the case. Even with the permission set to "false" for that page the pop-ups still occur but not if popup_allowed_events is set to "". I'm not sure what the best way to deal with this is though. I'm going to reopen the other bug and discuss it there.
Thanks.
Please add a callback for uninstalling addons to revert them to default.
(In reply to Mojtaba Daneshi from comment #13)
> Thanks.
> Please add a callback for uninstalling addons to revert them to default.

If we implement this via browserSettings (which is the intent) then that will be taken care of automatically.
Thank you so much.
Depends on: 1379560
No longer depends on: 1313939
Johann, I'm just following up on this. Do we have things in place right now to implement this, or does some platform work need to be done to support a default permission for popups?
Flags: needinfo?(jhofmann)
(In reply to Bob Silverberg [:bsilverberg] from comment #16)
> Johann, I'm just following up on this. Do we have things in place right now
> to implement this, or does some platform work need to be done to support a
> default permission for popups?

Since, as mentioned, popups are already blocked by default, I assume your intent is to block popups even from allowed user events. Giving extensions access to popup_allowed_events should do the trick.

If we expose this pref to extensions, we should find a way to alert the user about it, because there could be quite some web compat breakage (sites often try to show valid popups in user events).
Flags: needinfo?(jhofmann)
Assignee: bob.silverberg → nobody
Priority: P2 → P3
Product: Toolkit → WebExtensions
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.