Backed out changeset f05efdacedad (bug 1843926) for causing gv-junit failures on RuntimeSettings. CLOSED TREE

This commit is contained in:
Natalia Csoregi 2023-08-18 20:38:52 +03:00
parent ddca54d3a0
commit 2bb32121f6
8 changed files with 2 additions and 149 deletions

View File

@ -835,7 +835,6 @@ package org.mozilla.geckoview {
method public boolean getDoubleTapZoomingEnabled();
method public boolean getEnterpriseRootsEnabled();
method @AnyThread @Nullable public ExperimentDelegate getExperimentDelegate();
method @Nullable public Boolean getExtensionsProcessEnabled();
method public boolean getExtensionsWebAPIEnabled();
method @NonNull public Bundle getExtras();
method public boolean getFontInflationEnabled();
@ -862,7 +861,6 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings setConsoleOutputEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setDoubleTapZoomingEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setEnterpriseRootsEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setExtensionsProcessEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setExtensionsWebAPIEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setFontInflationEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setFontSizeFactor(float);
@ -902,7 +900,6 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings.Builder doubleTapZoomingEnabled(boolean);
method @NonNull public GeckoRuntimeSettings.Builder enterpriseRootsEnabled(boolean);
method @AnyThread @NonNull public GeckoRuntimeSettings.Builder experimentDelegate(@Nullable ExperimentDelegate);
method @NonNull public GeckoRuntimeSettings.Builder extensionsProcessEnabled(boolean);
method @NonNull public GeckoRuntimeSettings.Builder extensionsWebAPIEnabled(boolean);
method @NonNull public GeckoRuntimeSettings.Builder extras(@NonNull Bundle);
method @NonNull public GeckoRuntimeSettings.Builder fontInflation(boolean);

View File

@ -3091,39 +3091,4 @@ class WebExtensionTest : BaseSessionTest() {
equalTo(geckoPrefs[0] as Boolean),
)
}
@Test
fun testExtensionsProcessDisabledByDefault() {
val settings = GeckoRuntimeSettings.Builder()
.build()
assertThat(
"extensionsProcessEnabled setting default should be null",
settings.extensionsProcessEnabled,
equalTo(null),
)
val geckoPrefs = sessionRule.getPrefs(
"extensions.webextensions.remote",
)
assertThat(
"extensions.webextensions.remote pref default value should be false",
geckoPrefs[0] as Boolean,
equalTo(false),
)
}
@Test
fun testExtensionsProcessControlledFromSettings() {
val settings = GeckoRuntimeSettings.Builder()
.extensionsProcessEnabled(true)
.build()
assertThat(
"extensionsProcessEnabled setting should be set to true",
settings.extensionsProcessEnabled,
equalTo(true),
)
}
}

View File

@ -85,18 +85,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return this;
}
/**
* Set whether Extensions Process support should be enabled.
*
* @param flag A flag determining whether Extensions Process support should be enabled. Default
* is false.
* @return This Builder instance.
*/
public @NonNull Builder extensionsProcessEnabled(final boolean flag) {
getSettings().mExtensionsProcess.set(flag);
return this;
}
/**
* Set whether JavaScript support should be enabled.
*
@ -540,8 +528,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
/* package */ final Pref<Integer> mProcessCount = new Pref<>("dom.ipc.processCount", 2);
/* package */ final Pref<Boolean> mExtensionsWebAPIEnabled =
new Pref<>("extensions.webapi.enabled", false);
/* package */ final PrefWithoutDefault<Boolean> mExtensionsProcess =
new PrefWithoutDefault<Boolean>("extensions.webextensions.remote");
/* package */ int mPreferredColorScheme = COLOR_SCHEME_SYSTEM;
@ -671,26 +657,6 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return this;
}
/**
* Get whether Extensions Process support is enabled.
*
* @return Whether Extensions Process support is enabled.
*/
public @Nullable Boolean getExtensionsProcessEnabled() {
return mExtensionsProcess.get();
}
/**
* Set whether Extensions Process support should be enabled.
*
* @param flag A flag determining whether Extensions Process support should be enabled.
* @return This GeckoRuntimeSettings instance.
*/
public @NonNull GeckoRuntimeSettings setExtensionsProcessEnabled(final boolean flag) {
mExtensionsProcess.commit(flag);
return this;
}
/**
* Get whether remote debugging support is enabled.
*

View File

@ -109,10 +109,6 @@ public abstract class RuntimeSettings implements Parcelable {
return mIsSet;
}
public boolean hasDefault() {
return true;
}
public void reset() {
mValue = defaultValue;
mIsSet = false;
@ -132,48 +128,6 @@ public abstract class RuntimeSettings implements Parcelable {
}
}
/**
* Used to handle pref-based settings that should not have a default value, so that they will be
* controlled by GeckoView only when they are set.
*
* <p>When no value is set for a PrefWithoutDefault, its value on the GeckoView side is expected
* to be null, and the value set on the Gecko side to stay set to the either the prefs file
* included in the GeckoView build, or the user prefs file created by the xpcshell and mochitest
* test harness.
*/
/* package */ class PrefWithoutDefault<T> extends Pref<T> {
public PrefWithoutDefault(@NonNull final String name) {
super(name, null);
}
public boolean hasDefault() {
return false;
}
public @Nullable T get() {
if (!isSet()) {
return null;
}
return super.get();
}
public void commit() {
if (!isSet()) {
// Only add to the bundle prefs and
// propagate to Gecko when explicitly set.
return;
}
super.commit();
}
private void addToBundle(final GeckoBundle bundle) {
if (!isSet()) {
return;
}
super.addToBundle(bundle);
}
}
private RuntimeSettings mParent;
private final ArrayList<RuntimeSettings> mChildren;
private final ArrayList<Pref<?>> mPrefs;
@ -277,15 +231,7 @@ public abstract class RuntimeSettings implements Parcelable {
*/
/* package */ void commitResetPrefs() {
final ArrayList<String> names = new ArrayList<String>();
forAllPrefs(
pref -> {
// Do not reset prefs that don't have a default value
// and are not set.
if (!pref.hasDefault() && !pref.isSet()) {
return;
}
names.add(pref.name);
});
forAllPrefs(pref -> names.add(pref.name));
final GeckoBundle data = new GeckoBundle(1);
data.putStringArray("names", names);

View File

@ -24,7 +24,6 @@ exclude: true
- Changed [`GeckoSession.AccountSelectorPrompt`][118.8]: added the Provider to which the Account belongs ([bug 1847059]({{bugzilla}}1847059))
- Added [`getExperimentDelegate`][118.9] and [`setExperimentDelegate`][118.10] to the GeckoSession allow GeckoView to get and set the experiment delegate for the session. Default is to use the runtime delegate.
- ⚠️ Deprecated [`onGetNimbusFeature`][115.5] by 122, please use `ExperimentDelegate.onGetExperimentFeature` instead.
- Added [`GeckoRuntimeSettings.Builder.extensionsProcessEnabled`][118.11] for setting whether extensions process is enabled. ([bug 1843926]({{bugzilla}}1843926))
[118.1]: {{javadoc_uri}}/ExperimentDelegate.html
[118.2]: {{javadoc_uri}}/WebExtension.InstallException.ErrorCodes.html#ERROR_BLOCKLISTED
@ -36,7 +35,6 @@ exclude: true
[118.8]: {{javadoc_uri}}/GeckoSession.html#AccountSelectorPrompt
[118.9]: {{javadoc_uri}}/GeckoSession.html#getExperimentDelegate()
[118.10]: {{javadoc_uri}}/GeckoSession.html#setExperimentDelegate(org.mozilla.geckoview.ExperimentDelegate)
[118.11]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#extensionsProcessEnabled(Boolean)
## v116
- Added [`GeckoSession.didPrintPageContent`][116.1] to included extra print status for a standard print and new `GeckoPrintException.ERROR_NO_PRINT_DELEGATE`
@ -1417,4 +1415,4 @@ to allow adding gecko profiler markers.
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport(android.content.Context,android.os.Bundle,java.lang.String)
[65.25]: {{javadoc_uri}}/GeckoResult.html
[api-version]: 5743799f9da8509cfb6546e154f0e2d7989edc72
[api-version]: fd5137f14714faddcffb5d0ba63dd0cfa6721611

View File

@ -650,17 +650,6 @@ public class GeckoViewActivity extends AppCompatActivity
}
};
private final BooleanSetting mExtensionsProcessEnabled =
new BooleanSetting(
R.string.key_extensions_process_enabled,
R.bool.extensions_process_enabled_default,
/* reloadCurrentSession */ true) {
@Override
public void setValue(final GeckoRuntimeSettings settings, final Boolean value) {
settings.setExtensionsProcessEnabled(value);
}
};
private final BooleanSetting mTrackingProtection =
new BooleanSetting(R.string.key_tracking_protection, R.bool.tracking_protection_default) {
@Override
@ -842,7 +831,6 @@ public class GeckoViewActivity extends AppCompatActivity
.preferredColorScheme(mPreferredColorScheme.value())
.telemetryDelegate(new ExampleTelemetryDelegate())
.javaScriptEnabled(mJavascriptEnabled.value())
.extensionsProcessEnabled(mExtensionsProcessEnabled.value())
.aboutConfigEnabled(true);
sGeckoRuntime = GeckoRuntime.create(this, runtimeSettingsBuilder.build());

View File

@ -60,9 +60,6 @@
<string name="key_javascript_enabled">javascript_enabled</string>
<item type="bool" name="javascript_enabled_default">true</item>
<string name="key_extensions_process_enabled">extensions_process_enabled</string>
<item type="bool" name="extensions_process_enabled_default">false</item>
<string name="key_remote_debugging">remote_debugging</string>
<item type="bool" name="remote_debugging_default">true</item>

View File

@ -67,9 +67,5 @@
app:key="@string/key_javascript_enabled"
app:title="Javascript Enabled"
app:defaultValue="@bool/javascript_enabled_default"/>
<SwitchPreferenceCompat
app:key="@string/key_extensions_process_enabled"
app:title="Extensions Process Enabled"
app:defaultValue="@bool/extensions_process_enabled_default"/>
</PreferenceScreen>