Commit c17bfd3b authored by Sebastian Kaspari's avatar Sebastian Kaspari Committed by mergify[bot]
Browse files

Issue #10114: (Merge day) browser-engine-gecko-nightly (89) -> browser-engine-gecko-beta (89)

parent 52aa1180
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ internal object GeckoVersions {
    /**
     * GeckoView Beta Version.
     */
    const val beta_version = "88.0.20210410185959"
    const val beta_version = "89.0.20210419195043"

    /**
     * GeckoView Release Version.
+1 −26
Original line number Diff line number Diff line
@@ -90,13 +90,6 @@ class GeckoEngineView @JvmOverloads constructor(
    @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
    internal var currentSelection: BasicSelectionActionDelegate? = null

    /**
     * Cache of the last valid input result we got from GeckoView.
     */
    @Suppress("Deprecation")
    @VisibleForTesting
    internal var lastInputResult: EngineView.InputResult = EngineView.InputResult.INPUT_RESULT_UNHANDLED

    override var selectionActionDelegate: SelectionActionDelegate? = null

    init {
@@ -175,25 +168,7 @@ class GeckoEngineView @JvmOverloads constructor(
    override fun canScrollVerticallyDown() =
        true // waiting for this issue https://bugzilla.mozilla.org/show_bug.cgi?id=1507569

    @Suppress("MagicNumber", "Deprecation")
    override fun getInputResult(): EngineView.InputResult {
        // Direct mapping of GeckoView's returned values.
        // If not fail fast to allow for a quick fix.
        val input = geckoView.inputResult
        lastInputResult = when (input) {
            0 -> EngineView.InputResult.INPUT_RESULT_UNHANDLED
            1 -> EngineView.InputResult.INPUT_RESULT_HANDLED
            2 -> EngineView.InputResult.INPUT_RESULT_HANDLED_CONTENT
            3 -> {
                // Drop this result and return the previous.
                // See https://bugzilla.mozilla.org/show_bug.cgi?id=1687430 for details
                lastInputResult
            }
            else -> throw IllegalArgumentException("Unexpected geckoView.inputResult: \"$input\"")
        }

        return lastInputResult
    }
    override fun getInputResultDetail() = geckoView.inputResultDetail

    override fun setVerticalClipping(clippingHeight: Int) {
        geckoView.setVerticalClipping(clippingHeight)
+10 −11
Original line number Diff line number Diff line
@@ -10,10 +10,8 @@ import androidx.annotation.VisibleForTesting
import androidx.core.view.NestedScrollingChild
import androidx.core.view.NestedScrollingChildHelper
import androidx.core.view.ViewCompat
import mozilla.components.concept.engine.EngineView
import mozilla.components.concept.engine.InputResultDetail
import org.mozilla.geckoview.GeckoView
import org.mozilla.geckoview.PanZoomController.INPUT_RESULT_HANDLED
import org.mozilla.geckoview.PanZoomController.INPUT_RESULT_UNHANDLED

/**
 * geckoView that supports nested scrolls (for using in a CoordinatorLayout).
@@ -44,11 +42,11 @@ open class NestedGeckoView(context: Context) : GeckoView(context), NestedScrolli
    internal var childHelper: NestedScrollingChildHelper = NestedScrollingChildHelper(this)

    /**
     * Integer indicating how user's MotionEvent was handled.
     * How user's MotionEvent will be handled.
     *
     * There must be a 1-1 relation between this values and [EngineView.InputResult]'s.
     * @see InputResultDetail
     */
    internal var inputResult: Int = INPUT_RESULT_UNHANDLED
    internal var inputResultDetail = InputResultDetail.newInstance(true)

    init {
        isNestedScrollingEnabled = true
@@ -62,7 +60,8 @@ open class NestedGeckoView(context: Context) : GeckoView(context), NestedScrolli

        when (action) {
            MotionEvent.ACTION_MOVE -> {
                val allowScroll = !shouldPinOnScreen() && inputResult == INPUT_RESULT_HANDLED
                val allowScroll = !shouldPinOnScreen() && inputResultDetail.isTouchHandledByBrowser()

                var deltaY = lastY - eventY

                if (allowScroll && dispatchNestedPreScroll(0, deltaY, scrollConsumed, scrollOffset)) {
@@ -99,7 +98,7 @@ open class NestedGeckoView(context: Context) : GeckoView(context), NestedScrolli
                stopNestedScroll()
                // Reset handled status so that parents of this View would not get the old value
                // when querying it for a newly started touch event.
                inputResult = INPUT_RESULT_UNHANDLED
                inputResultDetail = InputResultDetail.newInstance(true)
            }
        }

@@ -121,9 +120,9 @@ open class NestedGeckoView(context: Context) : GeckoView(context), NestedScrolli
    internal fun updateInputResult(event: MotionEvent) {
        super.onTouchEventForDetailResult(event)
            .accept {
                // This should never be null.
                // Prefer to crash and investigate after rather than not knowing about problems with this.
                inputResult = it?.handledResult()!!
                inputResultDetail = inputResultDetail.copy(
                    it?.handledResult(), it?.scrollableDirections(), it?.overscrollDirections()
                )
                startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL)
            }
    }
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ import org.mozilla.geckoview.GeckoResult
 * them to [storageDelegate]. This allows us to avoid duplicating [LoginStorageDelegate] code
 * between different versions of GeckoView, by duplicating this wrapper instead.
 */
@Suppress("Deprecation")
// This will be addressed in https://github.com/mozilla-mobile/android-components/issues/10093
class GeckoLoginDelegateWrapper(private val storageDelegate: LoginStorageDelegate) :
    Autocomplete.LoginStorageDelegate {

+4 −48
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ import android.view.View
import androidx.test.ext.junit.runners.AndroidJUnit4
import mozilla.components.browser.engine.gecko.GeckoEngineView.Companion.DARK_COVER
import mozilla.components.browser.engine.gecko.selection.GeckoSelectionActionDelegate
import mozilla.components.concept.engine.EngineView
import mozilla.components.concept.engine.mediaquery.PreferredColorScheme
import mozilla.components.concept.engine.selection.SelectionActionDelegate
import mozilla.components.support.test.argumentCaptor
@@ -22,6 +21,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
@@ -278,55 +278,11 @@ class GeckoEngineViewTest {
        assertFalse(engineView.canClearSelection())
    }

    @Suppress("Deprecation")
    @Test
    fun `currentInputResult should default to EngineView#InputResult#INPUT_RESULT_UNHANDLED`() {
    fun `GIVEN a GeckoView WHEN EngineView returns the InputResultDetail THEN the value from the GeckoView is used`() {
        val engineView = GeckoEngineView(context)
        val geckoview = engineView.geckoView

        assertEquals(EngineView.InputResult.INPUT_RESULT_UNHANDLED, engineView.lastInputResult)
    }

    @Suppress("Deprecation")
    @Test
    fun `getInputResult should do a 1-1 mapping of the values received from GeckoView and cache the result`() {
        val engineView = GeckoEngineView(context)
        engineView.geckoView = mock()

        whenever(engineView.geckoView.inputResult).thenReturn(0)
        assertEquals(EngineView.InputResult.INPUT_RESULT_UNHANDLED, engineView.getInputResult())
        assertEquals(EngineView.InputResult.INPUT_RESULT_UNHANDLED, engineView.lastInputResult)

        whenever(engineView.geckoView.inputResult).thenReturn(1)
        assertEquals(EngineView.InputResult.INPUT_RESULT_HANDLED, engineView.getInputResult())
        assertEquals(EngineView.InputResult.INPUT_RESULT_HANDLED, engineView.lastInputResult)

        whenever(engineView.geckoView.inputResult).thenReturn(2)
        assertEquals(EngineView.InputResult.INPUT_RESULT_HANDLED_CONTENT, engineView.getInputResult())
        assertEquals(EngineView.InputResult.INPUT_RESULT_HANDLED_CONTENT, engineView.lastInputResult)
    }

    @Suppress("Deprecation")
    @Test
    fun `INPUT_RESULD_IGNORED should be ignored`() {
        val engineView = GeckoEngineView(context)
        engineView.geckoView = mock()

        whenever(engineView.geckoView.inputResult).thenReturn(1)
        assertEquals(EngineView.InputResult.INPUT_RESULT_HANDLED, engineView.getInputResult())
        assertEquals(EngineView.InputResult.INPUT_RESULT_HANDLED, engineView.lastInputResult)

        whenever(engineView.geckoView.inputResult).thenReturn(3)
        assertEquals(EngineView.InputResult.INPUT_RESULT_HANDLED, engineView.getInputResult())
        assertEquals(EngineView.InputResult.INPUT_RESULT_HANDLED, engineView.lastInputResult)
    }

    @Suppress("Deprecation")
    @Test(expected = IllegalArgumentException::class)
    fun `Values other than 0, 1, 2, 3 received as input results from GeckoView should throw`() {
        val engineView = GeckoEngineView(context)
        engineView.geckoView = mock()

        whenever(engineView.geckoView.inputResult).thenReturn(4)
        engineView.getInputResult()
        assertSame(geckoview.inputResultDetail, engineView.getInputResultDetail())
    }
}
Loading