forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1591533 - Add GV API to enable DNS-over-HTTPS capability on Fenix…
… r=geckoview-reviewers,calu,owlish This PR adds a couple GeckoView API to setup and specific DoH TRR mode and server URI, which enables the DNS-over-HTTPS capability on Firefox Fenix. Differential Revision: https://phabricator.services.mozilla.com/D121455
- Loading branch information
Showing
5 changed files
with
324 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...geckoview/src/androidTest/java/org/mozilla/geckoview/test/TrustedRecursiveResolverTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- | ||
* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
package org.mozilla.geckoview.test | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.filters.MediumTest | ||
import org.hamcrest.Matchers.* // ktlint-disable no-wildcard-imports | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mozilla.geckoview.GeckoRuntimeSettings | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
@MediumTest | ||
class TrustedRecursiveResolverTest : BaseSessionTest() { | ||
|
||
@Test fun trustedRecursiveResolverMode() { | ||
val settings = sessionRule.runtime.settings | ||
val trustedRecursiveResolverModePerf = "network.trr.mode" | ||
|
||
var prefValue = (sessionRule.getPrefs(trustedRecursiveResolverModePerf)[0] as Int) | ||
assertThat( | ||
"Initial TRR mode should be TRR_MODE_OFF (0)", | ||
prefValue, | ||
`is`(0), | ||
) | ||
|
||
settings.setTrustedRecursiveResolverMode(GeckoRuntimeSettings.TRR_MODE_FIRST) | ||
prefValue = (sessionRule.getPrefs(trustedRecursiveResolverModePerf)[0] as Int) | ||
|
||
assertThat( | ||
"Setting TRR mode to TRR_MODE_FIRST (2)", | ||
prefValue, | ||
`is`(2), | ||
) | ||
|
||
settings.setTrustedRecursiveResolverMode(GeckoRuntimeSettings.TRR_MODE_ONLY) | ||
prefValue = (sessionRule.getPrefs(trustedRecursiveResolverModePerf)[0] as Int) | ||
|
||
assertThat( | ||
"Setting TRR mode to TRR_MODE_ONLY (3)", | ||
prefValue, | ||
`is`(3), | ||
) | ||
|
||
settings.setTrustedRecursiveResolverMode(GeckoRuntimeSettings.TRR_MODE_DISABLED) | ||
prefValue = (sessionRule.getPrefs(trustedRecursiveResolverModePerf)[0] as Int) | ||
|
||
assertThat( | ||
"Setting TRR mode to TRR_MODE_DISABLED (5)", | ||
prefValue, | ||
`is`(5), | ||
) | ||
|
||
settings.setTrustedRecursiveResolverMode(GeckoRuntimeSettings.TRR_MODE_OFF) | ||
prefValue = (sessionRule.getPrefs(trustedRecursiveResolverModePerf)[0] as Int) | ||
|
||
assertThat( | ||
"Setting TRR mode to TRR_MODE_OFF (0)", | ||
prefValue, | ||
`is`(0), | ||
) | ||
} | ||
|
||
@Test fun trustedRecursiveResolverUrl() { | ||
val settings = sessionRule.runtime.settings | ||
val trustedRecursiveResolverUriPerf = "network.trr.uri" | ||
|
||
var prefValue = (sessionRule.getPrefs(trustedRecursiveResolverUriPerf)[0] as String) | ||
assertThat( | ||
"Initial TRR Uri should be empty", | ||
prefValue, | ||
`is`(""), | ||
) | ||
|
||
val exampleValue = "https://mozilla.cloudflare-dns.com/dns-query" | ||
settings.setTrustedRecursiveResolverUri(exampleValue) | ||
prefValue = (sessionRule.getPrefs(trustedRecursiveResolverUriPerf)[0] as String) | ||
assertThat( | ||
"Setting custom TRR Uri should work", | ||
prefValue, | ||
`is`(exampleValue), | ||
) | ||
} | ||
} |
Oops, something went wrong.