[components] Issue https://github.com/mozilla-mobile/android-components/issues/9746: (Merge day) browser-engine-gecko-beta (86) -> browser-engine-gecko (86)

This commit is contained in:
Sebastian Kaspari 2021-02-23 15:41:54 +01:00 committed by mergify[bot]
parent bbaa218292
commit 1596845e0a
10 changed files with 208 additions and 41 deletions

View File

@ -16,7 +16,7 @@ internal object GeckoVersions {
/**
* GeckoView Release Version.
*/
const val release_version = "85.0.20210208133944"
const val release_version = "86.0.20210222142601"
}
@Suppress("Unused", "MaxLineLength")

View File

@ -23,10 +23,10 @@ The following metrics are added to the ping:
| avif.aom_decode_error |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Image-decode Error from AOM decoder |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1670827#c9)|<ul><li>unit: error code</li></ul>|never | |
| avif.bit_depth |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Bits per pixel of AVIF image. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1670827#c9)|<ul><li>color_8</li><li>color_10</li><li>color_12</li><li>color_16</li><li>unknown</li></ul>|never | |
| avif.dav1d_decode_error |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Image-decode Error from dav1d decoder |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1670827#c9)|<ul><li>unit: error code</li></ul>|never | |
| avif.decode_result |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Decode result of AVIF image. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1670827#c9)|<ul><li>success</li><li>parse_error</li><li>no_primary_item</li><li>decode_error</li><li>size_overflow</li><li>out_of_memory</li><li>pipe_init_error</li><li>write_buffer_error</li></ul>|never | |
| avif.decode_result |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Decode result of AVIF image. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1670827#c9)|<ul><li>success</li><li>parse_error</li><li>no_primary_item</li><li>decode_error</li><li>size_overflow</li><li>out_of_memory</li><li>pipe_init_error</li><li>write_buffer_error</li><li>alpha_y_sz_mismatch</li><li>alpha_y_bpc_mismatch</li></ul>|never | |
| avif.decoder |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Decoder of AVIF image. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1670827#c9)|<ul><li>dav1d</li><li>aom</li></ul>|never | |
| avif.yuv_color_space |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |YUV color space of AVIF image. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1670827#c9)|<ul><li>bt601</li><li>bt709</li><li>bt2020</li><li>identity</li><li>unknown</li></ul>|never | |
| geckoview.build_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The Buildid of the Gecko engine, example: 20200205124310 |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1611240#c2)||2021-02-01 | |
| geckoview.build_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The Buildid of the Gecko engine, example: 20200205124310 |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1611240#c2)||never | |
| geckoview.content_process_lifetime |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The uptime of content processes in ms |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1625325#c2)||never | |
| geckoview.document_site_origins |[custom_distribution](https://mozilla.github.io/glean/book/user/metrics/custom_distribution.html) |When a document is loaded, report the number of [site origins](https://searchfox.org/ mozilla-central/rev/ 3300072e993ae05d50d5c63d815260367eaf9179/ caps/nsIPrincipal.idl#264) of the entire browser if it has been at least 5 minutes since last time we collect this data. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1589700#c5)||never | |
| geckoview.page_load_progress_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Time between page load progress starts (0) and completion (100). |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1580077#c10)||never | |
@ -34,16 +34,16 @@ The following metrics are added to the ping:
| geckoview.page_reload_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Time taken to reload a page. This includes all static contents, no dynamic content. Loading of about: pages is not counted. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1580077#c10)||never | |
| geckoview.per_document_site_origins |[custom_distribution](https://mozilla.github.io/glean/book/user/metrics/custom_distribution.html) |When a document is unloaded, report the highest number of [site origins](https://searchfox.org/ mozilla-central/rev/ 3300072e993ae05d50d5c63d815260367eaf9179/ caps/nsIPrincipal.idl#264) loaded simultaneously in that document. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1603185#c13)||never | |
| geckoview.startup_runtime |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time taken to initialize GeckoRuntime. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| geckoview.version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The version of the Gecko engine, example: 74.0a1 |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1611240#c2)||2021-02-01 | |
| gfx.adapter.primary.description |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Long form description of the Graphics adapter |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.adapter.primary.device_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter device identification |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.adapter.primary.driver_date |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter driver date |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.adapter.primary.driver_files |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |List of graphics adapter driver files |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.adapter.primary.driver_vendor |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter driver vendor identification |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.adapter.primary.driver_version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter driver version |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.adapter.primary.ram |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Graphics adapter dedicated memory |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)|<ul><li>unit: Megabytes</li></ul>|2021-02-01 | |
| gfx.adapter.primary.subsystem_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter subsystem identification |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.adapter.primary.vendor_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter vendor identification |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| geckoview.version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The version of the Gecko engine, example: 74.0a1 |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1611240#c2)||never | |
| gfx.adapter.primary.description |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Long form description of the Graphics adapter |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||never | |
| gfx.adapter.primary.device_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter device identification |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||never | |
| gfx.adapter.primary.driver_date |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter driver date |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2023-02-01 | |
| gfx.adapter.primary.driver_files |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |List of graphics adapter driver files |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2022-02-01 | |
| gfx.adapter.primary.driver_vendor |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter driver vendor identification |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||never | |
| gfx.adapter.primary.driver_version |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter driver version |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||never | |
| gfx.adapter.primary.ram |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Graphics adapter dedicated memory |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)|<ul><li>unit: Megabytes</li></ul>|never | |
| gfx.adapter.primary.subsystem_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter subsystem identification |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||never | |
| gfx.adapter.primary.vendor_id |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Graphics adapter vendor identification |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||never | |
| gfx.checkerboard.duration |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The duration of a checkerboard event. Checkerboarding is when painting has not kept up with asynchronous panning and zooming so the compositor has to display a "checkerboard pattern" (or in practice, the background color) rather than the actual page content. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.checkerboard.peak_pixel_count |[custom_distribution](https://mozilla.github.io/glean/book/user/metrics/custom_distribution.html) |The peak number of CSS pixels that checkerboarded during a checkerboard event. The minimum value of the largest histogram bucket is the size of a 4k display with maximum APZ zooming. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.checkerboard.potential_duration |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The total amount of time that we could reasonably be checkerboarding. This is the union of two possibly-intersecting sets of time periods: The first set is that in which checkerboarding was actually happening, since by definition it could potentially be happening. The second set is that in which the APZC is actively transforming content in the compositor, since it could potentially transform it so as to display checkerboarding to the user. Combined with other information, this allows us to meaningfully say how frequently users actually enncounters checkerboarding. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
@ -57,15 +57,16 @@ The following metrics are added to the ping:
| gfx.content.frame_time.without_upload |[custom_distribution](https://mozilla.github.io/glean/book/user/metrics/custom_distribution.html) |The time, in percentage of a vsync interval, spent from beginning a paint in the content process until that frame is presented in the compositor by webrender, excluding time spent uploading any content. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.content.full_paint_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Time spent in the full paint pipeline for content until it's ready for composition. For non-webrender this includes `paint_time`, plus rasterization if OMTP is enabled. For webrender, this includes `paint_time`, plus scene building time. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.content.paint_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Time spent in the main-thread paint pipeline for content. For non-webrender, this includes display list building, layer building, and when OMTP is disabled, rasterization. For webrender, this includes display list building, and webrender display list building. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.display.count |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Amount of displays connected to the device |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)|<ul><li>unit: Display count</li></ul>|2021-02-01 | |
| gfx.display.primary_height |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Height of the primary display, takes device rotation into account. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)|<ul><li>unit: Pixels</li></ul>|2021-02-01 | |
| gfx.display.primary_width |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Width of the primary display, takes device rotation into account. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)|<ul><li>unit: Pixels</li></ul>|2021-02-01 | |
| gfx.display.count |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Amount of displays connected to the device |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)|<ul><li>unit: Display count</li></ul>|never | |
| gfx.display.primary_height |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Height of the primary display, takes device rotation into account. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)|<ul><li>unit: Pixels</li></ul>|never | |
| gfx.display.primary_width |[quantity](https://mozilla.github.io/glean/book/user/metrics/quantity.html) |Width of the primary display, takes device rotation into account. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)|<ul><li>unit: Pixels</li></ul>|never | |
| gfx.feature.webrender |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Whether webrender is enabled or disabled, and why. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1687312#c5)||never | |
| gfx.scroll_present_latency |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Time between receiving a scroll event on the event loop and compositing its result onto the screen (ms). |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1604818#c4)||never | |
| gfx.status.compositor |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Name of the graphics compositor in use. Possible values are "opengl, d3d11, client, webrender or basic" |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.status.framebuild_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time taken to build a webrender frame. This involves calculating the visibility of primitives, requesting resources, and building the render passes which will be used to render the frame. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.status.headless |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Boolean indicated whether graphics is running in headless (no display) mode |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2021-02-01 | |
| gfx.status.sceneswap_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time taken to do a webrender scene swap. This is book-keeping that APZ must perform once webrender has built a new scene. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.status.compositor |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Name of the graphics compositor in use. Possible values are "opengl, d3d11, client, webrender or basic" |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2022-02-01 | |
| gfx.status.headless |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Boolean indicated whether graphics is running in headless (no display) mode |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1594145#c4)||2022-02-01 | |
| gfx.webrender.framebuild_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time taken to build a webrender frame. This involves calculating the visibility of primitives, requesting resources, and building the render passes which will be used to render the frame. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.webrender.scenebuild_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time taken to build a webrender scene. This occurs each time webrender receives a new display list. This additionally includes blob rasterization time. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| gfx.webrender.sceneswap_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time taken to do a webrender scene swap. This is book-keeping that APZ must perform once webrender has built a new scene. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1584109#c1)||never | |
| javascript.gc.compact_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time spent in the compact phase. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1636419#c17)||never | |
| javascript.gc.mark_roots_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time spent marking GC roots. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1636419#c17)||never | |
| javascript.gc.mark_time |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |The time spent in the mark phase. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1636419#c17)||never | |

View File

@ -9,6 +9,7 @@ import android.content.Context
import android.util.AttributeSet
import android.util.JsonReader
import androidx.annotation.VisibleForTesting
import mozilla.components.browser.engine.gecko.activity.GeckoActivityDelegate
import mozilla.components.browser.engine.gecko.ext.getAntiTrackingPolicy
import mozilla.components.browser.engine.gecko.ext.getEtpLevel
import mozilla.components.browser.engine.gecko.ext.getStrictSocialTrackingProtection
@ -31,6 +32,7 @@ import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy.
import mozilla.components.concept.engine.EngineSessionState
import mozilla.components.concept.engine.EngineView
import mozilla.components.concept.engine.Settings
import mozilla.components.concept.engine.activity.ActivityDelegate
import mozilla.components.concept.engine.content.blocking.TrackerLog
import mozilla.components.concept.engine.content.blocking.TrackingProtectionExceptionStorage
import mozilla.components.concept.engine.history.HistoryTrackingDelegate
@ -58,6 +60,7 @@ import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.GeckoWebExecutor
import org.mozilla.geckoview.WebExtensionController
import java.lang.ref.WeakReference
/**
* Gecko-based implementation of Engine interface.
@ -439,6 +442,34 @@ class GeckoEngine(
return requireNotNull(webPushHandler)
}
/**
* See [Engine.registerActivityDelegate].
*/
override fun registerActivityDelegate(
activityDelegate: ActivityDelegate
) {
/**
* Having the activity delegate on the engine can cause issues with resolving multiple requests to the delegate
* from different sessions. Ideally, this should be moved to the [EngineView].
*
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=1672195
*
* Attaching the delegate to the Gecko [Engine] implicitly assumes we have WebAuthn support. When a feature
* implements the ActivityDelegate today, we need to make sure that it has full support for WebAuthn. This
* needs to be fixed in GeckoView.
*
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=1671988
*/
runtime.activityDelegate = GeckoActivityDelegate(WeakReference(activityDelegate))
}
/**
* See [Engine.unregisterActivityDelegate].
*/
override fun unregisterActivityDelegate() {
runtime.activityDelegate = null
}
/**
* See [Engine.clearData].
*/

View File

@ -172,7 +172,7 @@ class GeckoEngineSession(
}
geckoSession.load(loader)
Fact(Component.BROWSER_ENGINE_GECKO, Action.IMPLEMENTATION_DETAIL, "GeckoSession.load").collect()
Fact(Component.BROWSER_ENGINE_GECKO_BETA, Action.IMPLEMENTATION_DETAIL, "GeckoSession.load").collect()
}
/**

View File

@ -169,10 +169,17 @@ class GeckoEngineView @JvmOverloads constructor(
override fun canScrollVerticallyDown() =
true // waiting for this issue https://bugzilla.mozilla.org/show_bug.cgi?id=1507569
@Suppress("MagicNumber")
override fun getInputResult(): EngineView.InputResult {
// Direct mapping of GeckoView's returned values.
// There should be a 1-1 relation. If not fail fast to allow for a quick fix.
return EngineView.InputResult.values().first { it.value == geckoView.inputResult }
// If not fail fast to allow for a quick fix.
val input = geckoView.inputResult
return when (input) {
0 -> EngineView.InputResult.INPUT_RESULT_UNHANDLED
1, 3 -> EngineView.InputResult.INPUT_RESULT_HANDLED
2 -> EngineView.InputResult.INPUT_RESULT_HANDLED_CONTENT
else -> throw IllegalArgumentException("Unexpected geckoView.inputResult: \"${geckoView.inputResult}\"")
}
}
override fun setVerticalClipping(clippingHeight: Int) {

View File

@ -0,0 +1,45 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package mozilla.components.browser.engine.gecko.activity
import android.app.PendingIntent
import android.content.Intent
import mozilla.components.concept.engine.activity.ActivityDelegate
import mozilla.components.support.base.log.logger.Logger
import org.mozilla.geckoview.GeckoResult
import org.mozilla.geckoview.GeckoRuntime
import java.lang.ref.WeakReference
/**
* A wrapper for the [ActivityDelegate] to communicate with the Gecko-based delegate.
*/
internal class GeckoActivityDelegate(
private val delegateRef: WeakReference<ActivityDelegate>
) : GeckoRuntime.ActivityDelegate {
private val logger = Logger(GeckoActivityDelegate::javaClass.name)
override fun onStartActivityForResult(intent: PendingIntent): GeckoResult<Intent> {
val result: GeckoResult<Intent> = GeckoResult()
val delegate = delegateRef.get()
if (delegate == null) {
logger.warn("No activity delegate attached. Cannot request FIDO auth.")
result.completeExceptionally(RuntimeException("Activity for result failed; no delegate attached."))
return result
}
delegate.startIntentSenderForResult(intent.intentSender) { data ->
if (data != null) {
result.complete(data)
} else {
result.completeExceptionally(RuntimeException("Activity for result failed."))
}
}
return result
}
}

