Commit Graph

38 Commits

Author SHA1 Message Date
alwu
d7a75adbdb Bug 1489278 - part1 : show doorhanger when create AudioContext r=padenot
In the ideal situation, sites should create AudioContext only when sites are going to produce
sound, so we would show doorhanger to ask users whether they want to allow autoplay.

We delay the AudioContext's state transition from `suspended` to `running` until
(1) user click 'Allow' button in doorhanger
(2) user interact with sites, and then AudioContext calls resume() again

Differential Revision: https://phabricator.services.mozilla.com/D5610

--HG--
extra : moz-landing-system : lando
2018-09-13 16:51:07 +00:00
alwu
bb11a649df Bug 1483703 - part1 : allow media without audio track to autoplay. r=cpearce
We would allow media without audio track to autoplay after it had loaded the metadata.

If media hasn't loaded metadata yet, we would treat it as audible media and then block it.

Differential Revision: https://phabricator.services.mozilla.com/D3670

--HG--
extra : moz-landing-system : lando
2018-08-22 23:31:58 +00:00
alwu
a23a30a650 Bug 1483703 - part1 : allow media without audio track to autoplay. r=cpearce
We would allow media without audio track to autoplay after it had loaded the metadata.

If media hasn't loaded metadata yet, we would treat it as audible media and then block it.

Differential Revision: https://phabricator.services.mozilla.com/D3670

--HG--
extra : moz-landing-system : lando
2018-08-21 20:58:26 +00:00
Dale Harvey
59e904f6cd Bug 1476555 - Show notification when autoplay blocked globally. r=cpearce,johannh
MozReview-Commit-ID: EI0GiaoBNqX

--HG--
extra : rebase_source : 0c6fb98047913fc50423532cc4c433c4627c5b06
2018-07-23 16:43:08 +01:00
alwu
7a58a577d5 Bug 1480738 - part1 : only allow top-level video document to autoplay. r=cpearce
Only allow top-level video document to autoplay in order to avoid autoplay from
video document which is in the iframe.

MozReview-Commit-ID: BbyjviK1BRK

--HG--
extra : rebase_source : f84421e27c6029dd3733f3c5a5d329b1755a0ee3
2018-08-03 11:28:30 -07:00
alwu
6d23d559af Bug 1480281 - part1 : add autoplay debug log module. r=cpearce
Add new log module which allow us to debug by using "MOZ_LOG=Autoplay:5".

MozReview-Commit-ID: 9CG5JyCw21G

--HG--
extra : rebase_source : c71c4bbed88b07a7803d93b661bfeac37cb94035
2018-08-01 17:30:59 -07:00
alwu
81ae6fd494 Bug 1466926 - part1 : always allow extension background script to autoplay. r=cpearce
In present web extension design (both Firefox and Chrome), background script can autoplay.
We don't want to break this design, so we would always allow it to autoplay.

MozReview-Commit-ID: 9BfWgll7PNx

--HG--
extra : rebase_source : 7996daa06c31a84a2aea9008daa9bddfcde98c74
2018-07-10 10:37:33 -07:00
alwu
b586e3d181 Bug 1477415 - part1 : allow video document autoplay. r=cpearce
Allow autoplay for video document when user is directly viewing a video/audio by visiting
its url.

MozReview-Commit-ID: GnSxx32h6hm

--HG--
extra : rebase_source : 0890f7f3e80711b35c65a6f32d7ce960de76d20e
2018-07-23 11:17:00 -07:00
Chris Pearce
ea566d079b Bug 1476456 - Add telemetry to report whether autoplay would be not allowed if autoplay was disabled. r=baku,francois
We'd like to add telemetry to help inform the decision as to how enabling
block autoplay will affect video playback in the wild.

Our data science team would also like some input to help them estimate the
rate at which our shield study would receive pings, and the telemetry
collected here will help them estimate that.

