Closed Bug 1622730 Opened 4 years ago Closed 4 years ago

Support principals `file://` for the site permission setting

Categories

(Firefox :: Site Permissions, defect, P3)

defect

Tracking

()

RESOLVED FIXED
Firefox 76
Tracking Status
firefox-esr68 --- wontfix
firefox74 --- wontfix
firefox75 --- wontfix
firefox76 --- fixed

People

(Reporter: jya, Assigned: gaurijove, Mentored)

References

Details

Attachments

(1 file)

Was trying to debug bug 1528265.
I have a local page that will autoplay a flac page.

playback doesn't start and in the console you see:
NotAllowedError: The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Attempting to modify the autoplay permission by selecting "Permissions -> Autoplay : Allow Audio and Video" in the URL bar has no effect. Autoplay is always blocked for local file.

This is probably a toolkit bug, but wasn't sure.

Flags: needinfo?(alwu)

What file did you play? And what pref do you have for media.autoplay.*?
We won't block any media playing from the top level video document [1], and I can't reproduce this issue.

[1] https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/dom/media/AutoplayPolicy.cpp#109-114

Flags: needinfo?(alwu) → needinfo?(jyavenard)

(In reply to Alastor Wu [:alwu] from comment #1)

What file did you play? And what pref do you have for media.autoplay.*?
We won't block any media playing from the top level video document [1], and I can't reproduce this issue.

[1] https://searchfox.org/mozilla-central/rev/d69ec052bed8700af7a283e37b60b4af22734930/dom/media/AutoplayPolicy.cpp#109-114

A local web page, I got from there:
https://bug1487797.bmoattachments.org/attachment.cgi?id=9020902

And manually adjusted so that the flac file it played was local.

Settings are default, happening on both my local central build after a clobber (started with ./mach run) or firefox nightly.

Flags: needinfo?(jyavenard)

Would you mind to paste all the value of the pref media.autoplay.*, or simply paste the info from about:support?

The Flac file can be played successfully on both latest own-build-central and latest Nightly.

Flags: needinfo?(jyavenard)

After discussed with jya offline, so this issue seems to me a site permission issue.

He opened a local file which would automatically play a Flac file in that page and that autoplay would be blocked by our autoplay policy. That is expected, and from blocking autoplay pespective that is not difference between a page from local or from internet. The only case we would allow media to autoplay for local file is that you open an local media file directly.

Then he wanted to add this file file:///.... to the setting list, but it didn't help. So the problem is that our setting list doesn't support adding a local file URL.

Component: Audio/Video: Playback → Site Permissions
Flags: needinfo?(jyavenard)
Product: Core → Firefox

(In reply to Alastor Wu [:alwu] from comment #4)

Then he wanted to add this file file:///.... to the setting list, but it didn't help. So the problem is that our setting list doesn't support adding a local file URL.

Adding to that, selecting in the top bar to allow permanently autoplay to work has no effect.

I believe autoplay should be disabled for all local files.

I was able to reproduce this.

When updating the autoplay permission via the site identity doorhanger SitePermissions.setForPrincipal is called, which in this case is a no-op because we don't support file:// principals.

In order to support this use case we either have to allow setting permissions for file URIs or allow autoplay for all file URI sources. I'm in favor of the latter.
Another option would be to not support this particular use case and disable the autoplay permission UI for file URIs. That would mean leaving the autoplay permission locked to the default state for these URIs.

Priority: -- → P3

OK, thank you for suggestions. I would leave this bug as to supporting file:// principals and file another bug to handle autoplay policy for local files.

Summary: Autoplay policy can't be changed for file:// page → Support principals `file://` for the site permission setting

Ok, I've talked to :johannh about this. We could support permissions for file://. Since the permission manager already supports them, we would only have to update SitePermissions.jsm to support file URIs.

Mentor: pbz

Hi May I work on this?
This is quite new to me, may I know exactly what changes need to be made to the file?

(In reply to Jayati Shrivastava from comment #9)

Hi May I work on this?
This is quite new to me, may I know exactly what changes need to be made to the file?

The SitePermissions module uses isSupportedPrincipal to check whether it can manage permissions for a principal. You need to update the method to allow the file scheme.
To get some test coverage, you should also add SitePermissions tests where you get/set/test permissions with a principal with file URI.
Finally we should run this on try so we make sure to not break anything.

Assignee: nobody → gaurijove
Status: NEW → ASSIGNED
Pushed by rgurzau@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/410e77634909
Support `file://` principals for the site permission setting.r=pbz
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 76
Blocks: 1627210
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: