Commit 2eb8ef72 authored by Jonathan Almeida's avatar Jonathan Almeida Committed by Christian Sadilek
Browse files

Manual GeckoView update (nightly) (20200213-035745)

parent 10da8c6e
......@@ -6,7 +6,7 @@ internal object GeckoVersions {
/**
* GeckoView Nightly Version.
*/
const val nightly_version = "75.0.20200212093201"
const val nightly_version = "75.0.20200213035745"
/**
* GeckoView Beta Version.
......
......@@ -81,6 +81,7 @@ typealias GeckoCookieBehavior = ContentBlocking.CookieBehavior
@RunWith(AndroidJUnit4::class)
class GeckoEngineSessionTest {
private lateinit var runtime: GeckoRuntime
private lateinit var geckoSession: GeckoSession
private lateinit var geckoSessionProvider: () -> GeckoSession
......@@ -107,6 +108,8 @@ class GeckoEngineSessionTest {
}
})
runtime = mock()
whenever(runtime.settings).thenReturn(mock())
navigationDelegate = ArgumentCaptor.forClass(GeckoSession.NavigationDelegate::class.java)
progressDelegate = ArgumentCaptor.forClass(GeckoSession.ProgressDelegate::class.java)
contentDelegate = ArgumentCaptor.forClass(GeckoSession.ContentDelegate::class.java)
......@@ -129,7 +132,6 @@ class GeckoEngineSessionTest {
@Test
fun engineSessionInitialization() {
val runtime = mock<GeckoRuntime>()
GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
verify(geckoSession).open(any())
......@@ -142,13 +144,12 @@ class GeckoEngineSessionTest {
@Test
fun isIgnoredForTrackingProtection() {
val mockedRuntime = mock<GeckoRuntime>()
val mockedContentBlockingController = mock<ContentBlockingController>()
var geckoResult = GeckoResult<Boolean?>()
val session = GeckoEngineSession(mockedRuntime, geckoSessionProvider = geckoSessionProvider)
val session = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
var wasExecuted = false
whenever(mockedRuntime.contentBlockingController).thenReturn(mockedContentBlockingController)
whenever(runtime.contentBlockingController).thenReturn(mockedContentBlockingController)
whenever(mockedContentBlockingController.checkException(any())).thenReturn(geckoResult)
session.isIgnoredForTrackingProtection {
......@@ -220,10 +221,8 @@ class GeckoEngineSessionTest {
@Test
fun navigationDelegateNotifiesObservers() {
val geckoResult = GeckoResult<Boolean?>()
val mockedRuntime = mock<GeckoRuntime>()
val mockedContentBlockingController = mock<ContentBlockingController>()
val engineSession = GeckoEngineSession(mockedRuntime,
geckoSessionProvider = geckoSessionProvider)
val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
var observedUrl = ""
var observedCanGoBack = false
......@@ -236,7 +235,7 @@ class GeckoEngineSessionTest {
}
})
whenever(mockedRuntime.contentBlockingController).thenReturn(mockedContentBlockingController)
whenever(runtime.contentBlockingController).thenReturn(mockedContentBlockingController)
whenever(mockedContentBlockingController.checkException(any())).thenReturn(geckoResult)
captureDelegates()
......@@ -521,17 +520,15 @@ class GeckoEngineSessionTest {
@Test
fun navigationDelegateIgnoresInitialLoadOfAboutBlank() {
val geckoResult = GeckoResult<Boolean?>()
val mockedRuntime = mock<GeckoRuntime>()
val mockedContentBlockingController = mock<ContentBlockingController>()
val engineSession = GeckoEngineSession(mockedRuntime,
geckoSessionProvider = geckoSessionProvider)
val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
var observedUrl = ""
engineSession.register(object : EngineSession.Observer {
override fun onLocationChange(url: String) { observedUrl = url }
})
whenever(mockedRuntime.contentBlockingController).thenReturn(mockedContentBlockingController)
whenever(runtime.contentBlockingController).thenReturn(mockedContentBlockingController)
whenever(mockedContentBlockingController.checkException(any())).thenReturn(geckoResult)
captureDelegates()
......@@ -934,7 +931,6 @@ class GeckoEngineSessionTest {
@Test
fun enableTrackingProtection() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
whenever(runtime.settings.contentBlocking).thenReturn(mock())
val session = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
......@@ -999,8 +995,6 @@ class GeckoEngineSessionTest {
@Test
fun disableTrackingProtection() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
whenever(runtime.settings.contentBlocking).thenReturn(mock())
val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
......@@ -1058,9 +1052,6 @@ class GeckoEngineSessionTest {
@Test
fun settingTestingMode() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
GeckoEngineSession(runtime,
geckoSessionProvider = geckoSessionProvider,
defaultSettings = DefaultSettings())
......@@ -1074,9 +1065,6 @@ class GeckoEngineSessionTest {
@Test
fun settingUserAgent() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
engineSession.settings.userAgentString
......@@ -1089,9 +1077,6 @@ class GeckoEngineSessionTest {
@Test
fun settingUserAgentDefault() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
GeckoEngineSession(runtime,
geckoSessionProvider = geckoSessionProvider,
defaultSettings = DefaultSettings(userAgentString = "test-ua"))
......@@ -1101,9 +1086,6 @@ class GeckoEngineSessionTest {
@Test
fun settingSuspendMediaWhenInactive() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
verify(geckoSession.settings, never()).suspendMediaWhenInactive = anyBoolean()
......@@ -1116,9 +1098,6 @@ class GeckoEngineSessionTest {
@Test
fun settingSuspendMediaWhenInactiveDefault() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
verify(geckoSession.settings, never()).suspendMediaWhenInactive = anyBoolean()
......@@ -1135,7 +1114,7 @@ class GeckoEngineSessionTest {
@Test
fun unsupportedSettings() {
val settings = GeckoEngineSession(mock(),
val settings = GeckoEngineSession(runtime,
geckoSessionProvider = geckoSessionProvider).settings
expectException(UnsupportedSettingException::class) {
......@@ -1335,7 +1314,7 @@ class GeckoEngineSessionTest {
fun onLoadErrorCallsInterceptorWithInvalidUri() {
val requestInterceptor: RequestInterceptor = mock()
val defaultSettings = DefaultSettings(requestInterceptor = requestInterceptor)
val engineSession = GeckoEngineSession(mock(), defaultSettings = defaultSettings)
val engineSession = GeckoEngineSession(runtime, defaultSettings = defaultSettings)
engineSession.geckoSession.navigationDelegate!!.onLoadError(
engineSession.geckoSession,
......@@ -1470,9 +1449,6 @@ class GeckoEngineSessionTest {
@Test
fun `WHEN TrackingCategory do not includes content then useTrackingProtection must be set to false`() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
val defaultSettings =
DefaultSettings(trackingProtectionPolicy = TrackingProtectionPolicy.recommended())
......@@ -1484,8 +1460,6 @@ class GeckoEngineSessionTest {
@Test
fun `WHEN disabling tracking protection THEN CookieBehavior and AntiTracking category must be set to ACCEPT_ALL and NONE`() {
val runtime = mock<GeckoRuntime>()
whenever(runtime.settings).thenReturn(mock())
whenever(runtime.settings.contentBlocking).thenReturn(mock())
val defaultSettings =
......@@ -1590,7 +1564,6 @@ class GeckoEngineSessionTest {
@Test
fun setDesktopMode() {
val runtime = mock<GeckoRuntime>()
val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
var desktopModeToggled = false
......@@ -1727,7 +1700,6 @@ class GeckoEngineSessionTest {
@Test
fun clearData() {
val runtime = mock<GeckoRuntime>()
val engineSession = GeckoEngineSession(runtime, geckoSessionProvider = geckoSessionProvider)
val observer: EngineSession.Observer = mock()
......@@ -1740,7 +1712,6 @@ class GeckoEngineSessionTest {
@Test
fun `after onCrash get called geckoSession must be reset`() {
val runtime = mock<GeckoRuntime>()
val engineSession = GeckoEngineSession(runtime)
val oldGeckoSession = engineSession.geckoSession
......
......@@ -36,6 +36,7 @@ import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyBoolean
......@@ -66,8 +67,15 @@ import org.mozilla.geckoview.WebExtension as GeckoWebExtension
@RunWith(AndroidJUnit4::class)
class GeckoEngineTest {
private val runtime: GeckoRuntime = mock()
private val context: Context = mock()
private lateinit var runtime: GeckoRuntime
private lateinit var context: Context
@Before
fun setup() {
runtime = mock()
whenever(runtime.settings).thenReturn(mock())
context = mock()
}
@Test
fun createView() {
......@@ -669,7 +677,6 @@ class GeckoEngineTest {
@Test
fun `web extension delegate handles closing tab`() {
val runtime: GeckoRuntime = mock()
val webExtensionController: WebExtensionController = mock()
whenever(runtime.webExtensionController).thenReturn(webExtensionController)
......@@ -789,7 +796,6 @@ class GeckoEngineTest {
@Test
fun `web extension delegate notified of browser actions from built-in extensions`() {
val runtime: GeckoRuntime = mock()
val webExtensionController: WebExtensionController = mock()
whenever(runtime.webExtensionController).thenReturn(webExtensionController)
......@@ -825,7 +831,6 @@ class GeckoEngineTest {
@Test
fun `web extension delegate notified of page actions from built-in extensions`() {
val runtime: GeckoRuntime = mock()
val webExtensionController: WebExtensionController = mock()
whenever(runtime.webExtensionController).thenReturn(webExtensionController)
......
......@@ -23,6 +23,7 @@ import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.spy
......@@ -37,13 +38,20 @@ import org.robolectric.Robolectric.buildActivity
@RunWith(AndroidJUnit4::class)
class TrackingProtectionExceptionFileStorageTest {
private lateinit var runtime: GeckoRuntime
private val context: Context
get() = buildActivity(Activity::class.java).get()
@Before
fun setup() {
runtime = mock()
whenever(runtime.settings).thenReturn(mock())
}
@Test
fun `restoreAsync exception`() {
val mockContentBlocking = mock<ContentBlockingController>()
val runtime: GeckoRuntime = mock()
val session = mock<GeckoEngineSession>()
val geckoResult = GeckoResult<List<ContentBlockingException>>()
val mockGeckoSession = mock<GeckoSession>()
......@@ -71,7 +79,6 @@ class TrackingProtectionExceptionFileStorageTest {
@Test
fun `add exception`() {
val mockContentBlocking = mock<ContentBlockingController>()
val runtime: GeckoRuntime = mock()
val session = spy(GeckoEngineSession(runtime))
val geckoResult = GeckoResult<List<ContentBlockingException>>()
val mockGeckoSession = mock<GeckoSession>()
......@@ -105,7 +112,6 @@ class TrackingProtectionExceptionFileStorageTest {
@Test
fun `remove all exceptions`() {
val mockContentBlocking = mock<ContentBlockingController>()
val runtime: GeckoRuntime = mock()
val session = mock<GeckoEngineSession>()
val geckoResult = GeckoResult<List<ContentBlockingException>>()
val mockGeckoSession = mock<GeckoSession>()
......@@ -138,7 +144,6 @@ class TrackingProtectionExceptionFileStorageTest {
@Test
fun `remove exception`() {
val mockContentBlocking = mock<ContentBlockingController>()
val runtime: GeckoRuntime = mock()
val session = spy(GeckoEngineSession(runtime))
var geckoResult = GeckoResult<List<ContentBlockingException>>()
val mockGeckoSession = mock<GeckoSession>()
......@@ -182,7 +187,6 @@ class TrackingProtectionExceptionFileStorageTest {
@Test
fun `remove a TrackingProtectionException`() {
val mockContentBlocking = mock<ContentBlockingController>()
val runtime: GeckoRuntime = mock()
val session = spy(GeckoEngineSession(runtime))
var geckoResult = GeckoResult<List<ContentBlockingException>>()
val mockGeckoSession = mock<GeckoSession>()
......@@ -218,7 +222,6 @@ class TrackingProtectionExceptionFileStorageTest {
@Test
fun `contains exception`() {
val mockContentBlocking = mock<ContentBlockingController>()
val runtime: GeckoRuntime = mock()
val session = mock<GeckoEngineSession>()
var geckoResult = GeckoResult<Boolean>()
val mockGeckoSession = mock<GeckoSession>()
......@@ -250,7 +253,6 @@ class TrackingProtectionExceptionFileStorageTest {
@Test
fun `getAll exceptions`() {
val mockContentBlocking = mock<ContentBlockingController>()
val runtime: GeckoRuntime = mock()
val session = mock<GeckoEngineSession>()
var geckoResult = GeckoResult<List<ContentBlockingException>>()
val mockGeckoSession = mock<GeckoSession>()
......
......@@ -10,13 +10,16 @@ import mozilla.components.concept.engine.EngineSession
import mozilla.components.concept.engine.media.Media
import mozilla.components.concept.engine.media.RecordingDevice
import mozilla.components.support.test.mock
import mozilla.components.support.test.whenever
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.verify
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.MediaElement
import org.mozilla.geckoview.MockRecordingDevice
......@@ -24,9 +27,17 @@ import org.mozilla.geckoview.MockRecordingDevice
@RunWith(AndroidJUnit4::class)
class GeckoMediaDelegateTest {
private lateinit var runtime: GeckoRuntime
@Before
fun setup() {
runtime = mock()
whenever(runtime.settings).thenReturn(mock())
}
@Test
fun `Added MediaElement is wrapped in GeckoMedia and forwarded to observer`() {
val engineSession = GeckoEngineSession(mock())
val engineSession = GeckoEngineSession(runtime)
var observedMedia: Media? = null
......@@ -47,7 +58,7 @@ class GeckoMediaDelegateTest {
@Test
fun `WHEN MediaElement is removed THEN previously added GeckoMedia is used to notify observer`() {
val engineSession = GeckoEngineSession(mock())
val engineSession = GeckoEngineSession(runtime)
var addedMedia: Media? = null
var removedMedia: Media? = null
......@@ -73,7 +84,7 @@ class GeckoMediaDelegateTest {
@Test
fun `WHEN unknown media is removed THEN observer is not notified`() {
val engineSession = GeckoEngineSession(mock())
val engineSession = GeckoEngineSession(runtime)
var onMediaRemovedExecuted = false
......@@ -91,7 +102,7 @@ class GeckoMediaDelegateTest {
@Test
fun `WHEN recording state changes THEN observers are notified`() {
val engineSession = GeckoEngineSession(mock())
val engineSession = GeckoEngineSession(runtime)
var observedDevices: List<RecordingDevice> = listOf()
......
......@@ -15,14 +15,17 @@ import mozilla.components.concept.engine.prompt.PromptRequest.SingleChoice
import mozilla.components.support.ktx.kotlin.toDate
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.whenever
import mozilla.components.test.ReflectionUtils
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.gecko.util.GeckoBundle
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.GeckoSession.PromptDelegate.DateTimePrompt.Type.DATE
import org.mozilla.geckoview.GeckoSession.PromptDelegate.DateTimePrompt.Type.DATETIME_LOCAL
......@@ -49,9 +52,17 @@ typealias AC_AUTH_LEVEL = PromptRequest.Authentication.Level
@RunWith(AndroidJUnit4::class)
class GeckoPromptDelegateTest {
private lateinit var runtime: GeckoRuntime
@Before
fun setup() {
runtime = mock()
whenever(runtime.settings).thenReturn(mock())
}
@Test
fun `onChoicePrompt called with CHOICE_TYPE_SINGLE must provide a SingleChoice PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var promptRequestSingleChoice: PromptRequest = MultipleChoice(arrayOf()) {}
var confirmWasCalled = false
val gecko = GeckoPromptDelegate(mockSession)
......@@ -84,7 +95,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onChoicePrompt called with CHOICE_TYPE_MULTIPLE must provide a MultipleChoice PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var promptRequestSingleChoice: PromptRequest = SingleChoice(arrayOf()) {}
var confirmWasCalled = false
val gecko = GeckoPromptDelegate(mockSession)
......@@ -116,7 +127,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onChoicePrompt called with CHOICE_TYPE_MENU must provide a MenuChoice PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var promptRequestSingleChoice: PromptRequest = PromptRequest.MenuChoice(arrayOf()) {}
var confirmWasCalled = false
val gecko = GeckoPromptDelegate(mockSession)
......@@ -161,7 +172,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onAlertPrompt must provide an alert PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var alertRequest: PromptRequest? = null
var dismissWasCalled = false
......@@ -197,7 +208,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt called with DATETIME_TYPE_DATE must provide a date PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var dateRequest: PromptRequest? = null
var confirmCalled = false
var onClearPicker = false
......@@ -232,7 +243,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt DATETIME_TYPE_DATE with date parameters must format dates correctly`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var timeSelectionRequest: PromptRequest.TimeSelection? = null
var geckoDate: String? = null
......@@ -270,7 +281,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt called with DATETIME_TYPE_MONTH must provide a date PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var dateRequest: PromptRequest? = null
var confirmCalled = false
......@@ -294,7 +305,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt DATETIME_TYPE_MONTH with date parameters must format dates correctly`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var timeSelectionRequest: PromptRequest.TimeSelection? = null
var geckoDate: String? = null
......@@ -330,7 +341,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt called with DATETIME_TYPE_WEEK must provide a date PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var dateRequest: PromptRequest? = null
var confirmCalled = false
val promptDelegate = GeckoPromptDelegate(mockSession)
......@@ -354,7 +365,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt DATETIME_TYPE_WEEK with date parameters must format dates correctly`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var timeSelectionRequest: PromptRequest.TimeSelection? = null
var geckoDate: String? = null
val promptDelegate = GeckoPromptDelegate(mockSession)
......@@ -390,7 +401,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt called with DATETIME_TYPE_TIME must provide a TimeSelection PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var dateRequest: PromptRequest? = null
var confirmCalled = false
......@@ -415,7 +426,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt DATETIME_TYPE_TIME with time parameters must format time correctly`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var timeSelectionRequest: PromptRequest.TimeSelection? = null
var geckoDate: String? = null
......@@ -452,7 +463,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt called with DATETIME_TYPE_DATETIME_LOCAL must provide a TimeSelection PromptRequest`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var dateRequest: PromptRequest? = null
var confirmCalled = false
......@@ -475,7 +486,7 @@ class GeckoPromptDelegateTest {
@Test
fun `onDateTimePrompt DATETIME_TYPE_DATETIME_LOCAL with date parameters must format time correctly`() {
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var timeSelectionRequest: PromptRequest.TimeSelection? = null
var geckoDate: String? = null
val promptDelegate = GeckoPromptDelegate(mockSession)
......@@ -540,7 +551,7 @@ class GeckoPromptDelegateTest {
fun `Calling onFilePrompt must provide a FilePicker PromptRequest`() {
val context = testContext
val mockSession = GeckoEngineSession(mock())
val mockSession = GeckoEngineSession(runtime)
var onSingleFileSelectedWasCalled = false
var onMultipleFilesSelectedWasCalled = false
var onDismissWasCalled = false
......@@ -603,7 +614,7 @@ class GeckoPromptDelegateTest {
@Test
fun `Calling onAuthPrompt must provide an Authentication PromptRequest`() {
val mockSession = GeckoEngineSession(mock())