We'd like to collect the following, on a per session basis:
* Count of the number of top level content documents loaded, as denominator for
other stats collected here.
* Count of the number of top level content documents which contained (directly
or in a descendant document) playback of an audible media element.
* Count of the number of top level content documents which contained (directly
or in a descendant document) a muted media element that was paused by the
autoplay policy because it tried to unmute and it wasn't allowed to autoplay
audibly.
* Count of the total number of audible autoplay videos that would have not been
allowed to play if block autoplay was enabled. We'd either prompt for
permission on these videos, or block outright depending on user's settings.
* Count of the total number of audible autoplay videos that would have been
allowed to play if block autoplay was enabled.

MozReview-Commit-ID: vHWJPyqHjT

--HG--
extra : rebase_source : e1f22ec83fda8b65d78f1de9f02cf060d424019c
2018-07-18 15:34:04 +12:00
Tom Schuster
d385a93dfb Bug 1477477 - Add preference for autoplaying muted media. r=cpearce
--HG--
extra : rebase_source : 61589dbd15331d48527c3513e832c6d9e0117941
2018-07-22 15:21:48 +02:00
Chris Pearce
33cfb93398 Bug 1476853 - Don't block WebAudio autoplay by default. r=padenot
Pending figuring out how we want to block autoplay of WebAudio content, we
should just not block it by default for the initial release of block autoplay,
and follow up once we've figured out how to not break the web.

MozReview-Commit-ID: ClfdrHcugLs

--HG--
extra : rebase_source : 54f61b0765f1d0ed9c754c90da9c2809a7de8676
2018-07-16 16:08:49 +12:00
Dale Harvey
c9e5e7c554 Bug 1470082 - Change autoplay checkbox to combobox. r=cpearce,flod,johannh
MozReview-Commit-ID: E71TxvgfJlJ

--HG--
extra : rebase_source : 30ca63df77e48a44de4d3e90182440c3937ed32f
2018-06-29 14:14:33 +01:00
Chris Pearce
848dee9a6f Bug 1472580 - Ensure we always get a allow/cancel response to an autoplay media permission request. r=smaug
The front end code can't always guarantee to give us an allow/cancel response
to a permission request. In particular in these cases:
* if we close a tab while showing a doorhanger, or
* if we navigate a tab while showing a doorhanger, or
* if the permission prompt requested in a background tab and never shown.

Handling all of these cases is problematic; we don't get events for all of
these where it's easy and cheap to determine that we should cancel the
permission request.

Canceling the permission request is important in the autoplay-media permission
request case as there's objects waiting on the resolution of the permission
request, and they leak in ASan builds while running chrome tests if the Gecko
size of the permission request doesn't get a notification telling it to stop
waiting.

But we can however rely on the doorhanger code to drop its reference to the
nsIContentPermissionRequest object that we pass to it when the doorhanger goes
away. So we can cancel the permission request in our
nsIContentPermissionRequest's implementation's destructor in order to easily
catch all the above cases.

In order to do that, we need to split AutoplayRequest into two; one part being
the implementation of nsIContentPermissionRequest (AutoplayPermissionRequest),
and the other part being the code to own the PromiseHolder and manage the
permission request (AutoplayPermissionManager).

AutoplayPermissionRequest keeps a weak reference to AutoplayPermissionManager,
so that it can tell the AutoplayPermissionManager to reject the request promise
when it's destroyed.

This fixes the ASan leak for which I got backed out from earlier in this bug,
and also fixes the cases above.

MozReview-Commit-ID: KoVkgIqDleW

--HG--
rename : dom/html/AutoplayRequest.cpp => dom/html/AutoplayPermissionManager.cpp
rename : dom/html/AutoplayRequest.h => dom/html/AutoplayPermissionManager.h
extra : rebase_source : dbca520a93d8c416f6d64c2da027630181bb5910
2018-07-06 21:15:20 +12:00
Chris Pearce
ea95e39bc9 Bug 1463919 - Move ask autoplay permission check into AutoplayPolicy. r=jya
MozReview-Commit-ID: KJcVI6gtGXw

--HG--
extra : rebase_source : a2ccd2da32d77708fdeb6ea6361975a7759cb18d
extra : source : 9b1c40f3e61ab351707f2d320ce8f87951e4868e
2018-06-26 14:16:13 +12:00
Chris Pearce
bbbdebe6e1 Bug 1463919 - Add AutoplayRequest to encapsulate asking for autoplay permission. r=smaug
Add an implementation of nsIContentPermissionRequest to encapsulate requesting
permission from the user to autoplay audible media.

All documents in the tab request permission using the top level document's
origin, so the AutoplayRequest instance for a tab is stored on the top level
content window of the tab.

AutoplayRequest ensures that there's only a single prompt shown at once.

MozReview-Commit-ID: 2u3aLnEa21z

--HG--
extra : rebase_source : a3db3a1ef87a09442b47ae1b1034b4a0143289fb
extra : source : ae572bf618155a92b136fc5f12c1f8c9ab31f89c
2018-06-22 11:57:24 +12:00
Chris Pearce
63dbf9d6f7 Bug 1470346 - Gesture activate all documents in tab, even across origins, upon user interaction. r=smaug
Sometimes when video is playing, a preroll ad plays, and that may be in a cross
origin iframe. If autoplay media is disabled, we require a user gesture in a
document before playback in that document is permitted, and we require each
origin to be gesture activated separately. So in the cross origin preroll video
add case, then the user will have to click once to unblock playback for the
cross origin ad, and then once the preroll ad finishes, the user will have to
click again to activate playback of the same origin content video.

This is a bad user experience.

So we should instead make gesture activation propagate up the doc tree
irrespective of crossing origins.  This way, when the user clicks to activate,
all documents in that tab are also also effectively gesture activated, and so
can autoplay.

MozReview-Commit-ID: 1HZQ5zkubR

--HG--
extra : rebase_source : d6b75732548cb1d73b9f82dce60a5e6e97d1da14
2018-06-22 11:52:20 +12:00
Chris Pearce
e08b3c171c Bug 1464922 - Don't allow media without audio tracks to autoplay. r=bryce
I don't think we should allow media without audio tracks to autoplay because:
* It means play() before loaded metadata behaves differently than play()
called after loaded metadata.
* With the current impl we dispatch the "play" event and then the "pause"
event when we decide we should block, which may confuse some sites' controls.
* Delaying running the play() algorithm until we've loaded metadata would add
significant complexity, and may break sites.
* Chrome doesn't have this provision, meaning the complexity required to
support it will not result in much benefit to us.

MozReview-Commit-ID: FSVlDJAOisw

--HG--
extra : rebase_source : 93b1bcf8d8edbd6ca10ad918b40a87cd3cfbbf0b
2018-05-28 22:09:14 +12:00
Chris Pearce
1cf7b8ae13 Bug 1464930 - Move AutoplayPolicy Camera/Mic permission test to after gestures-needed pref check. r=bryce
We only should do the camera/mic permission or active capture test in
the case where document gesture activation is enabled.

MozReview-Commit-ID: 9xSe8FDn5tu

--HG--
extra : rebase_source : fb19fdcc7003d7ba04f5f1ab3a7d51ce63abc3db
extra : intermediate-source : 7de5bdbef79bacbee3284d49b77de36aceb0270e
extra : source : e72b9f4dcf418d4fcd2a0698f601d42eb9b0ecc0
2018-05-18 13:43:00 +12:00
Paul Adenot
adf8e4702d Bug 1413098 - Part 5 - Allow starting an AudioContext when gUM has been allowed. r=pehrsons
MozReview-Commit-ID: E0fcpIbLhYJ

--HG--
extra : rebase_source : 927d9d0ca04dd593d49efdffe70ce9f70ddce8bd
extra : source : 3c186b3bb90961748566b7c39af27beebb3ec855
2018-04-27 19:13:40 +02:00
Alastor Wu
f59daea779 Bug 1413098 - part1 : add policy to decide whether allow audio context to start. r=padenot
Audio context would be allowed to start if
(1) its document has been activated by user gesture
(2) it's a offline audio context, because it won't directly output sound to audio
    devices

In addition, all resume promises would be pending until audio context has been
allowed and user calls resume() again.

MozReview-Commit-ID: G6RV8dDM6vQ

