commit 81b772d7a0a051fe25109cf439fd805a9276b120
Author: Alex Catarineu <acat(a)torproject.org>
Date: Sun Oct 18 17:06:04 2020 +0200
Bug 40198: Expose privacy.spoof_english pref in GeckoView
---
mobile/android/geckoview/api.txt | 3 ++
.../mozilla/geckoview/GeckoRuntimeSettings.java | 33 ++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/mobile/android/geckoview/api.txt b/mobile/android/geckoview/api.txt
index afab7a2ea9f3..65529f18cf46 …
[View More]100644
--- a/mobile/android/geckoview/api.txt
+++ b/mobile/android/geckoview/api.txt
@@ -632,6 +632,7 @@ package org.mozilla.geckoview {
method public boolean getRemoteDebuggingEnabled();
method @Nullable public GeckoRuntime getRuntime();
method @Nullable public Rect getScreenSizeOverride();
+ method public boolean getSpoofEnglish();
method @Nullable public RuntimeTelemetry.Delegate getTelemetryDelegate();
method public int getTorSecurityLevel();
method public boolean getUseMaxScreenDepth();
@@ -651,6 +652,7 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings setLoginAutofillEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setPreferredColorScheme(int);
method @NonNull public GeckoRuntimeSettings setRemoteDebuggingEnabled(boolean);
+ method @NonNull public GeckoRuntimeSettings setSpoofEnglish(boolean);
method @NonNull public GeckoRuntimeSettings setTorSecurityLevel(int);
method @NonNull public GeckoRuntimeSettings setWebFontsEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setWebManifestEnabled(boolean);
@@ -686,6 +688,7 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings.Builder preferredColorScheme(int);
method @NonNull public GeckoRuntimeSettings.Builder remoteDebuggingEnabled(boolean);
method @NonNull public GeckoRuntimeSettings.Builder screenSizeOverride(int, int);
+ method @NonNull public GeckoRuntimeSettings.Builder spoofEnglish(boolean);
method @NonNull public GeckoRuntimeSettings.Builder telemetryDelegate(@NonNull RuntimeTelemetry.Delegate);
method @NonNull public GeckoRuntimeSettings.Builder torSecurityLevel(int);
method @NonNull public GeckoRuntimeSettings.Builder useMaxScreenDepth(boolean);
diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
index bb992733937e..e6493f8cddb3 100644
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
@@ -457,6 +457,17 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
getSettings().mTorSecurityLevel.set(level);
return this;
}
+
+ /**
+ * Sets whether we should spoof locale to English for webpages.
+ *
+ * @param flag True if we should spoof locale to English for webpages, false otherwise.
+ * @return This Builder instance.
+ */
+ public @NonNull Builder spoofEnglish(final boolean flag) {
+ getSettings().mSpoofEnglish.set(flag ? 2 : 1);
+ return this;
+ }
}
private GeckoRuntime mRuntime;
@@ -507,6 +518,8 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
"signon.autofillForms", true);
/* package */ final Pref<Integer> mTorSecurityLevel = new Pref<>(
"extensions.torbutton.security_slider", 4);
+ /* package */ final Pref<Integer> mSpoofEnglish = new Pref<>(
+ "privacy.spoof_english", 0);
/* package */ int mPreferredColorScheme = COLOR_SCHEME_SYSTEM;
@@ -1171,6 +1184,26 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return this;
}
+ /**
+ * Get whether we should spoof locale to English for webpages.
+ *
+ * @return Whether we should spoof locale to English for webpages.
+ */
+ public boolean getSpoofEnglish() {
+ return mSpoofEnglish.get() == 2;
+ }
+
+ /**
+ * Set whether we should spoof locale to English for webpages.
+ *
+ * @param flag A flag determining whether we should locale to English for webpages.
+ * @return This GeckoRuntimeSettings instance.
+ */
+ public @NonNull GeckoRuntimeSettings setSpoofEnglish(final boolean flag) {
+ mSpoofEnglish.commit(flag ? 2 : 1);
+ return this;
+ }
+
@Override // Parcelable
public void writeToParcel(final Parcel out, final int flags) {
super.writeToParcel(out, flags);
[View Less]
commit ea7eb55e79fd4bd7856efb043540fe62f0331fc8
Author: Alex Catarineu <acat(a)torproject.org>
Date: Wed Nov 4 21:05:43 2020 +0100
fixup! Bug 12620: TorBrowser regression tests
---
tbb-tests/browser_tor_bug2950.js | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tbb-tests/browser_tor_bug2950.js b/tbb-tests/browser_tor_bug2950.js
index 010cc6356202..add683022d8e 100644
--- a/tbb-tests/browser_tor_bug2950.js
+++ b/tbb-tests/browser_tor_bug2950.js
@@ …
[View More]-13,19 +13,19 @@ let Ci = Components.interfaces;
// ## utility functions
-// __uri(spec)__.
-// Creates an nsIURI instance from a spec
+// __principal(spec)__.
+// Creates a principal instance from a spec
// (string address such as "http://torproject.org").
-let uri = spec => Services.io.newURI(spec, null, null);
+let principal = spec => Services.scriptSecurityManager.createContentPrincipalFromOrigin(spec);
// __setPermission(spec, key, value)__.
// Sets the site permission of type key to value, for the site located at address spec.
-let setPermission = (spec, key, value) => SitePermissions.set(uri(spec), key, value);
+let setPermission = (spec, key, value) => SitePermissions.setForPrincipal(principal(spec), key, value);
// __getPermission(spec, key)__.
// Reads the site permission value for permission type key, for the site
// located at address spec.
-let getPermission = (spec, key) => SitePermissions.get(uri(spec), key);
+let getPermission = (spec, key) => SitePermissions.getForPrincipal(principal(spec), key);
// __profileDirPath__.
// The Firefox Profile directory. Expected location of various persistent files.
@@ -54,12 +54,12 @@ let originalValue = getPermission(SITE, KEY);
window.setTimeout(
function () {
// Set the permission to a new value.
- setPermission(SITE, KEY, (originalValue === 0) ? 1 : 0);
+ setPermission(SITE, KEY, SitePermissions.BLOCK);
// Now read back the permission value again.
let newReadValue = getPermission(SITE, KEY);
// Compare to confirm that the permission
// value was successfully changed.
- isnot(newReadValue, originalValue, "Set a value in permissions db (perhaps in memory).");;
+ Assert.notDeepEqual(originalValue, newReadValue, "Set a value in permissions db (perhaps in memory).");
// If file existed or now exists, get the current time stamp.
if (permissionsFile.exists()) {
newModifiedTime = permissionsFile.lastModifiedTime;
[View Less]