Skip to content

Commit

Permalink
Closes mozilla-mobile#10200: Expose enterpriseRootsEnabled runtime se…
Browse files Browse the repository at this point in the history
…tting
  • Loading branch information
rocketsroger authored and mergify[bot] committed May 4, 2021
1 parent c95a60b commit 37e9d2a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,10 @@ class GeckoEngine(
override var forceUserScalableContent: Boolean
get() = runtime.settings.forceUserScalableEnabled
set(value) { runtime.settings.forceUserScalableEnabled = value }

override var enterpriseRootsEnabled: Boolean
get() = runtime.settings.enterpriseRootsEnabled
set(value) { runtime.settings.enterpriseRootsEnabled = value }
}.apply {
defaultSettings?.let {
this.javascriptEnabled = it.javascriptEnabled
Expand All @@ -643,6 +647,7 @@ class GeckoEngine(
this.forceUserScalableContent = it.forceUserScalableContent
this.clearColor = it.clearColor
this.loginAutofillEnabled = it.loginAutofillEnabled
this.enterpriseRootsEnabled = it.enterpriseRootsEnabled
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class GeckoEngineTest {
whenever(runtimeSettings.fontSizeFactor).thenReturn(1.0F)
whenever(runtimeSettings.forceUserScalableEnabled).thenReturn(false)
whenever(runtimeSettings.loginAutofillEnabled).thenReturn(false)
whenever(runtimeSettings.enterpriseRootsEnabled).thenReturn(false)
whenever(runtimeSettings.contentBlocking).thenReturn(contentBlockingSettings)
whenever(runtimeSettings.preferredColorScheme).thenReturn(GeckoRuntimeSettings.COLOR_SCHEME_SYSTEM)
whenever(runtime.settings).thenReturn(runtimeSettings)
Expand All @@ -219,6 +220,10 @@ class GeckoEngineTest {
engine.settings.loginAutofillEnabled = true
verify(runtimeSettings).loginAutofillEnabled = true

assertFalse(engine.settings.enterpriseRootsEnabled)
engine.settings.enterpriseRootsEnabled = true
verify(runtimeSettings).enterpriseRootsEnabled = true

assertTrue(engine.settings.webFontsEnabled)
engine.settings.webFontsEnabled = false
verify(runtimeSettings).webFontsEnabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ abstract class Settings {
* Setting to control the clear color while drawing.
*/
open var clearColor: Int? by UnsupportedSetting()

/**
* Setting to control whether enterprise root certs are enabled.
*/
open var enterpriseRootsEnabled: Boolean by UnsupportedSetting()
}

/**
Expand Down Expand Up @@ -214,7 +219,8 @@ data class DefaultSettings(
override var fontSizeFactor: Float? = null,
override var forceUserScalableContent: Boolean = false,
override var loginAutofillEnabled: Boolean = false,
override var clearColor: Int? = null
override var clearColor: Int? = null,
override var enterpriseRootsEnabled: Boolean = false
) : Settings()

class UnsupportedSetting<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class SettingsTest {
{ settings.loginAutofillEnabled },
{ settings.loginAutofillEnabled = false },
{ settings.clearColor },
{ settings.clearColor = Color.BLUE }
{ settings.clearColor = Color.BLUE },
{ settings.enterpriseRootsEnabled },
{ settings.enterpriseRootsEnabled = false }
)
}

Expand Down Expand Up @@ -125,6 +127,7 @@ class SettingsTest {
assertFalse(settings.forceUserScalableContent)
assertFalse(settings.loginAutofillEnabled)
assertNull(settings.clearColor)
assertFalse(settings.enterpriseRootsEnabled)

val interceptor: RequestInterceptor = mock()
val historyTrackingDelegate: HistoryTrackingDelegate = mock()
Expand Down Expand Up @@ -159,7 +162,8 @@ class SettingsTest {
fontSizeFactor = 2.0F,
forceUserScalableContent = true,
loginAutofillEnabled = true,
clearColor = Color.BLUE
clearColor = Color.BLUE,
enterpriseRootsEnabled = true
)

assertFalse(defaultSettings.domStorageEnabled)
Expand Down Expand Up @@ -192,5 +196,6 @@ class SettingsTest {
assertTrue(defaultSettings.forceUserScalableContent)
assertTrue(defaultSettings.loginAutofillEnabled)
assertEquals(Color.BLUE, defaultSettings.clearColor)
assertTrue(defaultSettings.enterpriseRootsEnabled)
}
}

0 comments on commit 37e9d2a

Please sign in to comment.