--HG--
extra : rebase_source : bc1d2ad0594ad1f54c05ade06495918aaee14911
extra : source : 5031770d70fd643230cb4caf6a5106616adaf0fd
2017-12-13 14:05:35 -06:00
Chris Pearce
ed8a27f065 Bug 1457048 - Ensure origins with autoplay-media exact permission can autoplay. r=bryce,johannh
Sites which are whitelisted should be allowed to autoplay audible media.
So check whether a HTMLMediaElement's owner doc's principal has an exact
"autoplay-media" permission. This ensures whitelisted origins can autoplay,
but sub-origins of whitelisted origins need their own permission.

MozReview-Commit-ID: 2IO5KIyplEa

--HG--
extra : rebase_source : 4a974aba0533bfbd5e9bb4c4c11d77d17a81db6d
2018-04-30 17:40:50 +12:00
Dorel Luca
48f71154c5 Backed out 2 changesets (bug 1457048) for multiple failures. CLOSED TREE
Backed out changeset a5d71f8bf413 (bug 1457048)
Backed out changeset cd70fc188bc8 (bug 1457048)
2018-05-03 08:39:36 +03:00
Chris Pearce
d7eacf6ae5 Bug 1457048 - Ensure origins with autoplay-media exact permission can autoplay. r=bryce,johannh
Sites which are whitelisted should be allowed to autoplay audible media.
So check whether a HTMLMediaElement's owner doc's principal has an exact
"autoplay-media" permission. This ensures whitelisted origins can autoplay,
but sub-origins of whitelisted origins need their own permission.

MozReview-Commit-ID: 2IO5KIyplEa

--HG--
extra : rebase_source : 4d9afdec0caa4a82b53bedfd645f259a5c760e4d
2018-04-30 17:40:50 +12:00
Kyle Machulis
9e159ac69d Bug 1407040 - Change HTMLMediaElement XPCOM Enums to WebIDL Enums; r=bz
MozReview-Commit-ID: 55GnbaL2HKl

--HG--
extra : rebase_source : 5bb6c927443bf6adcfe594e69bd70c3b597b9ea4
2018-02-14 19:23:32 -08:00
Chris Pearce
e878eeef74 Bug 1182329 - Allow pages which have camera/microphone permission to autoplay audible media. r=jib
It seems reasonable to assume that when a page has been granted permission
to capture camera/microphone, the user intends it to play audible media.

MozReview-Commit-ID: 1RdsPK1vRPt

--HG--
extra : rebase_source : 688b68c29d73f117a2cc376233d664bc9cdb5d52
2018-02-08 16:05:46 +13:00
Alastor Wu
d7ce5bde2b Bug 1415478 - part2 : allow autoplay for non-audible media content and video without audio content. r=jwwang
Per UX spec, we would allow non-audible media (volume 0, muted, video without audio track)
to autoplay.

MozReview-Commit-ID: HKUyt5Jt4sH

--HG--
extra : rebase_source : 83e53a0035d72984494948f131a5d6e516baa577
2017-11-30 10:50:21 +08:00
Alastor Wu
e750ccbccf Bug 1415478 - part1 : turn on the pref on Nightly build. r=jwwang
MozReview-Commit-ID: AJva2ypm7BJ

--HG--
extra : rebase_source : 385bcf45aa417de1593adcc506a047caa5b14f35
2017-11-30 10:50:17 +08:00
Alastor Wu
258e1d56df Bug 1420488 - part1 : bless media if media has started playing before. r=jwwang
If the media has started playing before, bless it and it would always be allowed
to autoplay.

MozReview-Commit-ID: 4GqMARLXULU

--HG--
extra : rebase_source : 2fdb3937156147755f8e387b1d84311ae1d37ce4
2017-11-29 18:59:56 +08:00
Sebastian Hengst
c4e3d3a858 Backed out 2 changesets (bug 1420488) for eslint failures in toolkit/content/tests/browser/browser_autoplay_policy_play_twice.js. r=backout
Backed out changeset 92bd0fcb67d5 (bug 1420488)
Backed out changeset 0f211029517c (bug 1420488)
2017-11-29 17:31:28 +02:00
Alastor Wu
28c25979d7 Bug 1420488 - part1 : bless media if media has started playing before. r=jwwang
If the media has started playing before, bless it and it would always be allowed
to autoplay.

