After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 782386 - Permission to use notifications not remembered in webapp mode
Permission to use notifications not remembered in webapp mode
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: Web Applications
git master
Other Linux
: Normal normal
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-05-09 14:26 UTC by Adrian Perez
Modified: 2017-05-09 20:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix initial notification permissions in web app mode (2.97 KB, patch)
2017-05-09 19:55 UTC, Michael Catanzaro
committed Details | Review

Description Adrian Perez 2017-05-09 14:26:07 UTC
Steps to reproduce
------------------

 1. Open https://riot.im/app/ in Epiphany (If you don't have an account,
    probably any other page that uses desktop notifications will also
    work for reproducing the bug, but I haven't tested with other pages)

 2. Save the page as a web application using “Install as Web Application...”
    from the Epiphany window menu.

 3. Open the application created in the previous step.

 4. Log in to Matrix and enable desktop notifications, either in the bar
    that Riot shows suggesting that, or by ticking the checkbox in the
    Riot settings panel (cogwheel icon in the left sidebar).

 5. Epiphany will ask for permission to use desktop notifications. Allow
    them.

 6. Close the window, open it again, and open the Riot settings menu.


Expected outcome
----------------
 
 Epiphany remembers that the notifications are allowed for the web
 application and the “Enable desktop notifications” checkbox in the
 Riot settings panel is marked.


Actual outcome
--------------

 The permission to use desktop notifications is NOT saved, and the
 “Enable desktop notifications” checkbox in the Riot settings panel
 is UNMARKED.
