Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Issue #10114: (Merge day) browser-engine-gecko-beta (88) -> browser-e…
Browse files Browse the repository at this point in the history
…ngine-gecko (88)
  • Loading branch information
pocmo authored and mergify[bot] committed Apr 20, 2021
1 parent 72d7370 commit 52aa118
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 22 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Gecko.kt
Expand Up @@ -16,7 +16,7 @@ internal object GeckoVersions {
/**
* GeckoView Release Version.
*/
const val release_version = "87.0.20210318103112"
const val release_version = "88.0.20210415204500"
}

@Suppress("Unused", "MaxLineLength")
Expand Down
Expand Up @@ -299,9 +299,9 @@ class GeckoEngine(
override fun onInstallPrompt(ext: org.mozilla.geckoview.WebExtension): GeckoResult<AllowOrDeny>? {
val extension = GeckoWebExtension(ext, runtime)
return if (webExtensionDelegate.onInstallPermissionRequest(extension)) {
GeckoResult.ALLOW
GeckoResult.allow()
} else {
GeckoResult.DENY
GeckoResult.deny()
}
}

Expand Down
Expand Up @@ -266,7 +266,7 @@ class GeckoEngineSession(
* [TrackingProtectionPolicy.TrackingCategory.SCRIPTS_AND_SUB_RESOURCES].
*/
val shouldBlockContent =
policy.contains(TrackingProtectionPolicy.TrackingCategory.SCRIPTS_AND_SUB_RESOURCES)
policy.contains(TrackingProtectionPolicy.TrackingCategory.SCRIPTS_AND_SUB_RESOURCES)

val enabledInBrowsingMode = if (privateMode) {
policy.useForPrivateSessions
Expand Down
Expand Up @@ -119,11 +119,11 @@ open class NestedGeckoView(context: Context) : GeckoView(context), NestedScrolli

@VisibleForTesting
internal fun updateInputResult(event: MotionEvent) {
super.onTouchEventForResult(event)
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!!
inputResult = it?.handledResult()!!
startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL)
}
}
Expand Down
Expand Up @@ -58,8 +58,13 @@ open class GeckoSelectionActionDelegate(
}

override fun performAction(id: String, item: MenuItem): Boolean {
val selectedText = mSelection?.text ?: return super.performAction(id, item)
/* Temporary, removed once https://bugzilla.mozilla.org/show_bug.cgi?id=1694983 is fixed */
try {
val selectedText = mSelection?.text ?: return super.performAction(id, item)

return customDelegate.performAction(id, selectedText) || super.performAction(id, item)
return customDelegate.performAction(id, selectedText) || super.performAction(id, item)
} catch (e: SecurityException) {
return false
}
}
}
Expand Up @@ -302,9 +302,9 @@ class GeckoWebExtension(
tabDetails.active == true,
tabDetails.url)
) {
GeckoResult.ALLOW
GeckoResult.allow()
} else {
GeckoResult.DENY
GeckoResult.deny()
}
}

Expand All @@ -315,12 +315,12 @@ class GeckoWebExtension(

return if (ext != null) {
if (tabHandler.onCloseTab(this@GeckoWebExtension, session)) {
GeckoResult.ALLOW
GeckoResult.allow()
} else {
GeckoResult.DENY
GeckoResult.deny()
}
} else {
GeckoResult.DENY
GeckoResult.deny()
}
}
}
Expand Down
Expand Up @@ -1127,7 +1127,7 @@ class GeckoEngineSessionTest {
}

