From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../optional-permission-all-urls/manifest.json | 13 ++ .../geckoview/test/GeckoSessionTestRuleTest.kt | 3 - .../org/mozilla/geckoview/test/GeckoViewTest.kt | 3 +- .../org/mozilla/geckoview/test/ScreenshotTest.kt | 26 +++- .../org/mozilla/geckoview/test/TelemetryTest.kt | 131 --------------------- .../org/mozilla/geckoview/test/TranslationsTest.kt | 115 ++++++++++++++++-- .../org/mozilla/geckoview/test/WebExtensionTest.kt | 102 +++++++++++++++- .../geckoview/test/rule/GeckoSessionTestRule.java | 6 - .../geckoview/test/util/RuntimeCreator.java | 50 -------- 9 files changed, 237 insertions(+), 212 deletions(-) create mode 100644 mobile/android/geckoview/src/androidTest/assets/web_extensions/optional-permission-all-urls/manifest.json delete mode 100644 mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TelemetryTest.kt (limited to 'mobile/android/geckoview/src/androidTest') diff --git a/mobile/android/geckoview/src/androidTest/assets/web_extensions/optional-permission-all-urls/manifest.json b/mobile/android/geckoview/src/androidTest/assets/web_extensions/optional-permission-all-urls/manifest.json new file mode 100644 index 0000000000..c1c8fd9caa --- /dev/null +++ b/mobile/android/geckoview/src/androidTest/assets/web_extensions/optional-permission-all-urls/manifest.json @@ -0,0 +1,13 @@ +{ + "manifest_version": 3, + "name": "optional-permission-all-urls", + "browser_specific_settings": { + "gecko": { + "id": "optional-permission-all-urls@example.com" + } + }, + "version": "1.0", + "description": "Request optional extension origins for all urls.", + "optional_permissions": ["geolocation", "activeTab"], + "host_permissions": ["http://*/", "https://*/", "file://*/*"] +} diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt index 2ec305f913..06b946ba3d 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt @@ -2029,9 +2029,6 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @IgnoreCrash @Test fun contentCrashIgnored() { - // TODO: Bug 1673953 - assumeThat(sessionRule.env.isFission, equalTo(false)) - // TODO: bug 1710940 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoViewTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoViewTest.kt index 82af2c6475..c2ecb652a2 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoViewTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoViewTest.kt @@ -11,7 +11,6 @@ import android.view.View import android.view.ViewStructure import android.view.autofill.AutofillId import android.view.autofill.AutofillValue -import androidx.core.view.ViewCompat import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest @@ -79,7 +78,7 @@ class GeckoViewTest : BaseSessionTest() { activityRule.scenario.onActivity { assertThat( "View should be attached", - ViewCompat.isAttachedToWindow(it.view), + it.view.isAttachedToWindow(), equalTo(true), ) it.view.session!!.acquireDisplay() diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ScreenshotTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ScreenshotTest.kt index f3141c661c..301995c95c 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ScreenshotTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ScreenshotTest.kt @@ -12,7 +12,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import androidx.test.platform.app.InstrumentationRegistry import org.hamcrest.Matchers.* // ktlint-disable no-wildcard-imports -import org.junit.Assert +import org.junit.Assert.* import org.junit.Assume.assumeThat import org.junit.Test import org.junit.runner.RunWith @@ -25,6 +25,7 @@ import org.mozilla.geckoview.GeckoSession.ContentDelegate import org.mozilla.geckoview.GeckoSession.ProgressDelegate import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay +import org.mozilla.geckoview.test.util.UiThreadUtils import java.lang.IllegalStateException import kotlin.math.absoluteValue import kotlin.math.max @@ -142,6 +143,27 @@ class ScreenshotTest : BaseSessionTest() { } } + @WithDisplay(height = SCREEN_HEIGHT, width = SCREEN_WIDTH) + @Test + fun capturePixelsFailsWhenCompositorNotReady() { + sessionRule.display?.let { display -> + mainSession.close() + var exceptionListenerCalled = false + val result = display.capturePixels() + result.exceptionally { error: Throwable -> + assertTrue(error is IllegalStateException) + exceptionListenerCalled = true + result + }.accept { + fail("screenshot shouldn't complete successfully after session is closed") + } + UiThreadUtils.waitForCondition( + { exceptionListenerCalled }, + sessionRule.env.defaultTimeoutMillis, + ) + } ?: run { fail("no display found") } + } + // This tests tries to catch problems like Bug 1644561. @WithDisplay(height = SCREEN_HEIGHT, width = SCREEN_WIDTH) @Test @@ -430,7 +452,7 @@ class ScreenshotTest : BaseSessionTest() { .capture() .exceptionally( OnExceptionListener { error: Throwable -> - Assert.assertTrue(error is OutOfMemoryError) + assertTrue(error is OutOfMemoryError) fromException(error) }, ) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TelemetryTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TelemetryTest.kt deleted file mode 100644 index 42286c47a7..0000000000 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TelemetryTest.kt +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- 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.CoreMatchers.equalTo -import org.hamcrest.Matchers.* // ktlint-disable no-wildcard-imports -import org.junit.Test -import org.junit.runner.RunWith -import org.mozilla.geckoview.GeckoResult -import org.mozilla.geckoview.RuntimeTelemetry -import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled - -@RunWith(AndroidJUnit4::class) -@MediumTest -class TelemetryTest : BaseSessionTest() { - @Test - fun testOnTelemetryReceived() { - // Let's make sure we batch the telemetry calls. - sessionRule.setPrefsUntilTestEnd( - mapOf("toolkit.telemetry.geckoview.batchDurationMS" to 100000), - ) - - val expectedHistograms = listOf(401, 12, 1, 109, 2000) - val receivedHistograms = mutableListOf() - val histogram = GeckoResult() - val stringScalar = GeckoResult() - val booleanScalar = GeckoResult() - val longScalar = GeckoResult() - - sessionRule.addExternalDelegateUntilTestEnd( - RuntimeTelemetry.Delegate::class, - sessionRule::setTelemetryDelegate, - { sessionRule.setTelemetryDelegate(null) }, - object : RuntimeTelemetry.Delegate { - @AssertCalled - override fun onHistogram(metric: RuntimeTelemetry.Histogram) { - if (metric.name != "TELEMETRY_TEST_STREAMING") { - return - } - - assertThat( - "The histogram should not be categorical", - metric.isCategorical, - equalTo(false), - ) - - receivedHistograms.addAll(metric.value.toList()) - - if (receivedHistograms.size == expectedHistograms.size) { - histogram.complete(null) - } - } - - @AssertCalled - override fun onStringScalar(metric: RuntimeTelemetry.Metric) { - if (metric.name != "telemetry.test.string_kind") { - return - } - - assertThat( - "Metric value should match", - metric.value, - equalTo("test scalar"), - ) - - stringScalar.complete(null) - } - - @AssertCalled - override fun onBooleanScalar(metric: RuntimeTelemetry.Metric) { - if (metric.name != "telemetry.test.boolean_kind") { - return - } - - assertThat( - "Metric value should match", - metric.value, - equalTo(true), - ) - - booleanScalar.complete(null) - } - - @AssertCalled - override fun onLongScalar(metric: RuntimeTelemetry.Metric) { - if (metric.name != "telemetry.test.unsigned_int_kind") { - return - } - - assertThat( - "Metric value should match", - metric.value, - equalTo(1234L), - ) - - longScalar.complete(null) - } - }, - ) - - sessionRule.addHistogram("TELEMETRY_TEST_STREAMING", expectedHistograms[0]) - sessionRule.addHistogram("TELEMETRY_TEST_STREAMING", expectedHistograms[1]) - sessionRule.addHistogram("TELEMETRY_TEST_STREAMING", expectedHistograms[2]) - sessionRule.addHistogram("TELEMETRY_TEST_STREAMING", expectedHistograms[3]) - - sessionRule.setScalar("telemetry.test.boolean_kind", true) - sessionRule.setScalar("telemetry.test.unsigned_int_kind", 1234) - sessionRule.setScalar("telemetry.test.string_kind", "test scalar") - - // Forces flushing telemetry data at next histogram. - sessionRule.setPrefsUntilTestEnd( - mapOf("toolkit.telemetry.geckoview.batchDurationMS" to 0), - ) - sessionRule.addHistogram("TELEMETRY_TEST_STREAMING", expectedHistograms[4]) - - sessionRule.waitForResult(histogram) - sessionRule.waitForResult(stringScalar) - sessionRule.waitForResult(booleanScalar) - sessionRule.waitForResult(longScalar) - - assertThat( - "Metric values should match", - receivedHistograms, - equalTo(expectedHistograms), - ) - } -} diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TranslationsTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TranslationsTest.kt index a2c4eede62..966eba73b6 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TranslationsTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/TranslationsTest.kt @@ -6,6 +6,7 @@ package org.mozilla.geckoview.test import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest +import junit.framework.TestCase.assertFalse import junit.framework.TestCase.assertTrue import org.json.JSONObject import org.junit.After @@ -78,7 +79,7 @@ class TranslationsTest : BaseSessionTest() { handled.complete(null) } }) - var expectedTranslateEvent = JSONObject( + val expectedTranslateEvent = JSONObject( """ { "actor":{ @@ -89,6 +90,7 @@ class TranslationsTest : BaseSessionTest() { "docLangTag": "es" }, "requestedTranslationPair": null, + "hasVisibleChange": false, "error": null, "isEngineReady": false } @@ -153,28 +155,43 @@ class TranslationsTest : BaseSessionTest() { val translate = sessionRule.session.sessionTranslation!!.translate("en", "es", null) try { sessionRule.waitForResult(translate) - assertTrue("Translate should complete.", true) + // When testing from AS, this path is possible. + if (!sessionRule.env.isAutomation) { + assertTrue("Translate should complete.", true) + } } catch (e: Exception) { - assertTrue("Should not have an exception while translating.", false) + if (sessionRule.env.isAutomation) { + assertTrue("Expect an exception while translating in automation.", true) + } } // Options should work as expected - var options = TranslationOptions.Builder().downloadModel(true).build() + val options = TranslationOptions.Builder().downloadModel(true).build() val translateOptions = sessionRule.session.sessionTranslation!!.translate("en", "es", options) try { sessionRule.waitForResult(translateOptions) - assertTrue("Translate should complete with options.", true) + // When testing from AS, this path is possible. + if (!sessionRule.env.isAutomation) { + assertTrue("Translate should complete with options.", true) + } } catch (e: Exception) { - assertTrue("Should not have an exception while translating with options.", false) + if (sessionRule.env.isAutomation) { + assertTrue("Expect an exception while translating in automation.", true) + } } // Language tags should be fault tolerant of minor variations val longLanguageTag = sessionRule.session.sessionTranslation!!.translate("EN", "ES", null) try { sessionRule.waitForResult(longLanguageTag) - assertTrue("Translate should complete with longer language tag.", true) + // When testing from AS, this path is possible. + if (!sessionRule.env.isAutomation) { + assertTrue("Translate should complete with longer language tag.", true) + } } catch (e: Exception) { - assertTrue("Should not have an exception while translating with a longer language tag.", false) + if (sessionRule.env.isAutomation) { + assertTrue("Expect an exception while translating in automation.", true) + } } } @@ -244,9 +261,14 @@ class TranslationsTest : BaseSessionTest() { val translate = sessionRule.session.sessionTranslation!!.translate("es", "en", null) try { sessionRule.waitForResult(translate) - assertTrue("Should be able to translate.", true) + // When testing from AS, this path is possible. + if (!sessionRule.env.isAutomation) { + assertTrue("Should be able to translate.", true) + } } catch (e: Exception) { - assertTrue("Should not have an exception.", false) + if (sessionRule.env.isAutomation) { + assertTrue("Expect an exception while translating in automation.", true) + } } } @@ -443,10 +465,10 @@ class TranslationsTest : BaseSessionTest() { @Test fun testGetLanguageSettings() { // Note: Test endpoint is using a mocked response and doesn't reflect actual prefs - var languageSettings: Map = + val languageSettings: Map = sessionRule.waitForResult(TranslationsController.RuntimeTranslation.getLanguageSettings()) - var frLanguageSetting = sessionRule.waitForResult(TranslationsController.RuntimeTranslation.getLanguageSetting("fr")) + val frLanguageSetting = sessionRule.waitForResult(TranslationsController.RuntimeTranslation.getLanguageSetting("fr")) if (sessionRule.env.isAutomation) { assertTrue("FR was correctly set to ALWAYS via full query.", languageSettings["fr"] == ALWAYS) @@ -621,4 +643,73 @@ class TranslationsTest : BaseSessionTest() { } } } + + @Test + fun hasVisibleChangeTest() { + mainSession.loadTestPath(TRANSLATIONS_ES) + mainSession.waitForPageStop() + + val handled = GeckoResult() + var delegateCalled = 0 + sessionRule.delegateUntilTestEnd(object : Delegate { + @AssertCalled(count = 2) + override fun onTranslationStateChange( + session: GeckoSession, + translationState: TranslationState?, + ) { + delegateCalled++ + + if (delegateCalled == 1) { + assertFalse("Initially not visibly changed.", translationState!!.hasVisibleChange) + } + + if (delegateCalled == 2) { + assertTrue("After a translation, the DOM should be visibly changed.", translationState!!.hasVisibleChange) + handled.complete(null) + } + } + }) + val notTranslated = JSONObject( + """ + { + "actor":{ + "languageState":{ + "detectedLanguages": { + "userLangTag": "en", + "isDocLangTagSupported": true, + "docLangTag": "es" + }, + "requestedTranslationPair": null, + "hasVisibleChange": false, + "error": null, + "isEngineReady": false + } + } + } + """.trimIndent(), + ) + mainSession.triggerLanguageStateChange(notTranslated) + + val translated = JSONObject( + """ + { + "actor":{ + "languageState":{ + "detectedLanguages": { + "userLangTag": "en", + "isDocLangTagSupported": true, + "docLangTag": "es" + }, + "requestedTranslationPair": {"fromLanguage" : "es" , "toLanguage" : "en"}, + "hasVisibleChange": true, + "error": null, + "isEngineReady": true + } + } + } + """.trimIndent(), + ) + mainSession.triggerLanguageStateChange(translated) + sessionRule.waitForResult(handled) + } } diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt index fa5caa8693..413ca7e2f6 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt @@ -482,6 +482,101 @@ class WebExtensionTest : BaseSessionTest() { sessionRule.waitForResult(controller.uninstall(extension)) } + @Test + fun optionalOriginsNormalized() { + // For mv3 extensions the host_permissions are being granted automatically at install time + // but this test needs them to not be granted yet and so we explicitly opt-out in this test. + sessionRule.setPrefsUntilTestEnd( + mapOf( + "extensions.originControls.grantByDefault" to false, + ), + ) + + var extension = sessionRule.waitForResult( + controller.ensureBuiltIn( + "resource://android/assets/web_extensions/optional-permission-all-urls/", + "optional-permission-all-urls@example.com", + ), + ) + + assertEquals("optional-permission-all-urls@example.com", extension.id) + + var grantedOptionalOrigins = extension.metaData.grantedOptionalOrigins + assertArrayEquals( + "grantedOptionalPermissions must be initially empty", + arrayOf(), + grantedOptionalOrigins, + ) + + extension = sessionRule.waitForResult( + controller.addOptionalPermissions( + extension.id, + arrayOf(), + arrayOf("http://*/", "https://*/", "file://*/*"), + ), + ) + + grantedOptionalOrigins = extension.metaData.grantedOptionalOrigins + + assertArrayEquals( + "grantedOptionalPermissions must be [http://*/*, https://*/*, file://*/*]", + arrayOf("http://*/*", "https://*/*", "file://*/*"), + grantedOptionalOrigins, + ) + + sessionRule.waitForResult(controller.uninstall(extension)) + } + + @Test + fun onOptionalPermissionsChanged() { + var extension = sessionRule.waitForResult( + controller.ensureBuiltIn( + "resource://android/assets/web_extensions/optional-permission-request/", + "optional-permission-request@example.com", + ), + ) + + assertEquals("optional-permission-request@example.com", extension.id) + + var grantedOptionalPermissions = extension.metaData.grantedOptionalPermissions + var grantedOptionalOrigins = extension.metaData.grantedOptionalOrigins + + assertThat( + "grantedOptionalPermissions must be 0.", + grantedOptionalPermissions.size, + equalTo(0), + ) + assertThat("grantedOptionalOrigins must be 0.", grantedOptionalOrigins.size, equalTo(0)) + + sessionRule.delegateDuringNextWait(object : WebExtensionController.AddonManagerDelegate { + @AssertCalled(count = 1) + override fun onOptionalPermissionsChanged(updatedExtension: WebExtension) { + grantedOptionalPermissions = updatedExtension.metaData.grantedOptionalPermissions + grantedOptionalOrigins = updatedExtension.metaData.grantedOptionalOrigins + assertNull(updatedExtension) + assertArrayEquals( + "grantedOptionalPermissions must be [activeTab, geolocation].", + arrayOf("activeTab", "geolocation"), + grantedOptionalPermissions, + ) + assertArrayEquals( + "grantedOptionalPermissions must be [*://example.com/*].", + arrayOf("*://example.com/*"), + grantedOptionalOrigins, + ) + } + }) + + extension = sessionRule.waitForResult( + controller.addOptionalPermissions( + extension.id, + arrayOf("activeTab", "geolocation"), + arrayOf("*://example.com/*"), + ), + ) + sessionRule.waitForResult(controller.uninstall(extension)) + } + private fun assertBodyBorderEqualTo(expected: String) { val color = mainSession.evaluateJS("document.body.style.borderColor") assertThat( @@ -2763,7 +2858,7 @@ class WebExtensionTest : BaseSessionTest() { "extensions.install.requireBuiltInCerts" to false, "extensions.update.requireBuiltInCerts" to false, "extensions.getAddons.cache.enabled" to true, - "extensions.getAddons.cache.lastUpdate" to 0, + "extensions.getAddons.cache.lastUpdate" to 1, ), ) mainSession.loadUri("https://example.com") @@ -3721,11 +3816,6 @@ class WebExtensionTest : BaseSessionTest() { mainSession.evaluateJS("typeof navigator.mozAddonManager") as String, equalTo("object"), ) - assertThat( - "mozAddonManager.abuseReportPanelEnabled should be false", - mainSession.evaluateJS("navigator.mozAddonManager.abuseReportPanelEnabled") as Boolean, - equalTo(false), - ) // Install an add-on, then assert results got from `mozAddonManager.getAddonByID()`. var addonId = "" diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java index 727f403931..7c95233552 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/rule/GeckoSessionTestRule.java @@ -89,7 +89,6 @@ import org.mozilla.geckoview.GeckoSession.TextInputDelegate; import org.mozilla.geckoview.GeckoSessionSettings; import org.mozilla.geckoview.MediaSession; import org.mozilla.geckoview.OrientationController; -import org.mozilla.geckoview.RuntimeTelemetry; import org.mozilla.geckoview.SessionTextInput; import org.mozilla.geckoview.TranslationsController; import org.mozilla.geckoview.WebExtension; @@ -988,10 +987,6 @@ public class GeckoSessionTestRule implements TestRule { return RuntimeCreator.getRuntime(); } - public void setTelemetryDelegate(final RuntimeTelemetry.Delegate delegate) { - RuntimeCreator.setTelemetryDelegate(delegate); - } - /** Sets an experiment delegate on the runtime creator. */ public void setExperimentDelegate(final ExperimentDelegate delegate) { RuntimeCreator.setExperimentDelegate(delegate); @@ -1463,7 +1458,6 @@ public class GeckoSessionTestRule implements TestRule { mLastWaitStart = 0; mLastWaitEnd = 0; mTimeoutMillis = 0; - RuntimeCreator.setTelemetryDelegate(null); RuntimeCreator.setExperimentDelegate(null); } diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/util/RuntimeCreator.java b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/util/RuntimeCreator.java index 7eda360459..db18c06a9d 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/util/RuntimeCreator.java +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/util/RuntimeCreator.java @@ -18,7 +18,6 @@ import org.mozilla.geckoview.ExperimentDelegate; import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoRuntimeSettings; -import org.mozilla.geckoview.RuntimeTelemetry; import org.mozilla.geckoview.WebExtension; import org.mozilla.geckoview.test.TestCrashHandler; @@ -34,40 +33,6 @@ public class RuntimeCreator { public static AtomicInteger sTestSupport = new AtomicInteger(0); public static WebExtension sTestSupportExtension; - // The RuntimeTelemetry.Delegate can only be set when creating the RuntimeCreator, to - // let tests set their own Delegate we need to create a proxy here. - public static class RuntimeTelemetryDelegate implements RuntimeTelemetry.Delegate { - public RuntimeTelemetry.Delegate delegate = null; - - @Override - public void onHistogram(@NonNull final RuntimeTelemetry.Histogram metric) { - if (delegate != null) { - delegate.onHistogram(metric); - } - } - - @Override - public void onBooleanScalar(@NonNull final RuntimeTelemetry.Metric metric) { - if (delegate != null) { - delegate.onBooleanScalar(metric); - } - } - - @Override - public void onStringScalar(@NonNull final RuntimeTelemetry.Metric metric) { - if (delegate != null) { - delegate.onStringScalar(metric); - } - } - - @Override - public void onLongScalar(@NonNull final RuntimeTelemetry.Metric metric) { - if (delegate != null) { - delegate.onLongScalar(metric); - } - } - } - /** * The ExperimentDelegate can only be set when starting the RuntimeCreator, so for testing we are * setting up a proxy here @@ -110,9 +75,6 @@ public class RuntimeCreator { } } - public static final RuntimeTelemetryDelegate sRuntimeTelemetryProxy = - new RuntimeTelemetryDelegate(); - public static RuntimeExperimentDelegate sRuntimeExperimentDelegateProxy = new RuntimeExperimentDelegate(); private static WebExtension.Port sBackgroundPort; @@ -162,17 +124,6 @@ public class RuntimeCreator { }); } - /** - * Set the {@link RuntimeTelemetry.Delegate} instance for this test. Application code can only - * register this delegate when the {@link GeckoRuntime} is created, so we need to proxy it for - * test code. - * - * @param delegate the {@link RuntimeTelemetry.Delegate} for this test run. - */ - public static void setTelemetryDelegate(final RuntimeTelemetry.Delegate delegate) { - sRuntimeTelemetryProxy.delegate = delegate; - } - /** * Set the {@link ExperimentDelegate} instance for this test. Application code can only register * this delegate when the {@link GeckoRuntime} is created, so we need to proxy it for test code. @@ -216,7 +167,6 @@ public class RuntimeCreator { .remoteDebuggingEnabled(true) .consoleOutput(true) .crashHandler(TestCrashHandler.class) - .telemetryDelegate(sRuntimeTelemetryProxy) .experimentDelegate(sRuntimeExperimentDelegateProxy) .build(); -- cgit v1.2.3