MozReview-Commit-ID: 28X4TmG25aJ

--HG--
extra : rebase_source : 3fd7cb16da9e7f925ad7020fb74c48537e08a996
2017-11-29 18:05:56 +08:00
Sebastian Hengst
706ac3aea0 Backed out 3 changesets (bug 1415478) for frequently asserting in own test test_autoplay_policy.html at MediaDecoderStateMachine.cpp:989. r=backout
Backed out changeset 6ba103fe1caf (bug 1415478)
Backed out changeset df6721a3584f (bug 1415478)
Backed out changeset 8a802839959b (bug 1415478)

--HG--
extra : rebase_source : be4296b1b36005195897de5544941b58895de661
2017-11-27 19:57:34 +02:00
Alastor Wu
a6a6078915 Bug 1415478 - part2 : allow autoplay for non-audible media content and video without audio content. r=jwwang
Per UX spec, we would allow non-audible media (volume 0, muted, video without audio track)
to autoplay.

MozReview-Commit-ID: HKUyt5Jt4sH

--HG--
extra : rebase_source : 97315d90fa46a16289135ac7490bd0dab651d682
2017-11-27 19:20:15 +08:00
Alastor Wu
10ef8e706f Bug 1415478 - part1 : turn on the pref on Nightly build. r=jwwang
MozReview-Commit-ID: AJva2ypm7BJ

--HG--
extra : rebase_source : 00b7a831a685dee21a13a786e93e9a3a388f4be3
2017-11-27 19:18:45 +08:00
Alastor Wu
62e836ef58 Bug 1420192 - when disable autoplay, allow script calls play() once user triggered load() or seek(). r=jwwang
This patch is mainly reverting the changing of bug1382574 part3, but not all the same.

Since youtube would call load() when user clicks to play, and then call play()
later. For the old pref (checking user-input-play), we should still allow the
following play() even it's not triggered via user input. It's also same for
seeking, Youtube would call play() after seeking completed.

In this patch, we would allow the script-calling once play() if user has called load()
or seek() before that.

MozReview-Commit-ID: 1UcxRCVfhnR

--HG--
extra : rebase_source : c72212ebf29ea624128a8190dab67e1197f1f198
2017-11-27 10:55:02 +08:00
dluca
85d0512151 Backed out 3 changesets (bug 1415478) for frequently asserting at dom/media/MediaDecoderStateMachine.cpp:1009 on a CLOSED TREE
Backed out changeset 447d895b350d (bug 1415478)
Backed out changeset d855c032c823 (bug 1415478)
Backed out changeset 6739012c4bdf (bug 1415478)
2017-11-24 18:50:53 +02:00
Alastor Wu
35a99cd8d3 Bug 1415478 - part2 : allow autoplay for non-audible media content and video without audio content. r=jwwang
Per UX spec, we would allow non-audible media (volume 0, muted, video without audio track)
to autoplay.

MozReview-Commit-ID: HKUyt5Jt4sH

--HG--
extra : rebase_source : fa8d1bfd2fb667e974dbe499d7f8215273d4fa10
2017-11-24 11:14:26 +08:00
Alastor Wu
d5341011c9 Bug 1415478 - part1 : turn on the pref on Nightly build. r=jwwang
MozReview-Commit-ID: AJva2ypm7BJ

--HG--
extra : rebase_source : 5bfd8d46aa8b928bd7b6a6e12c31f0c7e2c4ebee
2017-11-24 11:12:23 +08:00
Alastor Wu
5acb978a09 Bug 1382574 - part1 : create new class AutoplayPolicy to handle autoplay logic. r=jwwang
AutoplayPolicy is used to manage autoplay logic for all kinds of media,
including MediaElement, Web Audio and Web Speech.

MozReview-Commit-ID: R1TxMkarIw

--HG--
extra : rebase_source : 8c608a1d12c8e205391a91f22e1532bc4f2c8f16
2017-11-22 00:33:16 +08:00