Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8239: Update GeckoView (Beta) to 81.0.20200825191644. r=Amejia481 a=pocmo

Follow-up from mozilla-mobile#8221. We got a new beta build and now we can update safely. :)

Co-authored-by: Sebastian Kaspari <s.kaspari@gmail.com>
  • Loading branch information
MozLando and pocmo committed Aug 26, 2020
2 parents a4c3139 + 481787c commit e47c5f0
Show file tree
Hide file tree
Showing 11 changed files with 230 additions and 38 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Gecko.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal object GeckoVersions {
/**
* GeckoView Beta Version.
*/
const val beta_version = "80.0.20200813191622"
const val beta_version = "81.0.20200825191644"

/**
* GeckoView Release Version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ class GeckoEngine(
if (cookieBehavior != value.cookiePolicy.id) {
cookieBehavior = value.cookiePolicy.id
}

if (cookiePurging != value.cookiePurging) {
setCookiePurging(value.cookiePurging)
}
}

defaultSettings?.trackingProtectionPolicy = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ class GeckoEngineSession(
notifyObservers { onFirstContentfulPaint() }
}

override fun onPaintStatusReset(session: GeckoSession) {
notifyObservers { onPaintStatusReset() }
}

override fun onContextMenu(
session: GeckoSession,
screenX: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GeckoEngineView @JvmOverloads constructor(
} catch (e: IllegalStateException) {
// This is to debug "display already acquired" crashes
val otherActivityClassName =
this.session?.accessibility?.view?.context?.javaClass?.simpleName
this.session?.accessibility?.view?.context?.javaClass?.simpleName
val otherActivityClassHashcode =
this.session?.accessibility?.view?.context?.hashCode()
val activityClassName = context.javaClass.simpleName
Expand Down Expand Up @@ -156,7 +156,21 @@ class GeckoEngineView @JvmOverloads constructor(
* GeckoEngineSession) - since the previous one is no longer usable.
*/
private fun rebind() {
currentSession?.let { currentGeckoView.setSession(it.geckoSession) }
try {
currentSession?.let { currentGeckoView.setSession(it.geckoSession) }
} catch (e: IllegalArgumentException) {
// This is to debug "Display not attached" crashes
val otherActivityClassName =
currentSession?.geckoSession?.accessibility?.view?.context?.javaClass?.simpleName
val otherActivityClassHashcode =
currentSession?.geckoSession?.accessibility?.view?.context?.hashCode()
val activityClassName = context.javaClass.simpleName
val activityClassHashCode = context.hashCode()
val msg = "REBIND: Current activity: $activityClassName hashcode " +
"$activityClassHashCode Other activity: $otherActivityClassName " +
"hashcode $otherActivityClassHashcode"
throw IllegalArgumentException(msg, e)
}
}

@Synchronized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fun TrackingProtectionPolicy.toContentBlockingSetting(
enhancedTrackingProtectionLevel(getEtpLevel())
antiTracking(getAntiTrackingPolicy())
cookieBehavior(cookiePolicy.id)
cookiePurging(cookiePurging)
safeBrowsing(safeBrowsingPolicy.sumBy { it.id })
strictSocialTrackingProtection(getStrictSocialTrackingProtection())
}.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class GeckoWebExtension(
}

override fun onOpenOptionsPage(ext: GeckoNativeWebExtension) {
ext.metaData?.optionsPageUrl?.let { optionsPageUrl ->
ext.metaData.optionsPageUrl?.let { optionsPageUrl ->
tabHandler.onNewTab(
this@GeckoWebExtension,
GeckoEngineSession(runtime),
Expand Down Expand Up @@ -340,7 +340,7 @@ class GeckoWebExtension(
* See [WebExtension.getMetadata].
*/
override fun getMetadata(): Metadata? {
return nativeExtension.metaData?.let {
return nativeExtension.metaData.let {
Metadata(
name = it.name,
description = it.description,
Expand All @@ -364,11 +364,11 @@ class GeckoWebExtension(
}

override fun isEnabled(): Boolean {
return nativeExtension.metaData?.enabled ?: true
return nativeExtension.metaData.enabled
}

override fun isAllowedInPrivateBrowsing(): Boolean {
return isBuiltIn() || nativeExtension.metaData?.allowedInPrivateBrowsing ?: false
return isBuiltIn() || nativeExtension.metaData.allowedInPrivateBrowsing
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyList
import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mockito
import org.mockito.Mockito.atLeastOnce
import org.mockito.Mockito.never
import org.mockito.Mockito.reset
import org.mockito.Mockito.spy
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyZeroInteractions
Expand Down Expand Up @@ -1761,14 +1762,14 @@ class GeckoEngineSessionTest {
fun `toggleDesktopMode should reload a non-mobile url when set to desktop mode`() {
val mobileUrl = "https://m.example.com"
val nonMobileUrl = "https://example.com"
val engineSession = Mockito.spy(GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider))
val engineSession = spy(GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider))
engineSession.currentUrl = mobileUrl

engineSession.toggleDesktopMode(true, reload = true)
verify(engineSession, Mockito.atLeastOnce()).loadUrl(nonMobileUrl, null, LoadUrlFlags.select(LoadUrlFlags.LOAD_FLAGS_REPLACE_HISTORY), null)
verify(engineSession, atLeastOnce()).loadUrl(nonMobileUrl, null, LoadUrlFlags.select(LoadUrlFlags.LOAD_FLAGS_REPLACE_HISTORY), null)

engineSession.toggleDesktopMode(false, reload = true)
verify(engineSession, Mockito.atLeastOnce()).reload()
verify(engineSession, atLeastOnce()).reload()
}

@Test
Expand Down Expand Up @@ -2194,6 +2195,25 @@ class GeckoEngineSessionTest {
assertTrue(observed)
}

@Test
fun `onPaintStatusReset notifies observers`() {
val engineSession = GeckoEngineSession(mock(),
geckoSessionProvider = geckoSessionProvider)

captureDelegates()

var observed = false

engineSession.register(object : EngineSession.Observer {
override fun onPaintStatusReset() {
observed = true
}
})

contentDelegate.value.onPaintStatusReset(mock())
assertTrue(observed)
}

@Test
fun `onCrash notifies observers about crash`() {
val engineSession = GeckoEngineSession(mock(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,27 @@ class GeckoEngineTest {
)
}

@Test
fun `cookiePurging is only invoked when the value is changed`() {
val mockRuntime = mock<GeckoRuntime>()
val settings = spy(ContentBlocking.Settings.Builder().build())
whenever(mockRuntime.settings).thenReturn(mock())
whenever(mockRuntime.settings.contentBlocking).thenReturn(settings)

val engine = GeckoEngine(testContext, runtime = mockRuntime)
val policy = TrackingProtectionPolicy.recommended()

engine.settings.trackingProtectionPolicy = policy

verify(mockRuntime.settings.contentBlocking).setCookiePurging(policy.cookiePurging)

reset(settings)

engine.settings.trackingProtectionPolicy = policy

verify(mockRuntime.settings.contentBlocking, never()).setCookiePurging(policy.cookiePurging)
}

@Test
fun `setCookieBehavior is only invoked when the value is changed`() {
val mockRuntime = mock<GeckoRuntime>()
Expand Down Expand Up @@ -1192,6 +1213,11 @@ class GeckoEngineTest {
val bundle = GeckoBundle()
bundle.putString("webExtensionId", "id")
bundle.putString("locationURI", "uri")
val metaDataBundle = GeckoBundle()
metaDataBundle.putStringArray("disabledFlags", emptyArray())
metaDataBundle.putBoolean("privateBrowsingAllowed", false)
bundle.putBundle("metaData", metaDataBundle)

val installedExtension = MockWebExtension(bundle)

val installedExtensions = listOf<GeckoWebExtension>(installedExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class TrackingProtectionPolicyKtTest {
assertEquals(policy.getAntiTrackingPolicy(), setting.antiTrackingCategories)
assertEquals(policy.cookiePolicy.id, setting.cookieBehavior)
assertEquals(defaultSafeBrowsing.sumBy { it.id }, setting.safeBrowsingCategories)
assertEquals(setting.strictSocialTrackingProtection, setting.strictSocialTrackingProtection)
assertEquals(setting.strictSocialTrackingProtection, policy.strictSocialTrackingProtection)
assertEquals(setting.cookiePurging, policy.cookiePurging)

val policyWithSafeBrowsing = TrackingProtectionPolicy.recommended().toContentBlockingSetting(emptyArray())
assertEquals(0, policyWithSafeBrowsing.safeBrowsingCategories)
Expand Down
Loading

0 comments on commit e47c5f0

Please sign in to comment.