View File

@ -241,7 +241,6 @@ class GeckoWebExtension(
* See [WebExtension.registerTabHandler].
*/
override fun registerTabHandler(tabHandler: TabHandler, defaultSettings: Settings?) {
val tabDelegate = object : GeckoNativeWebExtension.TabDelegate {
override fun onNewTab(
@ -253,7 +252,6 @@ class GeckoWebExtension(
defaultSettings = defaultSettings,
openGeckoSession = false
)
tabHandler.onNewTab(
this@GeckoWebExtension,
geckoEngineSession,

View File

@ -572,20 +572,6 @@ class GeckoEngineSessionTest {
verify(geckoSession, never()).restoreState(any())
}
@Test
fun `restoreState returns false for empty state`() {
val engineSession = GeckoEngineSession(mock(),
geckoSessionProvider = geckoSessionProvider)
val actualState: GeckoSession.SessionState = mock()
whenever(actualState.isEmpty()).thenReturn(true)
val state = GeckoEngineSessionState(actualState)
assertFalse(engineSession.restoreState(state))
verify(geckoSession, never()).restoreState(any())
}
@Test
fun progressDelegateIgnoresInitialLoadOfAboutBlank() {
val engineSession = GeckoEngineSession(mock(),

View File

@ -1725,7 +1725,7 @@ class GeckoEngineTest {
whenever(runtime.settings).thenReturn(mockGeckoSetting)
whenever(mockGeckoSetting.contentBlocking).thenReturn(mockGeckoContentBlockingSetting)
whenever(mockGeckoContentBlockingSetting.getEnhancedTrackingProtectionLevel()).thenReturn(
whenever(mockGeckoContentBlockingSetting.enhancedTrackingProtectionLevel).thenReturn(
ContentBlocking.EtpLevel.STRICT
)
whenever(runtime.contentBlockingController).thenReturn(mockContentBlockingController)
@ -1870,7 +1870,7 @@ class GeckoEngineTest {
whenever(runtime.settings).thenReturn(mockGeckoSetting)
whenever(mockGeckoSetting.contentBlocking).thenReturn(mockGeckoContentBlockingSetting)
whenever(mockGeckoContentBlockingSetting.getEnhancedTrackingProtectionLevel()).thenReturn(
whenever(mockGeckoContentBlockingSetting.enhancedTrackingProtectionLevel).thenReturn(
ContentBlocking.EtpLevel.STRICT
)
whenever(runtime.contentBlockingController).thenReturn(mockContentBlockingController)
@ -1926,6 +1926,30 @@ class GeckoEngineTest {
assert(handler1 == handler2)
}
@Test
fun `registerActivityDelegate sets delegate`() {
val runtime = mock<GeckoRuntime>()
val engine = GeckoEngine(context, runtime = runtime)
engine.registerActivityDelegate(mock())
verify(runtime).activityDelegate = any()
}
@Test
fun `unregisterActivityDelegate sets delegate to null`() {
val runtime = mock<GeckoRuntime>()
val engine = GeckoEngine(context, runtime = runtime)
engine.registerActivityDelegate(mock())
verify(runtime).activityDelegate = any()
engine.unregisterActivityDelegate()
verify(runtime).activityDelegate = null
}
private fun createSocialTrackersLogEntryList(): List<ContentBlockingController.LogEntry> {
val blockedLogEntry = object : ContentBlockingController.LogEntry() {}

View File

@ -0,0 +1,75 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package mozilla.components.browser.engine.gecko.activity
import android.app.PendingIntent
import android.content.Intent
import android.content.IntentSender
import androidx.test.ext.junit.runners.AndroidJUnit4
import mozilla.components.concept.engine.activity.ActivityDelegate
import mozilla.components.support.test.mock
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when`
import org.mozilla.geckoview.GeckoResult
import java.lang.ref.WeakReference
@RunWith(AndroidJUnit4::class)
class GeckoActivityDelegateTest {
lateinit var pendingIntent: PendingIntent
@Before
fun setup() {
pendingIntent = mock()
`when`(pendingIntent.intentSender).thenReturn(mock())
}
@Test
fun `onStartActivityForResult is completed successfully`() {
val delegate: ActivityDelegate = object : ActivityDelegate {
override fun startIntentSenderForResult(intent: IntentSender, onResult: (Intent?) -> Unit) {
onResult(mock())
}
}
val geckoActivityDelegate = GeckoActivityDelegate(WeakReference(delegate))
val result = geckoActivityDelegate.onStartActivityForResult(pendingIntent)
result.accept {
assertNotNull(it)
}
}
@Test
fun `onStartActivityForResult completes exceptionally on null response`() {
val delegate: ActivityDelegate = object : ActivityDelegate {
override fun startIntentSenderForResult(intent: IntentSender, onResult: (Intent?) -> Unit) {
onResult(null)
}
}
val geckoActivityDelegate = GeckoActivityDelegate(WeakReference(delegate))
val result = geckoActivityDelegate.onStartActivityForResult(pendingIntent)
result.exceptionally { throwable ->
assertEquals("Activity for result failed.", throwable.localizedMessage)
GeckoResult.fromValue(null)
}
}
@Test
fun `onStartActivityForResult completes exceptionally when there is no object attached to the weak reference`() {
val geckoActivityDelegate = GeckoActivityDelegate(WeakReference(null))
val result = geckoActivityDelegate.onStartActivityForResult(pendingIntent)
result.exceptionally { throwable ->
assertEquals("Activity for result failed; no delegate attached.", throwable.localizedMessage)
GeckoResult.fromValue(null)
}
}
}