Closed Bug 1648134 Opened 4 years ago Closed 4 years ago

Permission Manager does not save changes when scope is changed.

Categories

(Core :: Permission Manager, defect)

defect

Tracking

()

VERIFIED FIXED
mozilla80
Tracking Status
firefox80 --- verified

People

(Reporter: julianwels, Assigned: baku)

References

Details

Attachments

(1 file)

Switching between the EXPIRE_SESSION- and EXPIRE_NEVER-scopes does not persist over Browser restarts.

How to reproduce:

  • Open Firefox and go to any website
  • Open the Browser Toolbox Console and add a permission with session scope: Services.perms.addFromPrincipal(gBrowser.contentPrincipal, "geo", Services.perms.ALLOW_ACTION, Services.perms.EXPIRE_SESSION)
  • Now change the permission scope from session to never: Services.perms.addFromPrincipal(gBrowser.contentPrincipal, "geo", Services.perms.ALLOW_ACTION, Services.perms.EXPIRE_NEVER)
  • Restart the browser and open the website

Expected behavior: Geo permission is still there.
Actual behavior: Geo permission did not persist.

This also works the other way around, where first EXPIRE_NEVER is set, then EXPIRE_SESSION. After the restart, the permission is still there.

Examining permissions.sqlite in the profile directory shows, that the file does not change when the permission-scope does.

Might be related to bug 593213

The bug is here:
https://searchfox.org/mozilla-central/rev/cfaa250d14e344834932de4c2eed0061701654da/extensions/permissions/PermissionManager.cpp#1810

Here we call UpdateDB() passing op=eOperationChanging because we are updating the permission. But the previous permission has never been stored to disk because it was a session-only one. The correct operation here should be eOperationAdding.

In the other direction, the first permission was stored on disk. The second one is session-only and it doesn't need to be written to disk. But the old permission must be removed, but we don't do it.

Assignee: nobody → amarchesini
Status: NEW → ASSIGNED
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/34d09061d827
Permission Manager does not save changes when scope is changed., r=mayhemer
Regressions: 1649196

Backed out for failures on test_permmanager_remove_add_update.js

backout: https://hg.mozilla.org/integration/autoland/rev/f35f77c3f495fccfd6a2ccff00abe74781fbc1ea

push: https://treeherder.mozilla.org/#/jobs?repo=autoland&group_state=expanded&revision=34d09061d8272ede6d1bf4ce0cb91b223eabd5d2&selectedTaskRun=YctlmLulRm-gb1yPx-qPmA.2 . It failed later on on tier 1 on a subsequent push https://treeherder.mozilla.org/#/jobs?repo=autoland&selectedTaskRun=RLaPUhc3RpGWXWP1Q5ikcQ.0&revision=a9e55b42982f7c3d8ab5639fcf278e71575b4ea2&searchStr=linux%2C18.04%2Cx64%2Casan%2Copt%2Cxpcshell%2Ctests%2Ctest-linux1804-64-asan%2Fopt-xpcshell-e10s-2%2Cx%28x2%29

failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=307888121&repo=autoland&lineNumber=1605

[task 2020-06-29T17:17:40.982Z] 17:17:40 INFO - TEST-START | extensions/permissions/test/unit/test_permmanager_remove_add_update.js
[task 2020-06-29T17:17:41.171Z] 17:17:41 WARNING - TEST-UNEXPECTED-FAIL | extensions/permissions/test/unit/test_permmanager_remove_add_update.js | xpcshell return code: 0
[task 2020-06-29T17:17:41.171Z] 17:17:41 INFO - TEST-INFO took 187ms
[task 2020-06-29T17:17:41.171Z] 17:17:41 INFO - >>>>>>>
[task 2020-06-29T17:17:41.171Z] 17:17:41 INFO - (xpcshell/head.js) | test MAIN run_test pending (1)
[task 2020-06-29T17:17:41.171Z] 17:17:41 INFO - (xpcshell/head.js) | test run_next_test 0 pending (2)
[task 2020-06-29T17:17:41.171Z] 17:17:41 INFO - (xpcshell/head.js) | test MAIN run_test finished (2)
[task 2020-06-29T17:17:41.175Z] 17:17:41 INFO - running event loop
[task 2020-06-29T17:17:41.175Z] 17:17:41 INFO - "CONSOLE_MESSAGE: (info) No chrome package registered for chrome://branding/locale/brand.properties"
[task 2020-06-29T17:17:41.175Z] 17:17:41 INFO - extensions/permissions/test/unit/test_permmanager_remove_add_update.js | Starting test
[task 2020-06-29T17:17:41.175Z] 17:17:41 INFO - (xpcshell/head.js) | test test pending (2)
[task 2020-06-29T17:17:41.175Z] 17:17:41 INFO - TEST-PASS | extensions/permissions/test/unit/test_permmanager_remove_add_update.js | test - [test : 25] true == true

Flags: needinfo?(amarchesini)
Flags: needinfo?(amarchesini)
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b3c38ba32f0b
Permission Manager does not save changes when scope is changed., r=mayhemer
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
Flags: qe-verify+

Reproduced the initial issue using old Nightly from 2020-06-24. Verified that this issue is fixed now using Firefox 80.0 RC across platforms (Windows 10 64bit, macOS 10.15.6 and Ubuntu 18.04).

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: