Commit 5e23e29c authored by Jeff Boek's avatar Jeff Boek
Browse files

For #4761 - Adds setting to control `forceUserScalableEnabled`

parent abdcd18b
......@@ -333,6 +333,10 @@ class GeckoEngine(
runtime.settings.fontSizeFactor = it
}
}
override var forceUserScalableContent: Boolean
get() = runtime.settings.forceUserScalableEnabled
set(value) { runtime.settings.forceUserScalableEnabled = value }
}.apply {
defaultSettings?.let {
this.javascriptEnabled = it.javascriptEnabled
......@@ -349,6 +353,7 @@ class GeckoEngine(
this.suspendMediaWhenInactive = it.suspendMediaWhenInactive
this.fontInflationEnabled = it.fontInflationEnabled
this.fontSizeFactor = it.fontSizeFactor
this.forceUserScalableContent = it.forceUserScalableContent
}
}
}
......
......@@ -88,6 +88,7 @@ class GeckoEngineTest {
whenever(runtimeSettings.automaticFontSizeAdjustment).thenReturn(true)
whenever(runtimeSettings.fontInflationEnabled).thenReturn(true)
whenever(runtimeSettings.fontSizeFactor).thenReturn(1.0F)
whenever(runtimeSettings.forceUserScalableEnabled).thenReturn(false)
whenever(runtimeSettings.contentBlocking).thenReturn(contentBlockingSettings)
whenever(runtimeSettings.preferredColorScheme).thenReturn(GeckoRuntimeSettings.COLOR_SCHEME_SYSTEM)
whenever(runtimeSettings.autoplayDefault).thenReturn(GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED)
......@@ -118,6 +119,10 @@ class GeckoEngineTest {
engine.settings.fontSizeFactor = 2.0F
verify(runtimeSettings).fontSizeFactor = 2.0F
assertFalse(engine.settings.forceUserScalableContent)
engine.settings.forceUserScalableContent = true
verify(runtimeSettings).forceUserScalableEnabled = true
assertFalse(engine.settings.remoteDebuggingEnabled)
engine.settings.remoteDebuggingEnabled = true
verify(runtimeSettings).remoteDebuggingEnabled = true
......@@ -328,7 +333,8 @@ class GeckoEngineTest {
userAgentString = "test-ua",
preferredColorScheme = PreferredColorScheme.Light,
allowAutoplayMedia = false,
suspendMediaWhenInactive = true
suspendMediaWhenInactive = true,
forceUserScalableContent = false
), runtime)
verify(runtimeSettings).javaScriptEnabled = false
......@@ -338,6 +344,7 @@ class GeckoEngineTest {
verify(runtimeSettings).fontSizeFactor = 2.0F
verify(runtimeSettings).remoteDebuggingEnabled = true
verify(runtimeSettings).autoplayDefault = GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED
verify(runtimeSettings).forceUserScalableEnabled = false
val trackingStrictCategories = TrackingProtectionPolicy.strict().trackingCategories.sumBy { it.id }
val artificialCategory =
......
......@@ -169,6 +169,11 @@ abstract class Settings {
* Setting to control the font size factor. All font sizes will be multiplied by this factor.
*/
open var fontSizeFactor: Float? by UnsupportedSetting()
/**
* Setting to force the ability to scale the content
*/
open var forceUserScalableContent: Boolean by UnsupportedSetting()
}
/**
......@@ -202,7 +207,8 @@ data class DefaultSettings(
override var allowAutoplayMedia: Boolean = true,
override var suspendMediaWhenInactive: Boolean = false,
override var fontInflationEnabled: Boolean? = null,
override var fontSizeFactor: Float? = null
override var fontSizeFactor: Float? = null,
override var forceUserScalableContent: Boolean = false
) : Settings()
class UnsupportedSetting<T> {
......
......@@ -78,7 +78,9 @@ class SettingsTest {
{ settings.fontInflationEnabled },
{ settings.fontInflationEnabled = false },
{ settings.fontSizeFactor },
{ settings.fontSizeFactor = 1.0F }
{ settings.fontSizeFactor = 1.0F },
{ settings.forceUserScalableContent },
{ settings.forceUserScalableContent = true }
)
}
......@@ -118,6 +120,7 @@ class SettingsTest {
assertFalse(settings.suspendMediaWhenInactive)
assertNull(settings.fontInflationEnabled)
assertNull(settings.fontSizeFactor)
assertFalse(settings.forceUserScalableContent)
val interceptor: RequestInterceptor = mock()
val historyTrackingDelegate: HistoryTrackingDelegate = mock()
......@@ -150,7 +153,8 @@ class SettingsTest {
allowAutoplayMedia = false,
suspendMediaWhenInactive = true,
fontInflationEnabled = false,
fontSizeFactor = 2.0F)
fontSizeFactor = 2.0F,
forceUserScalableContent = true)
assertFalse(defaultSettings.domStorageEnabled)
assertFalse(defaultSettings.javascriptEnabled)
......@@ -180,5 +184,6 @@ class SettingsTest {
assertTrue(defaultSettings.suspendMediaWhenInactive)
assertFalse(defaultSettings.fontInflationEnabled!!)
assertEquals(2.0F, defaultSettings.fontSizeFactor)
assertTrue(defaultSettings.forceUserScalableContent)
}
}
\ No newline at end of file
......@@ -15,6 +15,12 @@ permalink: /changelog/
* **browser-menu**
* Adds the ability to create a BrowserMenuCategory, a menu item that defines a category for other menu items
* **concept-engine**
* Adds the setting `forceUserScalableContent`.
* **engine-gecko-nightly**
* Implements the setting `forceUserScalableContent`.
# 17.0.0
* [Commits](https://github.com/mozilla-mobile/android-components/compare/v16.0.0...v17.0.0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment