Bug 1625310: Change WebExtensionTest to use the session rule for creating its GeckoSession objects; r=agi
authorAaron Klotz <aklotz@mozilla.com>
Thu, 26 Mar 2020 21:35:45 +0000
changeset 520650 1e8a3b65ac75f86b86f1ff573fa048b9de0d6382
parent 520649 6c4599d535e227b994b11c3ed1afe7905f355e8a
child 520651 5cbd560d875d4883cf7144ae0342729e9407f9aa
push id37254
push usernerli@mozilla.com
push dateFri, 27 Mar 2020 04:48:07 +0000
treeherdermozilla-central@2d758b42bd73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersagi
bugs1625310
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1625310: Change WebExtensionTest to use the session rule for creating its GeckoSession objects; r=agi Differential Revision: https://phabricator.services.mozilla.com/D68461
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/WebExtensionTest.kt
@@ -533,17 +533,17 @@ class WebExtensionTest : BaseSessionTest
         val tabsExtension = WebExtension(TABS_CREATE_REMOVE_BACKGROUND, controller)
 
         sessionRule.addExternalDelegateUntilTestEnd(
                 WebExtension.TabDelegate::class,
                 tabsExtension::setTabDelegate,
                 { tabsExtension.setTabDelegate(null) },
                 object : WebExtension.TabDelegate {
             override fun onNewTab(source: WebExtension, details: WebExtension.CreateTabDetails): GeckoResult<GeckoSession> {
-                val extensionCreatedSession = GeckoSession(sessionRule.session.settings)
+                val extensionCreatedSession = sessionRule.createClosedSession(sessionRule.session.settings)
 
                 extensionCreatedSession.webExtensionController.setTabDelegate(tabsExtension, object : WebExtension.SessionTabDelegate {
                     override fun onCloseTab(source: WebExtension?, session: GeckoSession): GeckoResult<AllowOrDeny> {
                         assertEquals(tabsExtension, source)
                         assertEquals(details.active, true)
                         assertNotEquals(null, extensionCreatedSession)
                         assertEquals(extensionCreatedSession, session)
                         onCloseRequestResult.complete(null)
@@ -573,19 +573,17 @@ class WebExtensionTest : BaseSessionTest
     // - Extension requests removal of newly created tab if tabs.query({active: true})
     //     contains only the newly activated tab
     // - TabDelegate handles closing of newly created tab
     // - Verify that close request came from right extension and targeted session
     @Test
     fun testSetTabActive() {
         val onCloseRequestResult = GeckoResult<Void>()
         val tabsExtension = WebExtension(TABS_ACTIVATE_REMOVE_BACKGROUND, controller)
-        val newTabSession = GeckoSession(sessionRule.session.settings)
-
-        newTabSession.open(sessionRule.runtime)
+        val newTabSession = sessionRule.createOpenSession(sessionRule.session.settings)
 
         sessionRule.addExternalDelegateUntilTestEnd(
                 WebExtension.SessionTabDelegate::class,
                 { delegate -> newTabSession.webExtensionController.setTabDelegate(tabsExtension, delegate) },
                 { newTabSession.webExtensionController.setTabDelegate(tabsExtension, null) },
                 object : WebExtension.SessionTabDelegate {
 
             override fun onCloseTab(source: WebExtension?, session: GeckoSession): GeckoResult<AllowOrDeny> {
@@ -634,22 +632,20 @@ class WebExtensionTest : BaseSessionTest
         })
         var tabsExtensionPB = sessionRule.waitForResult(
                 controller.install("https://example.org/tests/junit/tabs-activate-remove-2.xpi"))
 
         tabsExtensionPB = sessionRule.waitForResult(
                 controller.setAllowedInPrivateBrowsing(tabsExtensionPB, true))
 
 
-        val newTabSession = GeckoSession(sessionRule.session.settings)
-        newTabSession.open(sessionRule.runtime)
+        val newTabSession = sessionRule.createOpenSession(sessionRule.session.settings)
 
-        val newPrivateSession = GeckoSession(
+        val newPrivateSession = sessionRule.createOpenSession(
                 GeckoSessionSettings.Builder().usePrivateMode(true).build())
-        newPrivateSession.open(sessionRule.runtime)
 
         val privateBrowsingNewTabSession = GeckoResult<Void>()
 
         class TabDelegate(val result: GeckoResult<Void>, val extension: WebExtension,
                           val expectedSession: GeckoSession)
                 : WebExtension.SessionTabDelegate {
             override fun onCloseTab(source: WebExtension?,
                                     session: GeckoSession): GeckoResult<AllowOrDeny> {