Comment 1 Adrian Perez 2017-05-09 14:28:00 UTC
Epiphany behaves as described both in the current Git “master” and
also in version 3.24.1
Comment 2 Michael Catanzaro 2017-05-09 14:57:45 UTC
Looking over the code now, I don't spot any problems, so I remain to be convinced that this is an Epiphany bug. I can't test this now due to a database process crasher, but please find your Riot profile directory under ~/.config/epiphany and post the contents of permissions.ini. Is the notifications permission set there? If not, watch the file and see what happens when you grant it via the Riot web interface.
Comment 3 Adrian Perez 2017-05-09 15:05:58 UTC
(In reply to Michael Catanzaro from comment #2)
> Looking over the code now, I don't spot any problems, so I remain to be
> convinced that this is an Epiphany bug. I can't test this now due to a
> database process crasher, but please find your Riot profile directory under
> ~/.config/epiphany and post the contents of permissions.ini. Is the
> notifications permission set there? If not, watch the file and see what
> happens when you grant it via the Riot web interface.

There is only the “permissions.ini” for normal mode, but none of my
webapplication-specific profile directories have such a file:

  %  find ~/.config/epiphany/ -name permissions.ini
  /home/aperez/.config/epiphany/permissions.ini
  %

JFTR, I have 5 web applications saved right now:

  % ( cd ~/.config/epiphany/ && ls -dl * )
  drwx------ 1 aperez aperez     128 may  9 15:44 adblock/
  drwxr-x--- 1 aperez aperez     402 may  9 16:56 app-epiphany-mastodon-d8951096e3eedf7e3a438281a15f522b2bdee0f9/
  drwxr-x--- 1 aperez aperez     330 may  9 16:56 app-epiphany-riotweb-4b82d4ecaf1486897d26b6e46b72a346367b1d9a/
  drwxr-x--- 1 aperez aperez     464 may  9 16:56 app-epiphany-slack-430b38bf6daa7f9164b164b2ffd540b5a3afe2fd/
  -rw-r--r-- 1 aperez aperez     613 may  9 16:33 bookmarks.gvdb
  -rw-r--r-- 1 aperez aperez    3760 abr 19 18:23 bookmarks.rdf
  -rw-r--r-- 1 aperez aperez 1490944 may  9 15:21 cookies.sqlite
  -rw-r--r-- 1 aperez aperez   32768 may  9 17:59 cookies.sqlite-shm
  -rw-r--r-- 1 aperez aperez 4144752 may  9 17:59 cookies.sqlite-wal
  -rw-r--r-- 1 aperez aperez    5711 abr 19 18:23 ephy-bookmarks.xml
  -rw-r--r-- 1 aperez aperez 5705728 may  9 18:00 ephy-history.db
  -rw-r--r-- 1 aperez aperez     191 ene 30 15:33 page-setup-gtk.ini
  -rw-r--r-- 1 aperez aperez     761 may  9 16:30 permissions.ini
  -rw-r--r-- 1 aperez aperez   16444 may  9 18:00 session_state.xml
  -rw-r--r-- 1 aperez aperez   16459 may  9 18:00 session_state.xml~
  -rw-r--r-- 1 aperez aperez      52 feb 15 01:38 user-stylesheet.css
Comment 4 Adrian Perez 2017-05-09 15:10:47 UTC
(In reply to Adrian Perez from comment #3)

> There is only the “permissions.ini” for normal mode, but none of my
> webapplication-specific profile directories have such a file:
> 
>   %  find ~/.config/epiphany/ -name permissions.ini
>   /home/aperez/.config/epiphany/permissions.ini
>   %

Funny story. If I do the following before opening the Riot web application
then the “Enable desktop notifications” checkbox in the Riot settings
panel appears marked:

  % cat > ~/.config/epiphany/riotweb-*/permissions.ini <<EOF
  [org/gnome/epiphany/permissions/https/riot.im/0]
  notifications-permission='allow'
  EOF
  %

Clearly Epiphany is not saving the “permissions.ini” file in the
webapp-specific profile directory -- or not reading the global one
used in browser mode, I am not sure which one of those two would be
the intended behavior.

> JFTR, I have 5 web applications saved right now:

lol -- Clearly I should have written “3”!
Comment 5 Adrian Perez 2017-05-09 15:36:20 UTC
Adding some debug-prints in ephy_permissions_manager_set_permission()
shows nothing at all when toggling the “Enable desktop notifications”
setting. Somehow that function is not being reached. Which means that
the permission is never stored.
Comment 6 Michael Catanzaro 2017-05-09 17:04:44 UTC
(In reply to Adrian Perez from comment #5)
> Adding some debug-prints in ephy_permissions_manager_set_permission()
> shows nothing at all when toggling the “Enable desktop notifications”
> setting. Somehow that function is not being reached. Which means that
> the permission is never stored.

That function should be triggered by a JS call to Notification.requestPermission().

(In reply to Adrian Perez from comment #4)
> Funny story. If I do the following before opening the Riot web application
> then the “Enable desktop notifications” checkbox in the Riot settings
> panel appears marked:

Then it cannot ever work in Epiphany 3.22, which I'll be using until July when Fedora 26 is released (OK, it's scheduled for the last week of June, but you know it will slip). We did not start setting initial notification permissions until 3.24. This is a regression in Riot. Until a week or two ago, it used to prompt for notification permission on startup, and I never had any issues with notifications.
Comment 7 Michael Catanzaro 2017-05-09 17:07:40 UTC
I wrote this simple test to determine if this is an Epiphany bug:

<script>Notification.requestPermission();</script>

If that's loaded in a web app, and permissions get saved, then Epiphany is doing the right thing. When attempting to do so, Epiphany crashes. The crash is definitely an Epiphany bug. :) I'll look into it soon, as we have to fix that first to make progress here.
Comment 8 Michael Catanzaro 2017-05-09 19:33:27 UTC
Bug #782402
Comment 9 Michael Catanzaro 2017-05-09 19:42:50 UTC
(In reply to Michael Catanzaro from comment #7)
> I wrote this simple test to determine if this is an Epiphany bug:
> 
> <script>Notification.requestPermission();</script>
> 
> If that's loaded in a web app, and permissions get saved, then Epiphany is
> doing the right thing. When attempting to do so, Epiphany crashes. The crash
> is definitely an Epiphany bug. :) I'll look into it soon, as we have to fix
> that first to make progress here.

Nope, I'm dumb, I was accidentally testing with 3.22 I think... I forgot my 'jhbuild run' ;)

The problem is that no notification permission is ever being saved... Epiphany automatically grants notification permission in app mode, so it never gets saved and hence never gets set as an initial notification permission next time the browser starts.

(Still, a real shame that Riot stopped prompting for notification permission, because we cannot fix this in 3.22.)
Comment 10 Michael Catanzaro 2017-05-09 19:55:04 UTC
Created attachment 351478 [details] [review]
Fix initial notification permissions in web app mode

If we automatically grant notification permissions, then web apps that
test notification permissions without requesting them, like Riot, will
not work properly. It looks like I only tested my previous attempt to
fix this issue in normal browser mode.

The fix is just one call to ephy_permissions_manager_set_permissions().
That requires moving some code around.
Comment 11 Michael Catanzaro 2017-05-09 20:03:02 UTC
Attachment 351478 [details] pushed as bde8aee - Fix initial notification permissions in web app mode