@Test
fun `WHEN updating tracking protection with a recommended policy THEN etpEnabled should be enabled`() {
fun `WHEN updateing tracking protection with a recommended policy THEN etpEnabled should be enabled`() {
whenever(runtime.settings).thenReturn(mock())
whenever(runtime.settings.contentBlocking).thenReturn(mock())

Expand All @@ -1149,7 +1149,7 @@ class GeckoEngineSessionTest {
}

@Test
fun `WHEN updating tracking protection with a none policy THEN etpEnabled should be enabled`() {
fun `WHEN calling updateTrackingProtection with a none policy THEN etpEnabled should be disabled`() {
whenever(runtime.settings).thenReturn(mock())
whenever(runtime.settings.contentBlocking).thenReturn(mock())

Expand All @@ -1171,7 +1171,7 @@ class GeckoEngineSessionTest {
}

@Test
fun `WHEN update content blocking with a policy SCRIPTS_AND_SUB_RESOURCES useForPrivateSessions being in privateMode THEN useTrackingProtection should be true`() {
fun `WHEN updating the contentBlocking with a policy SCRIPTS_AND_SUB_RESOURCES useForPrivateSessions being in privateMode THEN useTrackingProtection should be true`() {
val geckoSetting = mock<GeckoSessionSettings>()
val geckoSession = mock<GeckoSession>()

Expand Down Expand Up @@ -1249,7 +1249,7 @@ class GeckoEngineSessionTest {
}

@Test
fun `changes to enableTrackingProtection will be notified to all new observers`() {
fun `changes to updateTrackingProtection will be notified to all new observers`() {
whenever(runtime.settings).thenReturn(mock())
whenever(runtime.settings.contentBlocking).thenReturn(mock())
val session = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
Expand Down
Expand Up @@ -862,15 +862,15 @@ class GeckoEngineTest {
val geckoDelegateCaptor = argumentCaptor<WebExtensionController.PromptDelegate>()
verify(webExtensionController).promptDelegate = geckoDelegateCaptor.capture()

assertEquals(GeckoResult.DENY, geckoDelegateCaptor.value.onInstallPrompt(extension))
assertEquals(GeckoResult.deny(), geckoDelegateCaptor.value.onInstallPrompt(extension))
val extensionCaptor = argumentCaptor<WebExtension>()
verify(webExtensionsDelegate).onInstallPermissionRequest(extensionCaptor.capture())
val capturedExtension =
extensionCaptor.value as mozilla.components.browser.engine.gecko.webextension.GeckoWebExtension
assertEquals(extension, capturedExtension.nativeExtension)

whenever(webExtensionsDelegate.onInstallPermissionRequest(any())).thenReturn(true)
assertEquals(GeckoResult.ALLOW, geckoDelegateCaptor.value.onInstallPrompt(extension))
assertEquals(GeckoResult.allow(), geckoDelegateCaptor.value.onInstallPrompt(extension))
}

@Test
Expand Down Expand Up @@ -912,7 +912,7 @@ class GeckoEngineTest {
assertEquals(updatedExtension, updated.nativeExtension)

onPermissionsGrantedCaptor.value.invoke(true)
assertEquals(GeckoResult.ALLOW, result)
assertEquals(GeckoResult.allow(), result)
}

@Test
Expand Down Expand Up @@ -953,7 +953,7 @@ class GeckoEngineTest {
assertEquals(updatedExtension, updated.nativeExtension)

onPermissionsGrantedCaptor.value.invoke(true)
assertEquals(GeckoResult.ALLOW, result)
assertEquals(GeckoResult.allow(), result)
}

@Test
Expand Down
Expand Up @@ -7,9 +7,11 @@ package mozilla.components.browser.engine.gecko.selection
import android.app.Activity
import android.app.Application
import android.app.Service
import android.view.MenuItem
import mozilla.components.concept.engine.selection.SelectionActionDelegate
import mozilla.components.support.test.mock
import org.junit.Assert
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test
Expand Down Expand Up @@ -55,6 +57,25 @@ class GeckoSelectionActionDelegateTest {
Assert.assertTrue(actualActions.contains(it))
}
}

@Test
fun `WHEN perform action triggers a security exception THEN false is returned`() {
val customActions = arrayOf("1", "2", "3")
val customDelegate = object : SelectionActionDelegate {
override fun getAllActions(): Array<String> = customActions
override fun isActionAvailable(id: String, selectedText: String): Boolean = false
override fun getActionTitle(id: String): CharSequence? = ""
override fun performAction(id: String, selectedText: String): Boolean {
throw SecurityException("test")
}
override fun sortedActions(actions: Array<String>): Array<String> {
return actions
}
}

val geckoDelegate = TestGeckoSelectionActionDelegate(mock(), customDelegate)
assertFalse(geckoDelegate.performAction("test", mock()))
}
}

/**
Expand All @@ -65,4 +86,7 @@ class TestGeckoSelectionActionDelegate(
customDelegate: SelectionActionDelegate
) : GeckoSelectionActionDelegate(activity, customDelegate) {
public override fun getAllActions() = super.getAllActions()
public override fun performAction(id: String, item: MenuItem): Boolean {
return super.performAction(id, item)
}
}
Expand Up @@ -4,8 +4,9 @@

package org.mozilla.geckoview

import mozilla.components.support.test.mock
import org.mozilla.gecko.util.GeckoBundle

class MockWebExtension(bundle: GeckoBundle) : WebExtension(bundle)
class MockWebExtension(bundle: GeckoBundle) : WebExtension(DelegateControllerProvider { mock() }, bundle)
class MockCreateTabDetails(bundle: GeckoBundle) : WebExtension.CreateTabDetails(bundle)
class MockUpdateTabDetails(bundle: GeckoBundle) : WebExtension.UpdateTabDetails(bundle)

0 comments on commit 52aa118

Please sign in to comment.