Bug 1614894 - Remove autoplayDefault. r=snorp,esawin,droeh

The pref does not make a lot more sense now that we check autoplay on every
session.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Agi Sferro 2020-02-20 19:07:58 +00:00
Родитель f8c4745805
Коммит 45e67578d0
8 изменённых файлов: 23 добавлений и 110 удалений

Просмотреть файл

@ -497,7 +497,6 @@ package org.mozilla.geckoview {
method public boolean getAboutConfigEnabled();
method @NonNull public String[] getArguments();
method public boolean getAutomaticFontSizeAdjustment();
method public int getAutoplayDefault();
method @Nullable public String getConfigFilePath();
method public boolean getConsoleOutputEnabled();
method @NonNull public ContentBlocking.Settings getContentBlocking();
@ -524,7 +523,6 @@ package org.mozilla.geckoview {
method public boolean getWebFontsEnabled();
method @NonNull public GeckoRuntimeSettings setAboutConfigEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setAutomaticFontSizeAdjustment(boolean);
method @NonNull public GeckoRuntimeSettings setAutoplayDefault(int);
method @NonNull public GeckoRuntimeSettings setConsoleOutputEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setDoubleTapZoomingEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setFontInflationEnabled(boolean);
@ -537,8 +535,6 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings setPreferredColorScheme(int);
method @NonNull public GeckoRuntimeSettings setRemoteDebuggingEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setWebFontsEnabled(boolean);
field public static final int AUTOPLAY_DEFAULT_ALLOWED = 0;
field public static final int AUTOPLAY_DEFAULT_BLOCKED = 1;
field public static final int COLOR_SCHEME_DARK = 1;
field public static final int COLOR_SCHEME_LIGHT = 0;
field public static final int COLOR_SCHEME_SYSTEM = -1;
@ -550,7 +546,6 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings.Builder aboutConfigEnabled(boolean);
method @NonNull public GeckoRuntimeSettings.Builder arguments(@NonNull String[]);
method @NonNull public GeckoRuntimeSettings.Builder automaticFontSizeAdjustment(boolean);
method @NonNull public GeckoRuntimeSettings.Builder autoplayDefault(int);
method @NonNull public GeckoRuntimeSettings.Builder configFilePath(@Nullable String);
method @NonNull public GeckoRuntimeSettings.Builder consoleOutput(boolean);
method @NonNull public GeckoRuntimeSettings.Builder contentBlocking(@NonNull ContentBlocking.Settings);

Просмотреть файл

@ -411,54 +411,4 @@ class MediaElementTest : BaseSessionTest() {
}
})
}
@Test fun autoplayBlocked() {
sessionRule.runtime.settings.autoplayDefault = GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED
val media = waitUntilVideoReadyNoPrefs(AUTOPLAY_PATH)
val promise = sessionRule.evaluatePromiseJS(mainSession,
"document.querySelector('video').play()")
var exceptionCaught = false
try {
val result = promise.value as Boolean
assertThat("Promise should not resolve", result, equalTo(false))
} catch (e: GeckoSessionTestRule.RejectedPromiseException) {
exceptionCaught = true;
}
assertThat("video.play() failed with exception", exceptionCaught, equalTo(true))
media.play()
/*
// Fails due to bug 1524092
waitForPlaybackStateChange(MediaElement.MEDIA_STATE_PLAY)
waitForPlaybackStateChange(MediaElement.MEDIA_STATE_PLAYING)
*/
}
@Test fun autoplayAllowed() {
sessionRule.runtime.settings.autoplayDefault = GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED
val media = waitUntilVideoReadyNoPrefs(VIDEO_WEBM_PATH)
val promise = sessionRule.evaluatePromiseJS(mainSession,
"document.querySelector('video').play()")
var exceptionCaught = false
try {
promise.value
} catch (e: GeckoSessionTestRule.RejectedPromiseException) {
exceptionCaught = true;
}
assertThat("video.play() did not fail", exceptionCaught, equalTo(false))
waitForPlaybackStateChange(MediaElement.MEDIA_STATE_PLAY)
waitForPlaybackStateChange(MediaElement.MEDIA_STATE_PLAYING)
media.pause()
media.play()
waitForPlaybackStateChange(MediaElement.MEDIA_STATE_PLAY)
waitForPlaybackStateChange(MediaElement.MEDIA_STATE_PLAYING)
// Restore default runtime settings
sessionRule.runtime.settings.autoplayDefault = GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED
}
}

Просмотреть файл

@ -266,7 +266,6 @@ class PermissionDelegateTest : BaseSessionTest() {
// The profile used in automation sets this to false, so we need to hack it back to true here.
sessionRule.setPrefsUntilTestEnd(mapOf(
"media.geckoview.autoplay.request" to true))
sessionRule.runtime.settings.autoplayDefault = GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED
mainSession.loadTestPath(AUTOPLAY_PATH)

Просмотреть файл

@ -245,8 +245,7 @@ public class TestRunnerActivity extends Activity {
.arguments(new String[] { "-purgecaches" })
.displayDpiOverride(160)
.displayDensityOverride(1.0f)
.remoteDebuggingEnabled(true)
.autoplayDefault(GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED);
.remoteDebuggingEnabled(true);
final Bundle extras = intent.getExtras();
if (extras != null) {

Просмотреть файл

@ -319,17 +319,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return this;
}
/**
* Sets video autoplay mode.
* May be either {@link GeckoRuntimeSettings#AUTOPLAY_DEFAULT_ALLOWED} or {@link GeckoRuntimeSettings#AUTOPLAY_DEFAULT_BLOCKED}
* @param autoplay Allows or blocks video autoplay.
* @return This Builder instance.
*/
public @NonNull Builder autoplayDefault(final @AutoplayDefault int autoplay) {
getSettings().mAutoplayDefault.set(autoplay);
return this;
}
/**
* Sets the preferred color scheme override for web content.
*
@ -450,8 +439,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
"browser.display.use_document_fonts", 1);
/* package */ final Pref<Boolean> mConsoleOutput = new Pref<Boolean>(
"geckoview.console.enabled", false);
/* package */ final Pref<Integer> mAutoplayDefault = new Pref<Integer>(
"media.autoplay.default", AUTOPLAY_DEFAULT_BLOCKED);
/* package */ final Pref<Integer> mFontSizeFactor = new Pref<>(
"font.size.systemFontScale", 100);
/* package */ final Pref<Integer> mFontInflationMinTwips = new Pref<>(
@ -836,41 +823,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return GeckoFontScaleListener.getInstance().getEnabled();
}
// Sync values with dom/media/nsIAutoplay.idl.
@Retention(RetentionPolicy.SOURCE)
@IntDef({ AUTOPLAY_DEFAULT_ALLOWED, AUTOPLAY_DEFAULT_BLOCKED })
/* package */ @interface AutoplayDefault {}
/**
* Autoplay video is allowed.
*/
public static final int AUTOPLAY_DEFAULT_ALLOWED = 0;
/**
* Autoplay video is blocked.
*/
public static final int AUTOPLAY_DEFAULT_BLOCKED = 1;
/**
* Sets video autoplay mode.
* May be either {@link GeckoRuntimeSettings#AUTOPLAY_DEFAULT_ALLOWED} or {@link GeckoRuntimeSettings#AUTOPLAY_DEFAULT_BLOCKED}
* @param autoplay Allows or blocks video autoplay.
* @return This GeckoRuntimeSettings instance.
*/
public @NonNull GeckoRuntimeSettings setAutoplayDefault(final @AutoplayDefault int autoplay) {
mAutoplayDefault.commit(autoplay);
return this;
}
/**
* Gets the current video autoplay mode.
* @return The current video autoplay mode. Will be either {@link GeckoRuntimeSettings#AUTOPLAY_DEFAULT_ALLOWED}
* or {@link GeckoRuntimeSettings#AUTOPLAY_DEFAULT_BLOCKED}
*/
public @AutoplayDefault int getAutoplayDefault() {
return mAutoplayDefault.get();
}
private static final int FONT_INFLATION_BASE_VALUE = 120;
/**

Просмотреть файл

@ -23,9 +23,15 @@ exclude: true
- Added [`DebuggerDelegate#onExtensionListUpdated`][75.2] to notify that a temporary
extension has been installed by the debugger.
([bug 1614295]({{bugzilla}}1614295))
- ⚠️ Removed [`GeckoRuntimeSettings.setAutoplayDefault`][75.3], use
[`GeckoSession.PermissionDelegate#PERMISSION_AUTOPLAY_AUDIBLE`][73.12] and
[`GeckoSession.PermissionDelegate#PERMISSION_AUTOPLAY_INAUDIBLE`][73.13] to
control autoplay.
([bug 1614894]({{bugzilla}}1614894))
[75.1]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#useMultiprocess-boolean-
[75.2]: {{javadoc_uri}}/WebExtensionController.DebuggerDelegate.html#onExtensionListUpdated--
[75.3]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#autoplayDefault-boolean-
## v74
- Added [`WebExtensionController.enable`][74.1] and [`disable`][74.2] to
@ -589,4 +595,4 @@ exclude: true
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
[65.25]: {{javadoc_uri}}/GeckoResult.html
[api-version]: e79b2ea5f93700f9e920b962286ec7b203c493b9
[api-version]: 898e8783e858824b7af7e4e9763bf5aaa54c0b0c

Просмотреть файл

@ -308,6 +308,7 @@ public class GeckoViewActivity
private GeckoView mGeckoView;
private boolean mFullAccessibilityTree;
private boolean mUseTrackingProtection;
private boolean mAllowAutoplay;
private boolean mUsePrivateBrowsing;
private boolean mEnableRemoteDebugging;
private boolean mKillProcessOnDestroy;
@ -317,7 +318,6 @@ public class GeckoViewActivity
private boolean mShowNotificationsRejected;
private ArrayList<String> mAcceptedPersistentStorage = new ArrayList<String>();
private ArrayList<String> mAcceptedAutoplay = new ArrayList<>();
private ToolbarLayout mToolbarView;
private String mCurrentUri;
@ -734,6 +734,7 @@ public class GeckoViewActivity
menu.findItem(R.id.desktop_mode).setChecked(mDesktopMode);
menu.findItem(R.id.action_remote_debugging).setChecked(mEnableRemoteDebugging);
menu.findItem(R.id.action_forward).setEnabled(mCanGoForward);
menu.findItem(R.id.allow_autoplay).setChecked(mAllowAutoplay);
return true;
}
@ -752,6 +753,10 @@ public class GeckoViewActivity
updateTrackingProtection(session);
session.reload();
break;
case R.id.allow_autoplay:
mAllowAutoplay = !mAllowAutoplay;
session.reload();
break;
case R.id.action_tpe:
sGeckoRuntime.getContentBlockingController().checkException(session).accept(value -> {
if (value.booleanValue()) {
@ -1314,8 +1319,13 @@ public class GeckoViewActivity
} else if (PERMISSION_XR == type) {
resId = R.string.request_xr;
} else if (PERMISSION_AUTOPLAY_AUDIBLE == type || PERMISSION_AUTOPLAY_INAUDIBLE == type) {
if (!mAllowAutoplay) {
Log.d(LOGTAG, "Rejecting autoplay request");
callback.reject();
} else {
Log.d(LOGTAG, "Granting autoplay request");
callback.grant();
}
return;
} else {
Log.w(LOGTAG, "Unknown permission: " + type);

Просмотреть файл

@ -2,6 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:title="@string/tracking_protection" android:id="@+id/action_tp" app:showAsAction="never"
android:checkable="true"/>
<item android:title="Allow Autoplay" android:id="@+id/allow_autoplay" app:showAsAction="never"
android:checkable="true" />
<item android:title="@string/tracking_protection_ex" android:id="@+id/action_tpe" app:showAsAction="never" />
<item android:title="@string/desktop_mode" android:id="@+id/desktop_mode" android:checkable="true"
app:showAsAction="never" />