diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/AccessibilityTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/AccessibilityTest.kt index 4079053f2756..cb8f67289a7b 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/AccessibilityTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/AccessibilityTest.kt @@ -150,7 +150,7 @@ class AccessibilityTest : BaseSessionTest() { @After fun teardown() { sessionRule.runtime.settings.forceEnableAccessibility = false - sessionRule.session.accessibility.view = null + mainSession.accessibility.view = null nodeInfos.forEach { node -> node.recycle() } } @@ -189,7 +189,7 @@ class AccessibilityTest : BaseSessionTest() { } @Test fun testPageLoad() { - sessionRule.session.loadTestPath(INPUTS_PATH) + mainSession.loadTestPath(INPUTS_PATH) sessionRule.waitUntilCalled(object : EventDelegate { @AssertCalled(count = 1) @@ -199,7 +199,7 @@ class AccessibilityTest : BaseSessionTest() { @Test fun testAccessibilityFocus() { var nodeId = AccessibilityNodeProvider.HOST_VIEW_ID - sessionRule.session.loadTestPath(INPUTS_PATH) + mainSession.loadTestPath(INPUTS_PATH) waitForInitialFocus(true) sessionRule.waitUntilCalled(object : EventDelegate { @@ -245,7 +245,7 @@ class AccessibilityTest : BaseSessionTest() { } fun loadTestPage(page: String) { - sessionRule.session.loadTestPath("/assets/www/accessibility/$page.html") + mainSession.loadTestPath("/assets/www/accessibility/$page.html") } @Test fun testTextEntryNode() { @@ -487,7 +487,7 @@ class AccessibilityTest : BaseSessionTest() { @Test fun testMoveByCharacter() { var nodeId = AccessibilityNodeProvider.HOST_VIEW_ID - sessionRule.session.loadTestPath(LOREM_IPSUM_HTML_PATH) + mainSession.loadTestPath(LOREM_IPSUM_HTML_PATH) waitForInitialFocus(true) sessionRule.waitUntilCalled(object : EventDelegate { @@ -517,7 +517,7 @@ class AccessibilityTest : BaseSessionTest() { @Test fun testMoveByWord() { var nodeId = AccessibilityNodeProvider.HOST_VIEW_ID - sessionRule.session.loadTestPath(LOREM_IPSUM_HTML_PATH) + mainSession.loadTestPath(LOREM_IPSUM_HTML_PATH) waitForInitialFocus(true) sessionRule.waitUntilCalled(object : EventDelegate { @@ -547,7 +547,7 @@ class AccessibilityTest : BaseSessionTest() { @Test fun testMoveByLine() { var nodeId = AccessibilityNodeProvider.HOST_VIEW_ID - sessionRule.session.loadTestPath(LOREM_IPSUM_HTML_PATH) + mainSession.loadTestPath(LOREM_IPSUM_HTML_PATH) waitForInitialFocus(true) sessionRule.waitUntilCalled(object : EventDelegate { @@ -577,7 +577,7 @@ class AccessibilityTest : BaseSessionTest() { @Test fun testMoveByCharacterAtEdges() { var nodeId = AccessibilityNodeProvider.HOST_VIEW_ID - sessionRule.session.loadTestPath(LOREM_IPSUM_HTML_PATH) + mainSession.loadTestPath(LOREM_IPSUM_HTML_PATH) waitForInitialFocus() // Move to the first link containing "anim id". @@ -627,7 +627,7 @@ class AccessibilityTest : BaseSessionTest() { @Test fun testMoveByWordAtEdges() { var nodeId = AccessibilityNodeProvider.HOST_VIEW_ID - sessionRule.session.loadTestPath(LOREM_IPSUM_HTML_PATH) + mainSession.loadTestPath(LOREM_IPSUM_HTML_PATH) waitForInitialFocus() // Move to the first link containing "anim id". @@ -677,7 +677,7 @@ class AccessibilityTest : BaseSessionTest() { @Test fun testMoveAtEndOfTextTrailingWhitespace() { var nodeId = AccessibilityNodeProvider.HOST_VIEW_ID - sessionRule.session.loadTestPath(LOREM_IPSUM_HTML_PATH) + mainSession.loadTestPath(LOREM_IPSUM_HTML_PATH) waitForInitialFocus(true) sessionRule.waitUntilCalled(object : EventDelegate { diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentBlockingControllerTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentBlockingControllerTest.kt index 907409d41040..6e9df37ad5df 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentBlockingControllerTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentBlockingControllerTest.kt @@ -129,8 +129,8 @@ class ContentBlockingControllerTest : BaseSessionTest() { fun getLog() { val category = ContentBlocking.AntiTracking.TEST sessionRule.runtime.settings.contentBlocking.setAntiTracking(category) - sessionRule.session.settings.useTrackingProtection = true - sessionRule.session.loadTestPath(TRACKERS_PATH) + mainSession.settings.useTrackingProtection = true + mainSession.loadTestPath(TRACKERS_PATH) sessionRule.waitUntilCalled(object : ContentBlocking.Delegate { @AssertCalled(count = 1) @@ -140,7 +140,7 @@ class ContentBlockingControllerTest : BaseSessionTest() { } }) - sessionRule.waitForResult(sessionRule.runtime.contentBlockingController.getLog(sessionRule.session).accept { + sessionRule.waitForResult(sessionRule.runtime.contentBlockingController.getLog(mainSession).accept { assertThat("Log must not be null", it, notNullValue()) assertThat("Log must have at least one entry", it?.size, not(0)) it?.forEach { diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt index cd7b840634c8..90b507170bd9 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ContentDelegateTest.kt @@ -32,7 +32,7 @@ import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.NullDelegate @MediumTest class ContentDelegateTest : BaseSessionTest() { @Test fun titleChange() { - sessionRule.session.loadTestPath(TITLE_CHANGE_HTML_PATH) + mainSession.loadTestPath(TITLE_CHANGE_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 2) @@ -47,7 +47,7 @@ class ContentDelegateTest : BaseSessionTest() { // disable test on pgo for frequently failing Bug 1543355 assumeThat(sessionRule.env.isDebugBuild, equalTo(true)) - sessionRule.session.loadTestPath(DOWNLOAD_HTML_PATH) + mainSession.loadTestPath(DOWNLOAD_HTML_PATH) sessionRule.waitUntilCalled(object : NavigationDelegate, ContentDelegate { @@ -395,7 +395,7 @@ class ContentDelegateTest : BaseSessionTest() { @AssertCalled(count = 1) override fun onPageStop(session: GeckoSession, success: Boolean) { assertThat("The script did not complete.", - sessionRule.session.evaluateJS("document.getElementById(\"content\").innerHTML") as String, + mainSession.evaluateJS("document.getElementById(\"content\").innerHTML") as String, equalTo("Started")) } }) @@ -413,7 +413,7 @@ class ContentDelegateTest : BaseSessionTest() { @AssertCalled(count = 1) override fun onPageStop(session: GeckoSession, success: Boolean) { assertThat("The script did not complete.", - sessionRule.session.evaluateJS("document.getElementById(\"content\").innerHTML") as String, + mainSession.evaluateJS("document.getElementById(\"content\").innerHTML") as String, equalTo("Started")) } }) @@ -437,7 +437,7 @@ class ContentDelegateTest : BaseSessionTest() { override fun onPageStop(session: GeckoSession, success: Boolean) { assertThat("The delegate was informed of the hang repeatedly", scriptHungReportCount, greaterThan(1)) assertThat("The script did complete.", - sessionRule.session.evaluateJS("document.getElementById(\"content\").innerHTML") as String, + mainSession.evaluateJS("document.getElementById(\"content\").innerHTML") as String, equalTo("Finished")) } }) @@ -458,7 +458,7 @@ class ContentDelegateTest : BaseSessionTest() { @AssertCalled(count = 1, order = [2]) override fun onPageStop(session: GeckoSession, success: Boolean) { assertThat("The script did not complete.", - sessionRule.session.evaluateJS("document.getElementById(\"content\").innerHTML") as String, + mainSession.evaluateJS("document.getElementById(\"content\").innerHTML") as String, equalTo("Started")) } }) @@ -479,7 +479,7 @@ class ContentDelegateTest : BaseSessionTest() { @AssertCalled(count = 1, order = [2]) override fun onPageStop(session: GeckoSession, success: Boolean) { assertThat("The script did complete.", - sessionRule.session.evaluateJS("document.getElementById(\"content\").innerHTML") as String, + mainSession.evaluateJS("document.getElementById(\"content\").innerHTML") as String, equalTo("Finished")) } }) @@ -506,7 +506,7 @@ class ContentDelegateTest : BaseSessionTest() { @AssertCalled(count = 1, order = [3]) override fun onPageStop(session: GeckoSession, success: Boolean) { assertThat("The script did not complete.", - sessionRule.session.evaluateJS("document.getElementById(\"content\").innerHTML") as String, + mainSession.evaluateJS("document.getElementById(\"content\").innerHTML") as String, equalTo("Started")) } }) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/DynamicToolbarTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/DynamicToolbarTest.kt index 192af1d0c9a0..a8bc140b31cb 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/DynamicToolbarTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/DynamicToolbarTest.kt @@ -152,15 +152,15 @@ class DynamicToolbarTest : BaseSessionTest() { mainSession.loadTestPath(BaseSessionTest.FIXED_VH) mainSession.waitForPageStop() - val pixelRatio = sessionRule.session.evaluateJS("window.devicePixelRatio") as Double - val scale = sessionRule.session.evaluateJS("window.visualViewport.scale") as Double + val pixelRatio = mainSession.evaluateJS("window.devicePixelRatio") as Double + val scale = mainSession.evaluateJS("window.visualViewport.scale") as Double for (i in 1..dynamicToolbarMaxHeight) { // Simulate the dynamic toolbar is going to be hidden. sessionRule.display?.run { setVerticalClipping(-i) } val expectedViewportHeight = (SCREEN_HEIGHT - dynamicToolbarMaxHeight + i) / scale / pixelRatio - val promise = sessionRule.session.evaluatePromiseJS(""" + val promise = mainSession.evaluatePromiseJS(""" new Promise(resolve => { window.visualViewport.addEventListener('resize', resolve(window.visualViewport.height)); }); @@ -203,7 +203,7 @@ class DynamicToolbarTest : BaseSessionTest() { getComputedStyle(document.querySelector('#fixed-element')).height """.trimIndent()) as String - val scale = sessionRule.session.evaluateJS("window.visualViewport.scale") as Double + val scale = mainSession.evaluateJS("window.visualViewport.scale") as Double val expectedHeight = (SCREEN_HEIGHT / scale).toInt() assertThat("The %-based height should be now recomputed based on the screen height", height, equalTo(expectedHeight.toString() + "px")) @@ -222,7 +222,7 @@ class DynamicToolbarTest : BaseSessionTest() { mainSession.waitForPageStop() for (i in 1..dynamicToolbarMaxHeight - 1) { - val promise = sessionRule.session.evaluatePromiseJS(""" + val promise = mainSession.evaluatePromiseJS(""" new Promise(resolve => { let fired = false; window.addEventListener('resize', () => { fired = true; }, { once: true }); @@ -239,7 +239,7 @@ class DynamicToolbarTest : BaseSessionTest() { promise.value as Boolean, equalTo(false)); } - val promise = sessionRule.session.evaluatePromiseJS(""" + val promise = mainSession.evaluatePromiseJS(""" new Promise(resolve => { window.addEventListener('resize', () => { resolve(true); }, { once: true }); }); @@ -265,10 +265,10 @@ class DynamicToolbarTest : BaseSessionTest() { mainSession.loadTestPath(BaseSessionTest.FIXED_BOTTOM) mainSession.waitForPageStop() - val pixelRatio = sessionRule.session.evaluateJS("window.devicePixelRatio") as Double + val pixelRatio = mainSession.evaluateJS("window.devicePixelRatio") as Double for (i in 1..dynamicToolbarMaxHeight - 1) { - val promise = sessionRule.session.evaluatePromiseJS(""" + val promise = mainSession.evaluatePromiseJS(""" new Promise(resolve => { window.visualViewport.addEventListener('resize', resolve(window.innerHeight)); }); @@ -280,7 +280,7 @@ class DynamicToolbarTest : BaseSessionTest() { promise.value as Double, closeTo(SCREEN_HEIGHT / 2 / pixelRatio, .01)) } - val promise = sessionRule.session.evaluatePromiseJS(""" + val promise = mainSession.evaluatePromiseJS(""" new Promise(resolve => { window.addEventListener('resize', () => { resolve(window.innerHeight); }, { once: true }); }); @@ -303,7 +303,7 @@ class DynamicToolbarTest : BaseSessionTest() { mainSession.loadTestPath(BaseSessionTest.FIXED_VH) mainSession.waitForPageStop() - val promise = sessionRule.session.evaluatePromiseJS(""" + val promise = mainSession.evaluatePromiseJS(""" new Promise(resolve => window.addEventListener('resize', () => resolve(true))); """.trimIndent()) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ExtensionActionTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ExtensionActionTest.kt index cfd9fede56bd..47a1017f0a93 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ExtensionActionTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ExtensionActionTest.kt @@ -58,7 +58,7 @@ class ExtensionActionTest : BaseSessionTest() { extension = sessionRule.waitForResult( controller.installBuiltIn("resource://android/assets/web_extensions/actions/")); - sessionRule.session.webExtensionController.setMessageDelegate( + mainSession.webExtensionController.setMessageDelegate( extension!!, object : WebExtension.MessageDelegate { override fun onConnect(port: WebExtension.Port) { @@ -86,7 +86,7 @@ class ExtensionActionTest : BaseSessionTest() { } }) - sessionRule.session.loadUri("http://example.com") + mainSession.loadUri("http://example.com") sessionRule.waitForPageStop() val pageAction = sessionRule.waitForResult(pageActionDefaultResult) @@ -174,8 +174,8 @@ class ExtensionActionTest : BaseSessionTest() { sessionRule.addExternalDelegateDuringNextWait( WebExtension.ActionDelegate::class, { delegate -> - sessionRule.session.webExtensionController.setActionDelegate(extension!!, delegate) }, - { sessionRule.session.webExtensionController.setActionDelegate(extension!!, null) }, + mainSession.webExtensionController.setActionDelegate(extension!!, delegate) }, + { mainSession.webExtensionController.setActionDelegate(extension!!, null) }, object : WebExtension.ActionDelegate { override fun onBrowserAction(extension: WebExtension, session: GeckoSession?, action: WebExtension.Action) { assertEquals(id, "#browserAction") @@ -505,7 +505,7 @@ class ExtensionActionTest : BaseSessionTest() { }""")) val openPopup = GeckoResult() - sessionRule.session.webExtensionController.setActionDelegate(extension!!, + mainSession.webExtensionController.setActionDelegate(extension!!, object : WebExtension.ActionDelegate { override fun onOpenPopup(extension: WebExtension, popupAction: WebExtension.Action): GeckoResult? { @@ -518,7 +518,7 @@ class ExtensionActionTest : BaseSessionTest() { sessionRule.waitForPageStops(2) // openPopup needs user activation - sessionRule.session.synthesizeTap(50, 50) + mainSession.synthesizeTap(50, 50) sessionRule.waitForResult(openPopup) } diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt index b5646e13056d..f663dc2ec22b 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoSessionTestRuleTest.kt @@ -39,14 +39,14 @@ import org.junit.runner.RunWith class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test fun getSession() { - assertThat("Can get session", sessionRule.session, notNullValue()) + assertThat("Can get session", mainSession, notNullValue()) assertThat("Session is open", - sessionRule.session.isOpen, equalTo(true)) + mainSession.isOpen, equalTo(true)) } @ClosedSessionAtStart @Test fun getSession_closedSession() { - assertThat("Session is closed", sessionRule.session.isOpen, equalTo(false)) + assertThat("Session is closed", mainSession.isOpen, equalTo(false)) } @Setting.List(Setting(key = Setting.Key.USE_PRIVATE_MODE, value = "true"), @@ -55,16 +55,16 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Setting(key = Setting.Key.USE_TRACKING_PROTECTION, value = "true") @Test fun settingsApplied() { assertThat("USE_PRIVATE_MODE should be set", - sessionRule.session.settings.usePrivateMode, + mainSession.settings.usePrivateMode, equalTo(true)) assertThat("DISPLAY_MODE should be set", - sessionRule.session.settings.displayMode, + mainSession.settings.displayMode, equalTo(GeckoSessionSettings.DISPLAY_MODE_MINIMAL_UI)) assertThat("USE_TRACKING_PROTECTION should be set", - sessionRule.session.settings.useTrackingProtection, + mainSession.settings.useTrackingProtection, equalTo(true)) assertThat("ALLOW_JAVASCRIPT should be set", - sessionRule.session.settings.allowJavascript, + mainSession.settings.allowJavascript, equalTo(false)) } @@ -90,21 +90,21 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @NullDelegate(ScrollDelegate::class) @Test fun nullDelegate() { assertThat("Content delegate should be null", - sessionRule.session.contentDelegate, nullValue()) + mainSession.contentDelegate, nullValue()) assertThat("Navigation delegate should be null", - sessionRule.session.navigationDelegate, nullValue()) + mainSession.navigationDelegate, nullValue()) assertThat("Scroll delegate should be null", - sessionRule.session.scrollDelegate, nullValue()) + mainSession.scrollDelegate, nullValue()) assertThat("Progress delegate should not be null", - sessionRule.session.progressDelegate, notNullValue()) + mainSession.progressDelegate, notNullValue()) } @NullDelegate(ProgressDelegate::class) @ClosedSessionAtStart @Test fun nullDelegate_closed() { assertThat("Progress delegate should be null", - sessionRule.session.progressDelegate, nullValue()) + mainSession.progressDelegate, nullValue()) } @Test(expected = AssertionError::class) @@ -112,13 +112,13 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @ClosedSessionAtStart fun nullDelegate_requireProgressOnOpen() { assertThat("Progress delegate should be null", - sessionRule.session.progressDelegate, nullValue()) + mainSession.progressDelegate, nullValue()) - sessionRule.session.open() + mainSession.open() } @Test fun waitForPageStop() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() var counter = 0 @@ -133,8 +133,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun waitForPageStops() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() sessionRule.waitForPageStops(2) var counter = 0 @@ -152,18 +152,18 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @NullDelegate(ProgressDelegate::class) @ClosedSessionAtStart fun waitForPageStops_throwOnNullDelegate() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.open(sessionRule.runtime) // Avoid waiting for initial load - sessionRule.session.reload() - sessionRule.session.waitForPageStops(2) + mainSession.open(sessionRule.runtime) // Avoid waiting for initial load + mainSession.reload() + mainSession.waitForPageStops(2) } @Test fun waitUntilCalled_anyInterfaceMethod() { // TODO: Bug 1673953 assumeThat(sessionRule.env.isFission, equalTo(false)) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(ProgressDelegate::class) var counter = 0 @@ -195,7 +195,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun waitUntilCalled_specificInterfaceMethod() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(ProgressDelegate::class, "onPageStart", "onPageStop") @@ -216,28 +216,28 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun waitUntilCalled_throwOnNotGeckoSessionInterface() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(CharSequence::class) } fun waitUntilCalled_notThrowOnCallbackInterface() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(ProgressDelegate::class) } @NullDelegate(ScrollDelegate::class) @Test fun waitUntilCalled_notThrowOnNonNullDelegateMethod() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.reload() - sessionRule.session.waitUntilCalled(ProgressDelegate::class, "onPageStop") + mainSession.reload() + mainSession.waitUntilCalled(ProgressDelegate::class, "onPageStop") } @Test fun waitUntilCalled_anyObjectMethod() { // TODO: Bug 1673953 assumeThat(sessionRule.env.isFission, equalTo(false)) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) var counter = 0 @@ -268,7 +268,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun waitUntilCalled_specificObjectMethod() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) var counter = 0 @@ -290,11 +290,11 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) @NullDelegate(ScrollDelegate::class) fun waitUntilCalled_throwOnNullDelegateObject() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.reload() - sessionRule.session.waitUntilCalled(object : ScrollDelegate { + mainSession.reload() + mainSession.waitUntilCalled(object : ScrollDelegate { @AssertCalled override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) { } @@ -303,11 +303,11 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @NullDelegate(ScrollDelegate::class) @Test fun waitUntilCalled_notThrowOnNonNullDelegateObject() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.reload() - sessionRule.session.waitUntilCalled(object : ProgressDelegate { + mainSession.reload() + mainSession.waitUntilCalled(object : ProgressDelegate { @AssertCalled override fun onPageStop(session: GeckoSession, success: Boolean) { } @@ -315,8 +315,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun waitUntilCalled_multipleCount() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() var counter = 0 @@ -336,8 +336,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun waitUntilCalled_currentCall() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() var counter = 0 @@ -359,7 +359,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = IllegalStateException::class) fun waitUntilCalled_passThroughExceptions() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(object : ProgressDelegate { @AssertCalled override fun onPageStop(session: GeckoSession, success: Boolean) { @@ -370,7 +370,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test fun waitUntilCalled_zeroCount() { // Support having @AssertCalled(count = 0) annotations for waitUntilCalled calls. - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(object : ProgressDelegate, ScrollDelegate { @AssertCalled(count = 1) override fun onPageStop(session: GeckoSession, success: Boolean) { @@ -385,7 +385,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test fun forCallbacksDuringWait_anyMethod() { // TODO: Bug 1673953 assumeThat(sessionRule.env.isFission, equalTo(false)) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() var counter = 0 @@ -401,14 +401,14 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun forCallbacksDuringWait_throwOnAnyMethodNotCalled() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ScrollDelegate {}) } @Test fun forCallbacksDuringWait_specificMethod() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() var counter = 0 @@ -429,8 +429,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun forCallbacksDuringWait_specificMethodMultipleTimes() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() sessionRule.waitForPageStops(2) var counter = 0 @@ -452,7 +452,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun forCallbacksDuringWait_throwOnSpecificMethodNotCalled() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ScrollDelegate { @@ -463,8 +463,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun forCallbacksDuringWait_specificCount() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() sessionRule.waitForPageStops(2) var counter = 0 @@ -486,8 +486,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun forCallbacksDuringWait_throwOnWrongCount() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() sessionRule.waitForPageStops(2) sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -502,7 +502,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun forCallbacksDuringWait_specificOrder() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -518,7 +518,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun forCallbacksDuringWait_throwOnWrongOrder() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -533,8 +533,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun forCallbacksDuringWait_multipleOrder() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() sessionRule.waitForPageStops(2) sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -550,8 +550,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun forCallbacksDuringWait_throwOnWrongMultipleOrder() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() sessionRule.waitForPageStops(2) sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -566,7 +566,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun forCallbacksDuringWait_notCalled() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ScrollDelegate { @@ -578,7 +578,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun forCallbacksDuringWait_throwOnCallingNoCall() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -589,7 +589,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun forCallbacksDuringWait_zeroCountEqualsNotCalled() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ScrollDelegate { @@ -601,7 +601,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun forCallbacksDuringWait_throwOnCallingZeroCount() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -612,10 +612,10 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun forCallbacksDuringWait_limitedToLastWait() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() - sessionRule.session.reload() - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() + mainSession.reload() + mainSession.reload() // Wait for Gecko to finish all loads. Thread.sleep(100) @@ -642,7 +642,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun forCallbacksDuringWait_currentCall() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -660,7 +660,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = IllegalStateException::class) fun forCallbacksDuringWait_passThroughExceptions() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -674,23 +674,23 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) @NullDelegate(ScrollDelegate::class) fun forCallbacksDuringWait_throwOnAnyNullDelegate() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() - sessionRule.session.forCallbacksDuringWait(object : NavigationDelegate, ScrollDelegate {}) + mainSession.forCallbacksDuringWait(object : NavigationDelegate, ScrollDelegate {}) } @Test(expected = AssertionError::class) @NullDelegate(ScrollDelegate::class) fun forCallbacksDuringWait_throwOnSpecificNullDelegate() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() - sessionRule.session.forCallbacksDuringWait(object : ScrollDelegate { + mainSession.forCallbacksDuringWait(object : ScrollDelegate { @AssertCalled override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) { } @@ -699,12 +699,12 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @NullDelegate(ScrollDelegate::class) @Test fun forCallbacksDuringWait_notThrowOnNonNullDelegate() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() - sessionRule.session.forCallbacksDuringWait(object : ProgressDelegate { + mainSession.forCallbacksDuringWait(object : ProgressDelegate { @AssertCalled override fun onPageStop(session: GeckoSession, success: Boolean) { } @@ -731,7 +731,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() assertThat("Callback count should be correct", counter, equalTo(2)) @@ -763,7 +763,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() } @@ -779,7 +779,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() } @@ -796,12 +796,12 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() } @Test fun delegateDuringNextWait() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() var counter = 0 @@ -817,12 +817,12 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() assertThat("Should have delegated", counter, equalTo(2)) - sessionRule.session.reload() + mainSession.reload() sessionRule.waitForPageStop() assertThat("Delegate should be cleared", counter, equalTo(2)) @@ -835,7 +835,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() } @@ -888,14 +888,14 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() assertThat("Text delegate should be overridden", testCounter, equalTo(2)) assertThat("Wait delegate should be used", waitCounter, equalTo(2)) - sessionRule.session.reload() + mainSession.reload() sessionRule.waitForPageStop() assertThat("Test delegate should be used", testCounter, equalTo(6)) @@ -911,14 +911,14 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() } @Test(expected = AssertionError::class) @NullDelegate(NavigationDelegate::class) fun delegateDuringNextWait_throwOnNullDelegate() { - sessionRule.session.delegateDuringNextWait(object : NavigationDelegate { + mainSession.delegateDuringNextWait(object : NavigationDelegate { override fun onLocationChange(session: GeckoSession, url: String?) { } }) @@ -926,7 +926,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test fun wrapSession() { val session = sessionRule.wrapSession( - GeckoSession(sessionRule.session.settings)) + GeckoSession(mainSession.settings)) sessionRule.openSession(session) session.reload() session.waitForPageStop() @@ -937,11 +937,11 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { assertThat("Can create session", newSession, notNullValue()) assertThat("New session is open", newSession.isOpen, equalTo(true)) assertThat("New session has same settings", - newSession.settings, equalTo(sessionRule.session.settings)) + newSession.settings, equalTo(mainSession.settings)) } @Test fun createOpenSession_withSettings() { - val settings = GeckoSessionSettings.Builder(sessionRule.session.settings) + val settings = GeckoSessionSettings.Builder(mainSession.settings) .usePrivateMode(true) .build() @@ -953,10 +953,10 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { // TODO: Bug 1673953 assumeThat(sessionRule.env.isFission, equalTo(false)) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) val newSession = sessionRule.createOpenSession() - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStops(2) newSession.forCallbacksDuringWait(object : ProgressDelegate { @@ -965,7 +965,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.forCallbacksDuringWait(object : ProgressDelegate { + mainSession.forCallbacksDuringWait(object : ProgressDelegate { @AssertCalled(count = 2) override fun onPageStop(session: GeckoSession, success: Boolean) { } @@ -977,11 +977,11 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { assertThat("Can create session", newSession, notNullValue()) assertThat("New session is open", newSession.isOpen, equalTo(false)) assertThat("New session has same settings", - newSession.settings, equalTo(sessionRule.session.settings)) + newSession.settings, equalTo(mainSession.settings)) } @Test fun createClosedSession_withSettings() { - val settings = GeckoSessionSettings.Builder(sessionRule.session.settings).usePrivateMode(true).build() + val settings = GeckoSessionSettings.Builder(mainSession.settings).usePrivateMode(true).build() val newSession = sessionRule.createClosedSession(settings) assertThat("New session has same settings", newSession.settings, equalTo(settings)) @@ -1020,7 +1020,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = AssertionError::class) fun waitForPageStop_throwOnNotWrapped() { - GeckoSession(sessionRule.session.settings).waitForPageStop() + GeckoSession(mainSession.settings).waitForPageStop() } @Test fun waitForPageStops_withSpecificSessions() { @@ -1033,7 +1033,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test fun waitForPageStops_withAllSessions() { val newSession = sessionRule.createOpenSession() newSession.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStops(2) } @@ -1041,9 +1041,9 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { // TODO: Bug 1673953 assumeThat(sessionRule.env.isFission, equalTo(false)) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) val session = sessionRule.createOpenSession() - sessionRule.session.reload() + mainSession.reload() session.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStops(3) } @@ -1073,7 +1073,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test fun waitUntilCalled_callbackWithAllSessions() { val newSession = sessionRule.createOpenSession() newSession.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(object : ProgressDelegate { @AssertCalled(count = 2) override fun onPageStop(session: GeckoSession, success: Boolean) { @@ -1095,7 +1095,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.forCallbacksDuringWait(object : ProgressDelegate { + mainSession.forCallbacksDuringWait(object : ProgressDelegate { @AssertCalled(false) override fun onPageStop(session: GeckoSession, success: Boolean) { counter++ @@ -1108,7 +1108,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test fun forCallbacksDuringWait_withAllSessions() { val newSession = sessionRule.createOpenSession() newSession.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStops(2) var counter = 0 @@ -1126,8 +1126,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test fun forCallbacksDuringWait_limitedToLastSessionWait() { val newSession = sessionRule.createOpenSession() - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() newSession.loadTestPath(HELLO_HTML_PATH) newSession.waitForPageStop() @@ -1135,7 +1135,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { // forCallbacksDuringWait calls strictly apply to the last wait, session-specific or not. var counter = 0 - sessionRule.session.forCallbacksDuringWait(object : ProgressDelegate { + mainSession.forCallbacksDuringWait(object : ProgressDelegate { @AssertCalled(false) override fun onPageStop(session: GeckoSession, success: Boolean) { counter++ @@ -1171,7 +1171,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } }) - sessionRule.session.delegateUntilTestEnd(object : ProgressDelegate { + mainSession.delegateUntilTestEnd(object : ProgressDelegate { @AssertCalled(false) override fun onPageStop(session: GeckoSession, success: Boolean) { counter++ @@ -1220,7 +1220,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { }) newSession.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStops(2) assertThat("Callback count should be correct", counter, equalTo(1)) @@ -1245,7 +1245,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { }) newSession.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStops(2) assertThat("Callback count should be correct", counter, equalTo(2)) @@ -1253,20 +1253,20 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @WithDisplay(width = 100, height = 100) @Test fun synthesizeTap() { - sessionRule.session.loadTestPath(CLICK_TO_RELOAD_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(CLICK_TO_RELOAD_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.synthesizeTap(50, 50) - sessionRule.session.waitForPageStop() + mainSession.synthesizeTap(50, 50) + mainSession.waitForPageStop() } @WithDisplay(width = 100, height = 100) @Test fun synthesizeMouseMove() { - sessionRule.session.loadTestPath(MOUSE_TO_RELOAD_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(MOUSE_TO_RELOAD_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.synthesizeMouseMove(50, 50) - sessionRule.session.waitForPageStop() + mainSession.synthesizeMouseMove(50, 50) + mainSession.waitForPageStop() } @Test fun evaluateExtensionJS() { @@ -1310,50 +1310,50 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun evaluateJS() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH); - sessionRule.session.waitForPageStop(); + mainSession.loadTestPath(HELLO_HTML_PATH); + mainSession.waitForPageStop(); assertThat("JS string result should be correct", - sessionRule.session.evaluateJS("'foo'") as String, equalTo("foo")) + mainSession.evaluateJS("'foo'") as String, equalTo("foo")) assertThat("JS number result should be correct", - sessionRule.session.evaluateJS("1+1") as Double, equalTo(2.0)) + mainSession.evaluateJS("1+1") as Double, equalTo(2.0)) assertThat("JS boolean result should be correct", - sessionRule.session.evaluateJS("!0") as Boolean, equalTo(true)) + mainSession.evaluateJS("!0") as Boolean, equalTo(true)) val expected = JSONObject("{bar:42,baz:true,foo:'bar'}") - val actual = sessionRule.session.evaluateJS("({foo:'bar',bar:42,baz:true})") as JSONObject + val actual = mainSession.evaluateJS("({foo:'bar',bar:42,baz:true})") as JSONObject for (key in expected.keys()) { assertThat("JS object result should be correct", actual.get(key), equalTo(expected.get(key))) } assertThat("JS array result should be correct", - sessionRule.session.evaluateJS("[1,2,3]") as JSONArray, + mainSession.evaluateJS("[1,2,3]") as JSONArray, equalTo(JSONArray("[1,2,3]"))) assertThat("JS DOM object result should be correct", - sessionRule.session.evaluateJS("document.body.tagName") as String, + mainSession.evaluateJS("document.body.tagName") as String, equalTo("BODY")) } @Test fun evaluateJS_windowObject() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() assertThat("JS DOM window result should be correct", - (sessionRule.session.evaluateJS("window.location.pathname")) as String, + (mainSession.evaluateJS("window.location.pathname")) as String, equalTo(HELLO_HTML_PATH)) } @Test fun evaluateJS_multipleSessions() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("this.foo = 42") + mainSession.evaluateJS("this.foo = 42") assertThat("Variable should be set", - sessionRule.session.evaluateJS("this.foo") as Double, equalTo(42.0)) + mainSession.evaluateJS("this.foo") as Double, equalTo(42.0)) val newSession = sessionRule.createOpenSession() newSession.loadTestPath(HELLO_HTML_PATH) @@ -1365,18 +1365,18 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun evaluateJS_supportPromises() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() assertThat("Can get resolved promise", - sessionRule.session.evaluatePromiseJS( + mainSession.evaluatePromiseJS( "new Promise(resolve => resolve('foo'))").value as String, equalTo("foo")); - val promise = sessionRule.session.evaluatePromiseJS( + val promise = mainSession.evaluatePromiseJS( "new Promise(r => window.resolve = r)") - sessionRule.session.evaluateJS("window.resolve('bar')") + mainSession.evaluateJS("window.resolve('bar')") assertThat("Can wait for promise to resolve", promise.value as String, equalTo("bar")) @@ -1384,55 +1384,55 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { @Test(expected = RejectedPromiseException::class) fun evaluateJS_throwOnRejectedPromise() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() - sessionRule.session.evaluatePromiseJS("Promise.reject('foo')").value + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() + mainSession.evaluatePromiseJS("Promise.reject('foo')").value } @Test fun evaluateJS_notBlockMainThread() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() // Test that we can still receive delegate callbacks during evaluateJS, // by calling alert(), which blocks until prompt delegate is called. assertThat("JS blocking result should be correct", - sessionRule.session.evaluateJS("alert(); 'foo'") as String, + mainSession.evaluateJS("alert(); 'foo'") as String, equalTo("foo")) } @TimeoutMillis(1000) @Test(expected = UiThreadUtils.TimeoutException::class) fun evaluateJS_canTimeout() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() - sessionRule.session.delegateUntilTestEnd(object : PromptDelegate { + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() + mainSession.delegateUntilTestEnd(object : PromptDelegate { override fun onAlertPrompt(session: GeckoSession, prompt: PromptDelegate.AlertPrompt): GeckoResult { // Return a GeckoResult that we will never complete, so it hangs. val res = GeckoResult() return res } }) - sessionRule.session.evaluateJS("alert()") + mainSession.evaluateJS("alert()") } @Test(expected = RuntimeException::class) fun evaluateJS_throwOnJSException() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() - sessionRule.session.evaluateJS("throw Error()") + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() + mainSession.evaluateJS("throw Error()") } @Test(expected = RuntimeException::class) fun evaluateJS_throwOnSyntaxError() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() - sessionRule.session.evaluateJS("<{[") + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() + mainSession.evaluateJS("<{[") } @Test(expected = RuntimeException::class) fun evaluateJS_throwOnChromeAccess() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() - sessionRule.session.evaluateJS("ChromeUtils") + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() + mainSession.evaluateJS("ChromeUtils") } @Test fun getPrefs_undefinedPrefReturnsNull() { @@ -1474,7 +1474,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun setPrefsDuringNextWait() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.setPrefsDuringNextWait(mapOf( @@ -1491,8 +1491,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { assertThat("Prefs should be set before wait", prefs[1] as Int, equalTo(1)) assertThat("Prefs should be set before wait", prefs[2] as String, equalTo("foo")) - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() prefs = sessionRule.getPrefs( "test.pref.bool", @@ -1505,7 +1505,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun setPrefsDuringNextWait_hasPrecedence() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.setPrefsUntilTestEnd(mapOf( @@ -1525,8 +1525,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { assertThat("Prefs should be overridden", prefs[1] as String, equalTo("bar")) assertThat("Prefs should be overridden", prefs[2] as String, equalTo("baz")) - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() prefs = sessionRule.getPrefs( "test.pref.int", @@ -1539,14 +1539,14 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun waitForJS() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() assertThat("waitForJS should return correct result", - sessionRule.session.waitForJS("alert(), 'foo'") as String, + mainSession.waitForJS("alert(), 'foo'") as String, equalTo("foo")) - sessionRule.session.forCallbacksDuringWait(object : PromptDelegate { + mainSession.forCallbacksDuringWait(object : PromptDelegate { @AssertCalled(count = 1) override fun onAlertPrompt(session: GeckoSession, prompt: PromptDelegate.AlertPrompt): GeckoResult? { return null; @@ -1555,27 +1555,27 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun waitForJS_resolvePromise() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() assertThat("waitForJS should wait for promises", - sessionRule.session.waitForJS("Promise.resolve('foo')") as String, + mainSession.waitForJS("Promise.resolve('foo')") as String, equalTo("foo")) } @Test fun waitForJS_delegateDuringWait() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() var count = 0 - sessionRule.session.delegateDuringNextWait(object : PromptDelegate { + mainSession.delegateDuringNextWait(object : PromptDelegate { override fun onAlertPrompt(session: GeckoSession, prompt: PromptDelegate.AlertPrompt): GeckoResult { count++ return GeckoResult.fromValue(prompt.dismiss()) } }) - sessionRule.session.waitForJS("alert()") - sessionRule.session.waitForJS("alert()") + mainSession.waitForJS("alert()") + mainSession.waitForJS("alert()") // The delegate set through delegateDuringNextWait // should have been cleared after the first wait. @@ -1635,7 +1635,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun addExternalDelegateDuringNextWait() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() var delegate: Runnable? = null @@ -1655,7 +1655,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { } @Test fun addExternalDelegateDuringNextWait_hasPrecedence() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() var delegate: TestDelegate? = null @@ -1710,7 +1710,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) { fun contentCrashFails() { assumeThat(sessionRule.env.shouldShutdownOnCrash(), equalTo(false)) - sessionRule.session.loadUri(CONTENT_CRASH_URL) + mainSession.loadUri(CONTENT_CRASH_URL) sessionRule.waitForPageStop() } diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/HistoryDelegateTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/HistoryDelegateTest.kt index c0372fa519f1..4ee344d287ff 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/HistoryDelegateTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/HistoryDelegateTest.kt @@ -67,8 +67,8 @@ class HistoryDelegateTest : BaseSessionTest() { // Since `getVisited` is called asynchronously after the page loads, we // can't use `waitForPageStop` here. - sessionRule.session.loadUri(testUri) - sessionRule.session.waitUntilCalled(GeckoSession.HistoryDelegate::class, + mainSession.loadUri(testUri) + mainSession.waitUntilCalled(GeckoSession.HistoryDelegate::class, "onVisited", "getVisited") // Sometimes link changes are not applied immediately, wait for a little bit @@ -97,7 +97,7 @@ class HistoryDelegateTest : BaseSessionTest() { @Ignore //disable test on debug for frequent failures Bug 1544169 @Test fun onHistoryStateChange() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(object : HistoryDelegate { @AssertCalled(count = 1) @@ -111,7 +111,7 @@ class HistoryDelegateTest : BaseSessionTest() { } }) - sessionRule.session.loadTestPath(HELLO2_HTML_PATH) + mainSession.loadTestPath(HELLO2_HTML_PATH) sessionRule.waitUntilCalled(object : HistoryDelegate { @AssertCalled(count = 1) @@ -125,7 +125,7 @@ class HistoryDelegateTest : BaseSessionTest() { } }) - sessionRule.session.goBack() + mainSession.goBack() sessionRule.waitUntilCalled(object : HistoryDelegate { @AssertCalled(count = 1) @@ -139,7 +139,7 @@ class HistoryDelegateTest : BaseSessionTest() { } }) - sessionRule.session.goForward() + mainSession.goForward() sessionRule.waitUntilCalled(object : HistoryDelegate { @AssertCalled(count = 1) @@ -153,7 +153,7 @@ class HistoryDelegateTest : BaseSessionTest() { } }) - sessionRule.session.gotoHistoryIndex(0) + mainSession.gotoHistoryIndex(0) sessionRule.waitUntilCalled(object : HistoryDelegate { @AssertCalled(count = 1) @@ -167,7 +167,7 @@ class HistoryDelegateTest : BaseSessionTest() { } }) - sessionRule.session.gotoHistoryIndex(1) + mainSession.gotoHistoryIndex(1) sessionRule.waitUntilCalled(object : HistoryDelegate { @AssertCalled(count = 1) @@ -187,7 +187,7 @@ class HistoryDelegateTest : BaseSessionTest() { assumeThat(sessionRule.env.isFission, equalTo(false)) // This is a smaller version of the above test, in the hopes to minimize race conditions - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitUntilCalled(object : HistoryDelegate { @AssertCalled(count = 1) @@ -201,7 +201,7 @@ class HistoryDelegateTest : BaseSessionTest() { } }) - sessionRule.session.loadTestPath(HELLO2_HTML_PATH) + mainSession.loadTestPath(HELLO2_HTML_PATH) sessionRule.waitUntilCalled(object : HistoryDelegate { @AssertCalled(count = 1) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/InputResultDetailTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/InputResultDetailTest.kt index 6ae02dd62999..1f2719dda611 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/InputResultDetailTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/InputResultDetailTest.kt @@ -22,13 +22,13 @@ class InputResultDetailTest : BaseSessionTest() { private val scrollWaitTimeout = 10000.0 // 10 seconds private fun setupDocument(documentPath: String) { - sessionRule.session.loadTestPath(documentPath) + mainSession.loadTestPath(documentPath) sessionRule.waitUntilCalled(object : ContentDelegate { @GeckoSessionTestRule.AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { } }) - sessionRule.session.flushApzRepaints() + mainSession.flushApzRepaints() } private fun sendDownEvent(x: Float, y: Float): GeckoResult { @@ -177,7 +177,7 @@ class InputResultDetailTest : BaseSessionTest() { scroll.scrollTo(0, scroll.scrollHeight); """.trimIndent()) assertThat("scroll", scrollPromise.value as Boolean, equalTo(true)); - sessionRule.session.flushApzRepaints() + mainSession.flushApzRepaints() } @WithDisplay(width = 100, height = 100) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt index 6b80ea0e1311..e15aa3402c3e 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt @@ -91,7 +91,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.load(testLoader) + mainSession.load(testLoader) sessionRule.waitForPageStop() if (errorPageUrl != null) { @@ -148,7 +148,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.loadUri(testUri) + mainSession.loadUri(testUri) sessionRule.waitUntilCalled(NavigationDelegate::class, "onLoadError") if (errorPageUrl != null) { @@ -496,7 +496,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.load(testLoader) + mainSession.load(testLoader) sessionRule.waitForPageStop() sessionRule.runtime.settings.setAllowInsecureConnections(GeckoRuntimeSettings.ALLOW_ALL) @@ -551,7 +551,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.load(testLoader) + mainSession.load(testLoader) sessionRule.waitForPageStop() sessionRule.waitUntilCalled(object : ContentDelegate, NavigationDelegate { @@ -590,7 +590,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.load(testLoader) + mainSession.load(testLoader) sessionRule.waitForPageStop() sessionRule.delegateDuringNextWait( @@ -632,8 +632,8 @@ class NavigationDelegateTest : BaseSessionTest() { // Should match iframe URI from IFRAME_UNKNOWN_PROTOCOL val iframeUri = "foo://bar" - sessionRule.session.loadTestPath(IFRAME_UNKNOWN_PROTOCOL) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(IFRAME_UNKNOWN_PROTOCOL) + mainSession.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate { @AssertCalled(count = 1) @@ -659,7 +659,7 @@ class NavigationDelegateTest : BaseSessionTest() { @Test fun trackingProtection() { val category = ContentBlocking.AntiTracking.TEST sessionRule.runtime.settings.contentBlocking.setAntiTracking(category) - sessionRule.session.loadTestPath(TRACKERS_PATH) + mainSession.loadTestPath(TRACKERS_PATH) sessionRule.waitUntilCalled( object : ContentBlocking.Delegate { @@ -678,10 +678,10 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.settings.useTrackingProtection = false + mainSession.settings.useTrackingProtection = false - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() sessionRule.forCallbacksDuringWait( object : ContentBlocking.Delegate { @@ -716,7 +716,7 @@ class NavigationDelegateTest : BaseSessionTest() { "https://jigsaw.w3.org/HTTP/300/301.html" } - sessionRule.session.loadUri(uri) + mainSession.loadUri(uri) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate { @@ -752,7 +752,7 @@ class NavigationDelegateTest : BaseSessionTest() { IFRAME_REDIRECT_LOCAL } - sessionRule.session.loadTestPath(path) + mainSession.loadTestPath(path) sessionRule.waitForPageStop() // We shouldn't be firing onLoadRequest for iframes, including redirects. @@ -825,7 +825,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.loadUri(uri) + mainSession.loadUri(uri) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait( @@ -848,7 +848,7 @@ class NavigationDelegateTest : BaseSessionTest() { val redirectUri = "intent://test" val uri = "https://example.org/tests/junit/simple_redirect.sjs?$redirectUri" - sessionRule.session.loadUri(uri) + mainSession.loadUri(uri) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate { @@ -874,10 +874,10 @@ class NavigationDelegateTest : BaseSessionTest() { sessionRule.runtime.settings.contentBlocking.setSafeBrowsing(category) - sessionRule.session.load(Loader() + mainSession.load(Loader() .uri(phishingUri + "?bypass=true") .flags(GeckoSession.LOAD_FLAGS_BYPASS_CLASSIFIER)) - sessionRule.session.waitForPageStop() + mainSession.waitForPageStop() sessionRule.forCallbacksDuringWait( object : NavigationDelegate { @@ -908,8 +908,8 @@ class NavigationDelegateTest : BaseSessionTest() { sessionRule.runtime.settings.contentBlocking.setSafeBrowsing(ContentBlocking.SafeBrowsing.NONE) - sessionRule.session.loadUri(phishingUri + "?block=false") - sessionRule.session.waitForPageStop() + mainSession.loadUri(phishingUri + "?block=false") + mainSession.waitForPageStop() sessionRule.forCallbacksDuringWait( object : NavigationDelegate { @@ -939,8 +939,8 @@ class NavigationDelegateTest : BaseSessionTest() { sessionRule.runtime.settings.contentBlocking.setSafeBrowsing(ContentBlocking.SafeBrowsing.NONE) - sessionRule.session.loadUri(malwareUri + "?block=false") - sessionRule.session.waitForPageStop() + mainSession.loadUri(malwareUri + "?block=false") + mainSession.waitForPageStop() sessionRule.forCallbacksDuringWait( object : NavigationDelegate { @@ -966,8 +966,8 @@ class NavigationDelegateTest : BaseSessionTest() { sessionRule.runtime.settings.contentBlocking.setSafeBrowsing(ContentBlocking.SafeBrowsing.NONE) - sessionRule.session.loadUri(unwantedUri + "?block=false") - sessionRule.session.waitForPageStop() + mainSession.loadUri(unwantedUri + "?block=false") + mainSession.waitForPageStop() sessionRule.forCallbacksDuringWait( object : NavigationDelegate { @@ -997,8 +997,8 @@ class NavigationDelegateTest : BaseSessionTest() { sessionRule.runtime.settings.contentBlocking.setSafeBrowsing(ContentBlocking.SafeBrowsing.NONE) - sessionRule.session.loadUri(harmfulUri + "?block=false") - sessionRule.session.waitForPageStop() + mainSession.loadUri(harmfulUri + "?block=false") + mainSession.waitForPageStop() sessionRule.forCallbacksDuringWait( object : NavigationDelegate { @@ -1013,13 +1013,13 @@ class NavigationDelegateTest : BaseSessionTest() { // Checks that the User Agent matches the user agent built in // nsHttpHandler::BuildUserAgent @Test fun defaultUserAgentMatchesActualUserAgent() { - var userAgent = sessionRule.waitForResult(sessionRule.session.userAgent) + var userAgent = sessionRule.waitForResult(mainSession.userAgent) assertThat("Mobile user agent should match the default user agent", userAgent, equalTo(GeckoSession.getDefaultUserAgent())) } @Test fun desktopMode() { - sessionRule.session.loadUri("https://example.com") + mainSession.loadUri("https://example.com") sessionRule.waitForPageStop() val mobileSubStr = "Mobile" @@ -1029,53 +1029,53 @@ class NavigationDelegateTest : BaseSessionTest() { getUserAgent(), containsString(mobileSubStr)) - var userAgent = sessionRule.waitForResult(sessionRule.session.userAgent) + var userAgent = sessionRule.waitForResult(mainSession.userAgent) assertThat("User agent should be reported as mobile", userAgent, containsString(mobileSubStr)) - sessionRule.session.settings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_DESKTOP + mainSession.settings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_DESKTOP - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() assertThat("User agent should be set to desktop", getUserAgent(), containsString(desktopSubStr)) - userAgent = sessionRule.waitForResult(sessionRule.session.userAgent) + userAgent = sessionRule.waitForResult(mainSession.userAgent) assertThat("User agent should be reported as desktop", userAgent, containsString(desktopSubStr)) - sessionRule.session.settings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_MOBILE + mainSession.settings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_MOBILE - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() assertThat("User agent should be set to mobile", getUserAgent(), containsString(mobileSubStr)) - userAgent = sessionRule.waitForResult(sessionRule.session.userAgent) + userAgent = sessionRule.waitForResult(mainSession.userAgent) assertThat("User agent should be reported as mobile", userAgent, containsString(mobileSubStr)) val vrSubStr = "Mobile VR" - sessionRule.session.settings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_VR + mainSession.settings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_VR - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() assertThat("User agent should be set to VR", getUserAgent(), containsString(vrSubStr)) - userAgent = sessionRule.waitForResult(sessionRule.session.userAgent) + userAgent = sessionRule.waitForResult(mainSession.userAgent) assertThat("User agent should be reported as VR", userAgent, containsString(vrSubStr)) } - private fun getUserAgent(session: GeckoSession = sessionRule.session): String { + private fun getUserAgent(session: GeckoSession = mainSession): String { return session.evaluateJS("window.navigator.userAgent") as String } @@ -1098,7 +1098,7 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.loadUri("https://example.com") + mainSession.loadUri("https://example.com") sessionRule.waitForPageStop() val mobileSubStr = "Mobile" @@ -1108,52 +1108,52 @@ class NavigationDelegateTest : BaseSessionTest() { assertThat("User agent should be reported as mobile", getUserAgent(), containsString(mobileSubStr)) - sessionRule.session.settings.userAgentOverride = overrideUserAgent + mainSession.settings.userAgentOverride = overrideUserAgent - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() assertThat("User agent should be reported as override", getUserAgent(), equalTo(overrideUserAgent)) - sessionRule.session.settings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_VR + mainSession.settings.userAgentMode = GeckoSessionSettings.USER_AGENT_MODE_VR - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() assertThat("User agent should still be reported as override even when USER_AGENT_MODE is set", getUserAgent(), equalTo(overrideUserAgent)) - sessionRule.session.settings.userAgentOverride = null + mainSession.settings.userAgentOverride = null - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() assertThat("User agent should now be reported as VR", getUserAgent(), containsString(vrSubStr)) sessionRule.delegateDuringNextWait(object : NavigationDelegate { override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { - sessionRule.session.settings.userAgentOverride = overrideUserAgent + mainSession.settings.userAgentOverride = overrideUserAgent return null } }) - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() assertThat("User agent should be reported as override after being set in onLoadRequest", getUserAgent(), equalTo(overrideUserAgent)) sessionRule.delegateDuringNextWait(object : NavigationDelegate { override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { - sessionRule.session.settings.userAgentOverride = null + mainSession.settings.userAgentOverride = null return null } }) - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() assertThat("User agent should again be reported as VR after disabling override in onLoadRequest", getUserAgent(), containsString(vrSubStr)) @@ -1164,34 +1164,34 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.loadTestPath(VIEWPORT_PATH) + mainSession.loadTestPath(VIEWPORT_PATH) sessionRule.waitForPageStop() val desktopInnerWidth = 980.0 val physicalWidth = 600.0 - val pixelRatio = sessionRule.session.evaluateJS("window.devicePixelRatio") as Double + val pixelRatio = mainSession.evaluateJS("window.devicePixelRatio") as Double val mobileInnerWidth = physicalWidth / pixelRatio val innerWidthJs = "window.innerWidth" - var innerWidth = sessionRule.session.evaluateJS(innerWidthJs) as Double + var innerWidth = mainSession.evaluateJS(innerWidthJs) as Double assertThat("innerWidth should be equal to $mobileInnerWidth", innerWidth, closeTo(mobileInnerWidth, 0.1)) - sessionRule.session.settings.viewportMode = GeckoSessionSettings.VIEWPORT_MODE_DESKTOP + mainSession.settings.viewportMode = GeckoSessionSettings.VIEWPORT_MODE_DESKTOP - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() - innerWidth = sessionRule.session.evaluateJS(innerWidthJs) as Double + innerWidth = mainSession.evaluateJS(innerWidthJs) as Double assertThat("innerWidth should be equal to $desktopInnerWidth", innerWidth, closeTo(desktopInnerWidth, 0.1)) - sessionRule.session.settings.viewportMode = GeckoSessionSettings.VIEWPORT_MODE_MOBILE + mainSession.settings.viewportMode = GeckoSessionSettings.VIEWPORT_MODE_MOBILE - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() - innerWidth = sessionRule.session.evaluateJS(innerWidthJs) as Double + innerWidth = mainSession.evaluateJS(innerWidthJs) as Double assertThat("innerWidth should be equal to $mobileInnerWidth again", innerWidth, closeTo(mobileInnerWidth, 0.1)) } @@ -1200,7 +1200,7 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") + mainSession.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate { @@ -1254,7 +1254,7 @@ class NavigationDelegateTest : BaseSessionTest() { assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) val dataUrl = "data:,Hello%2C%20World!" - sessionRule.session.loadUri(dataUrl) + mainSession.loadUri(dataUrl) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate { @@ -1276,11 +1276,11 @@ class NavigationDelegateTest : BaseSessionTest() { assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) // Test that when navigation delegate is disabled, we can still perform loads. - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() } @NullDelegate(NavigationDelegate::class) @@ -1290,20 +1290,20 @@ class NavigationDelegateTest : BaseSessionTest() { // Test that if we unset the navigation delegate during a load, the load still proceeds. var onLocationCount = 0 - sessionRule.session.navigationDelegate = object : NavigationDelegate { + mainSession.navigationDelegate = object : NavigationDelegate { override fun onLocationChange(session: GeckoSession, url: String?) { onLocationCount++ } } - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() assertThat("Should get callback for first load", onLocationCount, equalTo(1)) - sessionRule.session.reload() - sessionRule.session.navigationDelegate = null - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.navigationDelegate = null + mainSession.waitForPageStop() assertThat("Should not get callback for second load", onLocationCount, equalTo(1)) @@ -1315,7 +1315,7 @@ class NavigationDelegateTest : BaseSessionTest() { val dataString = "TheTitleTheBody" val mimeType = "text/html" - sessionRule.session.load(Loader().data(dataString, mimeType)) + mainSession.load(Loader().data(dataString, mimeType)) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate, ContentDelegate { @@ -1338,7 +1338,7 @@ class NavigationDelegateTest : BaseSessionTest() { } @Test fun loadString_noMimeType() { - sessionRule.session.load(Loader().data("Hello, World!", null)) + mainSession.load(Loader().data("Hello, World!", null)) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate { @@ -1361,7 +1361,7 @@ class NavigationDelegateTest : BaseSessionTest() { val bytes = getTestBytes(HELLO_HTML_PATH) assertThat("test html should have data", bytes.size, greaterThan(0)) - sessionRule.session.load(Loader().data(bytes, "text/html")) + mainSession.load(Loader().data(bytes, "text/html")) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate, ContentDelegate { @@ -1397,7 +1397,7 @@ class NavigationDelegateTest : BaseSessionTest() { val bytes = getTestBytes(assetPath) assertThat("test data should have bytes", bytes.size, greaterThan(0)) - sessionRule.session.load(Loader().data(bytes, mimeType)) + mainSession.load(Loader().data(bytes, mimeType)) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate { @@ -1426,10 +1426,10 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") + mainSession.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") sessionRule.waitForPageStop() - sessionRule.session.reload() + mainSession.reload() sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate { @@ -1473,10 +1473,10 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") + mainSession.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") sessionRule.waitForPageStop() - sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO2_HTML_PATH") + mainSession.loadUri("$TEST_ENDPOINT$HELLO2_HTML_PATH") sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate { @@ -1486,7 +1486,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.goBack() + mainSession.goBack() sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate { @@ -1520,7 +1520,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.goForward() + mainSession.goForward() sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : NavigationDelegate { @@ -1572,8 +1572,8 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.loadTestPath(HELLO2_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO2_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -1596,12 +1596,12 @@ class NavigationDelegateTest : BaseSessionTest() { // Disable popup blocker. sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(NEW_SESSION_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("window.open('newSession_child.html', '_blank')") + mainSession.evaluateJS("window.open('newSession_child.html', '_blank')") - sessionRule.session.waitUntilCalled(object : NavigationDelegate { + mainSession.waitUntilCalled(object : NavigationDelegate { @AssertCalled(count = 1, order = [1]) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): @@ -1632,22 +1632,22 @@ class NavigationDelegateTest : BaseSessionTest() { // Disable popup blocker. sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(NEW_SESSION_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("window.open('file:///data/local/tmp', '_blank')") + mainSession.evaluateJS("window.open('file:///data/local/tmp', '_blank')") } @Test fun onNewSession_calledForTargetBlankLink() { // Disable popup blocker. sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(NEW_SESSION_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("document.querySelector('#targetBlankLink').click()") + mainSession.evaluateJS("document.querySelector('#targetBlankLink').click()") - sessionRule.session.waitUntilCalled(object : NavigationDelegate { + mainSession.waitUntilCalled(object : NavigationDelegate { // We get two onLoadRequest calls for the link click, // one when loading the URL and one when opening a new window. @AssertCalled(count = 1, order = [1]) @@ -1673,7 +1673,7 @@ class NavigationDelegateTest : BaseSessionTest() { private fun delegateNewSession(settings: GeckoSessionSettings = mainSession.settings): GeckoSession { val newSession = sessionRule.createClosedSession(settings) - sessionRule.session.delegateDuringNextWait(object : NavigationDelegate { + mainSession.delegateDuringNextWait(object : NavigationDelegate { @AssertCalled(count = 1) override fun onNewSession(session: GeckoSession, uri: String): GeckoResult { return GeckoResult.fromValue(newSession) @@ -1690,11 +1690,11 @@ class NavigationDelegateTest : BaseSessionTest() { // Disable popup blocker. sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(NEW_SESSION_HTML_PATH) + mainSession.waitForPageStop() val newSession = delegateNewSession() - sessionRule.session.evaluateJS("document.querySelector('#targetBlankLink').click()") + mainSession.evaluateJS("document.querySelector('#targetBlankLink').click()") // Initial about:blank newSession.waitForPageStop() // NEW_SESSION_CHILD_HTML_PATH @@ -1720,11 +1720,11 @@ class NavigationDelegateTest : BaseSessionTest() { // Disable popup blocker. sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(NEW_SESSION_HTML_PATH) + mainSession.waitForPageStop() val newSession = delegateNewSession() - sessionRule.session.evaluateJS("document.querySelector('#targetBlankLink').click()") + mainSession.evaluateJS("document.querySelector('#targetBlankLink').click()") newSession.waitForPageStop() assertThat("window.opener should be set", @@ -1739,11 +1739,11 @@ class NavigationDelegateTest : BaseSessionTest() { // Disable popup blocker. sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(NEW_SESSION_HTML_PATH) + mainSession.waitForPageStop() val newSession = delegateNewSession() - sessionRule.session.evaluateJS("document.querySelector('#noOpenerLink').click()") + mainSession.evaluateJS("document.querySelector('#noOpenerLink').click()") newSession.waitForPageStop() assertThat("window.opener should not be set", @@ -1758,10 +1758,10 @@ class NavigationDelegateTest : BaseSessionTest() { // Disable popup blocker. sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(NEW_SESSION_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.delegateDuringNextWait(object : NavigationDelegate { + mainSession.delegateDuringNextWait(object : NavigationDelegate { override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { @@ -1774,13 +1774,13 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.evaluateJS("document.querySelector('#targetBlankLink').click()") + mainSession.evaluateJS("document.querySelector('#targetBlankLink').click()") - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() // Assert that onNewSession was not called for the link click. - sessionRule.session.forCallbacksDuringWait(object : NavigationDelegate { + mainSession.forCallbacksDuringWait(object : NavigationDelegate { @AssertCalled(count = 2) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): @@ -1803,23 +1803,23 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.loadTestPath(FORM_BLANK_HTML_PATH) + mainSession.loadTestPath(FORM_BLANK_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" document.querySelector('input[type=text]').focus() """) - sessionRule.session.waitUntilCalled(TextInputDelegate::class, + mainSession.waitUntilCalled(TextInputDelegate::class, "restartInput") val time = SystemClock.uptimeMillis() val keyEvent = KeyEvent(time, time, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER, 0) - sessionRule.session.textInput.onKeyDown(KeyEvent.KEYCODE_ENTER, keyEvent) - sessionRule.session.textInput.onKeyUp(KeyEvent.KEYCODE_ENTER, + mainSession.textInput.onKeyDown(KeyEvent.KEYCODE_ENTER, keyEvent) + mainSession.textInput.onKeyUp(KeyEvent.KEYCODE_ENTER, KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_UP)) - sessionRule.session.waitUntilCalled(object : NavigationDelegate { + mainSession.waitUntilCalled(object : NavigationDelegate { @AssertCalled(count = 1, order = [1]) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { @@ -1848,14 +1848,14 @@ class NavigationDelegateTest : BaseSessionTest() { val uri = "https://example.com" val referrer = "https://foo.org/" - sessionRule.session.load(Loader() + mainSession.load(Loader() .uri(uri) .referrer(referrer) .flags(GeckoSession.LOAD_FLAGS_NONE)) - sessionRule.session.waitForPageStop() + mainSession.waitForPageStop() assertThat("Referrer should match", - sessionRule.session.evaluateJS("document.referrer") as String, + mainSession.evaluateJS("document.referrer") as String, equalTo(referrer)) } @@ -1866,13 +1866,13 @@ class NavigationDelegateTest : BaseSessionTest() { val uri = "https://example.com/bar" val referrer = "https://example.org/" - sessionRule.session.loadUri(referrer) - sessionRule.session.waitForPageStop() + mainSession.loadUri(referrer) + mainSession.waitForPageStop() val newSession = sessionRule.createOpenSession() newSession.load(Loader() .uri(uri) - .referrer(sessionRule.session) + .referrer(mainSession) .flags(GeckoSession.LOAD_FLAGS_NONE)) newSession.waitForPageStop() @@ -1888,13 +1888,13 @@ class NavigationDelegateTest : BaseSessionTest() { val uri = "file:///system/etc/fonts.xml" val referrer = "https://example.org" - sessionRule.session.loadUri(referrer) - sessionRule.session.waitForPageStop() + mainSession.loadUri(referrer) + mainSession.waitForPageStop() val newSession = sessionRule.createOpenSession() newSession.load(Loader() .uri(uri) - .referrer(sessionRule.session) + .referrer(mainSession) .flags(GeckoSession.LOAD_FLAGS_NONE)) newSession.waitUntilCalled(object : NavigationDelegate { @AssertCalled @@ -1908,10 +1908,10 @@ class NavigationDelegateTest : BaseSessionTest() { additional: Map, filter: Int = GeckoSession.HEADER_FILTER_CORS_SAFELISTED) { // First collect default headers with no override - sessionRule.session.loadUri("$TEST_ENDPOINT/anything") - sessionRule.session.waitForPageStop() + mainSession.loadUri("$TEST_ENDPOINT/anything") + mainSession.waitForPageStop() - val defaultContent = sessionRule.session.evaluateJS("document.body.children[0].innerHTML") as String + val defaultContent = mainSession.evaluateJS("document.body.children[0].innerHTML") as String val defaultBody = JSONObject(defaultContent) val defaultHeaders = defaultBody.getJSONObject("headers").asMap() @@ -1925,13 +1925,13 @@ class NavigationDelegateTest : BaseSessionTest() { } // Now load the page with the header override - sessionRule.session.load(Loader() + mainSession.load(Loader() .uri("$TEST_ENDPOINT/anything") .additionalHeaders(headers) .headerFilter(filter)) - sessionRule.session.waitForPageStop() + mainSession.waitForPageStop() - val content = sessionRule.session.evaluateJS("document.body.children[0].innerHTML") as String + val content = mainSession.evaluateJS("document.body.children[0].innerHTML") as String val body = JSONObject(content) val actualHeaders = body.getJSONObject("headers").asMap() @@ -1969,7 +1969,7 @@ class NavigationDelegateTest : BaseSessionTest() { Loader().uri("http://test-uri-equals.com") .flags(GeckoSession.LOAD_FLAGS_BYPASS_CLASSIFIER) .headerFilter(GeckoSession.HEADER_FILTER_UNRESTRICTED_UNSAFE) - .referrer(sessionRule.session), + .referrer(mainSession), Loader().uri("http://test-uri-equals.com") .flags(GeckoSession.LOAD_FLAGS_BYPASS_CLASSIFIER) .headerFilter(GeckoSession.HEADER_FILTER_UNRESTRICTED_UNSAFE) @@ -1977,13 +1977,13 @@ class NavigationDelegateTest : BaseSessionTest() { false) testLoaderEquals( - Loader().referrer(sessionRule.session) + Loader().referrer(mainSession) .data("testtest", "text/plain"), - Loader().referrer(sessionRule.session) + Loader().referrer(mainSession) .data("testtest", "text/plain"), true) testLoaderEquals( - Loader().referrer(sessionRule.session) + Loader().referrer(mainSession) .data("testtest", "text/plain"), Loader().referrer("test-referrer") .data("testtest", "text/plain"), @@ -2155,19 +2155,19 @@ class NavigationDelegateTest : BaseSessionTest() { // Disable popup blocker. sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(NEW_SESSION_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.delegateDuringNextWait(object : NavigationDelegate { + mainSession.delegateDuringNextWait(object : NavigationDelegate { @AssertCalled(count = 1) override fun onNewSession(session: GeckoSession, uri: String): GeckoResult { return GeckoResult.fromValue(sessionRule.createOpenSession()) } }) - sessionRule.session.evaluateJS("document.querySelector('#targetBlankLink').click()") + mainSession.evaluateJS("document.querySelector('#targetBlankLink').click()") - sessionRule.session.waitUntilCalled(NavigationDelegate::class, + mainSession.waitUntilCalled(NavigationDelegate::class, "onNewSession") UiThreadUtils.loopUntilIdle(sessionRule.env.defaultTimeoutMillis) } @@ -2255,7 +2255,7 @@ class NavigationDelegateTest : BaseSessionTest() { assertThat("URL should match", currentUrl!!, equalTo(url)) - sessionRule.session.goBack() + mainSession.goBack() sessionRule.waitForPageStop() assertThat("URL should match", currentUrl!!, endsWith(HELLO_HTML_PATH)) @@ -2263,12 +2263,12 @@ class NavigationDelegateTest : BaseSessionTest() { mainSession.active, equalTo(true)) - sessionRule.session.goBack() + mainSession.goBack() sessionRule.waitForPageStop() assertThat("URL should match", currentUrl!!, equalTo(url)) - sessionRule.session.goBack() + mainSession.goBack() sessionRule.waitForPageStop() assertThat("URL should match", currentUrl!!, endsWith(HELLO2_HTML_PATH)) @@ -2283,12 +2283,12 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") + mainSession.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") sessionRule.waitForPageStop() - sessionRule.session.evaluateJS("location.hash = 'test1';") + mainSession.evaluateJS("location.hash = 'test1';") - sessionRule.session.waitUntilCalled(object : NavigationDelegate { + mainSession.waitUntilCalled(object : NavigationDelegate { @AssertCalled(count = 0) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): @@ -2304,9 +2304,9 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.evaluateJS("location.hash = 'test2';") + mainSession.evaluateJS("location.hash = 'test2';") - sessionRule.session.waitUntilCalled(object : NavigationDelegate { + mainSession.waitUntilCalled(object : NavigationDelegate { @AssertCalled(count = 0) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): @@ -2328,7 +2328,7 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") + mainSession.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH") sessionRule.waitUntilCalled(object : NavigationDelegate { @AssertCalled(count = 1) override fun onCanGoBack(session: GeckoSession, canGoBack: Boolean) { @@ -2342,7 +2342,7 @@ class NavigationDelegateTest : BaseSessionTest() { assertThat("Cannot go forward", canGoForward, equalTo(false)) } }) - sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO2_HTML_PATH") + mainSession.loadUri("$TEST_ENDPOINT$HELLO2_HTML_PATH") sessionRule.waitUntilCalled(object : HistoryDelegate, NavigationDelegate { @AssertCalled(count = 1) override fun onCanGoBack(session: GeckoSession, canGoBack: Boolean) { @@ -2359,7 +2359,7 @@ class NavigationDelegateTest : BaseSessionTest() { assertThat("History should have two entries", state.size, equalTo(2)) } }) - sessionRule.session.purgeHistory() + mainSession.purgeHistory() sessionRule.waitUntilCalled(object : HistoryDelegate, NavigationDelegate { @AssertCalled(count = 1) override fun onHistoryStateChange(session: GeckoSession, state: HistoryDelegate.HistoryList) { @@ -2407,7 +2407,7 @@ class NavigationDelegateTest : BaseSessionTest() { // TODO: bug 1710943 assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false)) - sessionRule.session.delegateDuringNextWait(object : NavigationDelegate { + mainSession.delegateDuringNextWait(object : NavigationDelegate { @AssertCalled(count = 2) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { assertThat("URLs should match", request.uri, endsWith(forEachCall(HELLO_HTML_PATH, HELLO2_HTML_PATH))) @@ -2426,7 +2426,7 @@ class NavigationDelegateTest : BaseSessionTest() { val expectedUri = createDataUri(dataBytes, "*/*") val loader = Loader().data(dataBytes, "*/*") - sessionRule.session.delegateUntilTestEnd(object : NavigationDelegate { + mainSession.delegateUntilTestEnd(object : NavigationDelegate { @AssertCalled(count = 1, order = [1]) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { assertThat("URLs should match", request.uri, equalTo(expectedUri)) @@ -2445,7 +2445,7 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.load(loader) + mainSession.load(loader) sessionRule.waitUntilCalled(NavigationDelegate::class, "onLoadError") } @@ -2457,24 +2457,24 @@ class NavigationDelegateTest : BaseSessionTest() { val dataBytes = ByteArray(3 * 1024 * 1024) val dataUri = createDataUri(dataBytes, "*/*") - sessionRule.session.loadTestPath(DATA_URI_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(DATA_URI_PATH) + mainSession.waitForPageStop() - sessionRule.session.delegateUntilTestEnd(object : NavigationDelegate { + mainSession.delegateUntilTestEnd(object : NavigationDelegate { @AssertCalled(false) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { return GeckoResult.deny() } }) - sessionRule.session.evaluateJS("document.querySelector('#largeLink').href = \"$dataUri\"") - sessionRule.session.evaluateJS("document.querySelector('#largeLink').click()") - sessionRule.session.waitForPageStop() + mainSession.evaluateJS("document.querySelector('#largeLink').href = \"$dataUri\"") + mainSession.evaluateJS("document.querySelector('#largeLink').click()") + mainSession.waitForPageStop() } @Test fun loadShortDataUriToplevelIndirect() { - sessionRule.session.delegateUntilTestEnd(object : NavigationDelegate { + mainSession.delegateUntilTestEnd(object : NavigationDelegate { @AssertCalled(count = 2) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { return GeckoResult.allow() @@ -2490,12 +2490,12 @@ class NavigationDelegateTest : BaseSessionTest() { val dataBytes = this.getTestBytes("/assets/www/images/test.gif") val uri = createDataUri(dataBytes, "image/*") - sessionRule.session.loadTestPath(DATA_URI_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(DATA_URI_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("document.querySelector('#smallLink').href = \"$uri\"") - sessionRule.session.evaluateJS("document.querySelector('#smallLink').click()") - sessionRule.session.waitForPageStop() + mainSession.evaluateJS("document.querySelector('#smallLink').href = \"$uri\"") + mainSession.evaluateJS("document.querySelector('#smallLink').click()") + mainSession.waitForPageStop() } fun createLargeHighEntropyImageDataUri() : String { @@ -2525,7 +2525,7 @@ class NavigationDelegateTest : BaseSessionTest() { fun loadLongDataUriNonToplevel() { val dataUri = createLargeHighEntropyImageDataUri() - sessionRule.session.delegateUntilTestEnd(object : NavigationDelegate { + mainSession.delegateUntilTestEnd(object : NavigationDelegate { @AssertCalled(count = 1) override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult? { return GeckoResult.allow() @@ -2538,14 +2538,14 @@ class NavigationDelegateTest : BaseSessionTest() { } }) - sessionRule.session.loadTestPath(DATA_URI_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(DATA_URI_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("document.querySelector('#image').onload = () => { imageLoaded = true; }") - sessionRule.session.evaluateJS("document.querySelector('#image').src = \"$dataUri\"") + mainSession.evaluateJS("document.querySelector('#image').onload = () => { imageLoaded = true; }") + mainSession.evaluateJS("document.querySelector('#image').src = \"$dataUri\"") UiThreadUtils.waitForCondition({ - sessionRule.session.evaluateJS("document.querySelector('#image').complete") as Boolean + mainSession.evaluateJS("document.querySelector('#image').complete") as Boolean }, sessionRule.env.defaultTimeoutMillis) - sessionRule.session.evaluateJS("if (!imageLoaded) throw imageLoaded") + mainSession.evaluateJS("if (!imageLoaded) throw imageLoaded") } } diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PanZoomControllerTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PanZoomControllerTest.kt index 816b3d42d957..a9e7dbad9ff7 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PanZoomControllerTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PanZoomControllerTest.kt @@ -21,10 +21,10 @@ class PanZoomControllerTest : BaseSessionTest() { private val scrollWaitTimeout = 10000.0 // 10 seconds private fun setupDocument(documentPath: String) { - sessionRule.session.loadTestPath(documentPath) - sessionRule.session.waitForPageStop() - sessionRule.session.promiseAllPaintsDone() - sessionRule.session.flushApzRepaints() + mainSession.loadTestPath(documentPath) + mainSession.waitForPageStop() + mainSession.promiseAllPaintsDone() + mainSession.flushApzRepaints() } private fun setupScroll() { @@ -62,7 +62,7 @@ class PanZoomControllerTest : BaseSessionTest() { setupScroll() val vh = mainSession.evaluateJS("window.visualViewport.height") as Double assertThat("Visual viewport height is not zero", vh, greaterThan(0.0)) - sessionRule.session.panZoomController.scrollBy(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) + mainSession.panZoomController.scrollBy(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) waitForVerticalScroll(vh, scrollWaitTimeout) val scrollY = mainSession.evaluateJS("window.visualViewport.pageTop") as Double assertThat("scrollBy should have scrolled along y axis one viewport", scrollY, closeTo(vh, errorEpsilon)) @@ -73,7 +73,7 @@ class PanZoomControllerTest : BaseSessionTest() { setupScroll() val vw = mainSession.evaluateJS("window.visualViewport.width") as Double assertThat("Visual viewport width is not zero", vw, greaterThan(0.0)) - sessionRule.session.panZoomController.scrollBy(ScreenLength.fromVisualViewportWidth(1.0), ScreenLength.zero(), mode) + mainSession.panZoomController.scrollBy(ScreenLength.fromVisualViewportWidth(1.0), ScreenLength.zero(), mode) waitForHorizontalScroll(vw, scrollWaitTimeout) val scrollX = mainSession.evaluateJS("window.visualViewport.pageLeft") as Double assertThat("scrollBy should have scrolled along x axis one viewport", scrollX, closeTo(vw, errorEpsilon)) @@ -107,9 +107,9 @@ class PanZoomControllerTest : BaseSessionTest() { setupScroll() val vh = mainSession.evaluateJS("window.visualViewport.height") as Double assertThat("Visual viewport height is not zero", vh, greaterThan(0.0)) - sessionRule.session.panZoomController.scrollBy(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) + mainSession.panZoomController.scrollBy(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) waitForVerticalScroll(vh, scrollWaitTimeout) - sessionRule.session.panZoomController.scrollBy(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) + mainSession.panZoomController.scrollBy(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) waitForVerticalScroll(vh * 2.0, scrollWaitTimeout) val scrollY = mainSession.evaluateJS("window.visualViewport.pageTop") as Double assertThat("scrollBy should have scrolled along y axis one viewport", scrollY, closeTo(vh * 2.0, errorEpsilon)) @@ -131,7 +131,7 @@ class PanZoomControllerTest : BaseSessionTest() { setupScroll() val vh = mainSession.evaluateJS("window.visualViewport.height") as Double assertThat("Visual viewport height is not zero", vh, greaterThan(0.0)) - sessionRule.session.panZoomController.scrollTo(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) + mainSession.panZoomController.scrollTo(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) waitForVerticalScroll(vh, scrollWaitTimeout) val scrollY = mainSession.evaluateJS("window.visualViewport.pageTop") as Double assertThat("scrollBy should have scrolled along y axis one viewport", scrollY, closeTo(vh, errorEpsilon)) @@ -142,7 +142,7 @@ class PanZoomControllerTest : BaseSessionTest() { setupScroll() val vw = mainSession.evaluateJS("window.visualViewport.width") as Double assertThat("Visual viewport width is not zero", vw, greaterThan(0.0)) - sessionRule.session.panZoomController.scrollTo(ScreenLength.fromVisualViewportWidth(1.0), ScreenLength.zero(), mode) + mainSession.panZoomController.scrollTo(ScreenLength.fromVisualViewportWidth(1.0), ScreenLength.zero(), mode) waitForHorizontalScroll(vw, scrollWaitTimeout) val scrollX = mainSession.evaluateJS("window.visualViewport.pageLeft") as Double assertThat("scrollBy should have scrolled along x axis one viewport", scrollX, closeTo(vw, errorEpsilon)) @@ -193,7 +193,7 @@ class PanZoomControllerTest : BaseSessionTest() { val vh = mainSession.evaluateJS("window.visualViewport.height") as Double assertThat("Visual viewport height has been changed", vh, lessThan(originalVH)) - sessionRule.session.panZoomController.scrollTo(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) + mainSession.panZoomController.scrollTo(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) waitForVerticalScroll(vh, scrollWaitTimeout) val scrollY = mainSession.evaluateJS("window.visualViewport.pageTop") as Double @@ -216,9 +216,9 @@ class PanZoomControllerTest : BaseSessionTest() { setupScroll() val vh = mainSession.evaluateJS("window.visualViewport.height") as Double assertThat("Visual viewport height is not zero", vh, greaterThan(0.0)) - sessionRule.session.panZoomController.scrollTo(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) + mainSession.panZoomController.scrollTo(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) waitForVerticalScroll(vh, scrollWaitTimeout) - sessionRule.session.panZoomController.scrollTo(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) + mainSession.panZoomController.scrollTo(ScreenLength.zero(), ScreenLength.fromVisualViewportHeight(1.0), mode) waitForVerticalScroll(vh, scrollWaitTimeout) val scrollY = mainSession.evaluateJS("window.visualViewport.pageTop") as Double assertThat("scrollBy should have scrolled along y axis one viewport", scrollY, closeTo(vh, errorEpsilon)) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PrivateModeTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PrivateModeTest.kt index bef092693c96..071e5a198465 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PrivateModeTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PrivateModeTest.kt @@ -16,10 +16,10 @@ import org.mozilla.geckoview.GeckoSessionSettings class PrivateModeTest : BaseSessionTest() { @Test fun privateDataNotShared() { - sessionRule.session.loadUri("https://example.com") - sessionRule.session.waitForPageStop() + mainSession.loadUri("https://example.com") + mainSession.waitForPageStop() - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" localStorage.setItem('ctx', 'regular'); """) @@ -42,7 +42,7 @@ class PrivateModeTest : BaseSessionTest() { localStorage.setItem('ctx', 'private'); """) - localStorage = sessionRule.session.evaluateJS(""" + localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ProgressDelegateTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ProgressDelegateTest.kt index 07700932fab8..c39ea1972110 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ProgressDelegateTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ProgressDelegateTest.kt @@ -22,7 +22,7 @@ import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.* class ProgressDelegateTest : BaseSessionTest() { fun testProgress(path: String) { - sessionRule.session.loadTestPath(path) + mainSession.loadTestPath(path) sessionRule.waitForPageStop() var counter = 0 @@ -68,7 +68,7 @@ class ProgressDelegateTest : BaseSessionTest() { @Test fun load() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -98,8 +98,8 @@ class ProgressDelegateTest : BaseSessionTest() { @Ignore @Test fun multipleLoads() { - sessionRule.session.loadUri(UNKNOWN_HOST_URI) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadUri(UNKNOWN_HOST_URI) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStops(2) sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -120,10 +120,10 @@ class ProgressDelegateTest : BaseSessionTest() { } @Test fun reload() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.reload() + mainSession.reload() sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -145,12 +145,12 @@ class ProgressDelegateTest : BaseSessionTest() { } @Test fun goBackAndForward() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.loadTestPath(HELLO2_HTML_PATH) + mainSession.loadTestPath(HELLO2_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.goBack() + mainSession.goBack() sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -170,7 +170,7 @@ class ProgressDelegateTest : BaseSessionTest() { } }) - sessionRule.session.goForward() + mainSession.goForward() sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -194,7 +194,7 @@ class ProgressDelegateTest : BaseSessionTest() { @Test fun correctSecurityInfoForValidTLS_automation() { assumeThat(sessionRule.env.isAutomation, equalTo(true)) - sessionRule.session.loadUri("https://example.com") + mainSession.loadUri("https://example.com") sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -234,7 +234,7 @@ class ProgressDelegateTest : BaseSessionTest() { @Test fun correctSecurityInfoForValidTLS_local() { assumeThat(sessionRule.env.isAutomation, equalTo(false)) - sessionRule.session.loadUri("https://mozilla-modern.badssl.com") + mainSession.loadUri("https://mozilla-modern.badssl.com") sessionRule.waitForPageStop() sessionRule.forCallbacksDuringWait(object : ProgressDelegate { @@ -272,7 +272,7 @@ class ProgressDelegateTest : BaseSessionTest() { @LargeTest @Test fun noSecurityInfoForExpiredTLS() { - sessionRule.session.loadUri(if (sessionRule.env.isAutomation) + mainSession.loadUri(if (sessionRule.env.isAutomation) "https://expired.example.com" else "https://expired.badssl.com") @@ -454,7 +454,7 @@ class ProgressDelegateTest : BaseSessionTest() { @Test fun noHistoryDelegateOnSessionStateChange() { // TODO: Bug 1648158 assumeThat(sessionRule.env.isFission, equalTo(false)) - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.waitUntilCalled(object : ProgressDelegate { diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PromptDelegateTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PromptDelegateTest.kt index 05e9109768db..20b65bcbc7ac 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PromptDelegateTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/PromptDelegateTest.kt @@ -55,7 +55,7 @@ class PromptDelegateTest : BaseSessionTest() { } }) - sessionRule.session.loadTestPath(POPUP_HTML_PATH) + mainSession.loadTestPath(POPUP_HTML_PATH) sessionRule.waitUntilCalled(NavigationDelegate::class, "onNewSession") } @@ -88,14 +88,14 @@ class PromptDelegateTest : BaseSessionTest() { } }) - sessionRule.session.loadTestPath(POPUP_HTML_PATH) + mainSession.loadTestPath(POPUP_HTML_PATH) sessionRule.waitForPageStop() - sessionRule.session.waitForRoundTrip() + mainSession.waitForRoundTrip() } @Ignore // TODO: Reenable when 1501574 is fixed. @Test fun alertTest() { - sessionRule.session.evaluateJS("alert('Alert!');") + mainSession.evaluateJS("alert('Alert!');") sessionRule.waitUntilCalled(object : PromptDelegate { @AssertCalled(count = 1) @@ -205,7 +205,7 @@ class PromptDelegateTest : BaseSessionTest() { } @Test fun buttonTest() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() sessionRule.delegateDuringNextWait(object : PromptDelegate { @@ -217,7 +217,7 @@ class PromptDelegateTest : BaseSessionTest() { }) assertThat("Result should match", - sessionRule.session.waitForJS("confirm('Confirm?')") as Boolean, + mainSession.waitForJS("confirm('Confirm?')") as Boolean, equalTo(true)) sessionRule.delegateDuringNextWait(object : PromptDelegate { @@ -229,16 +229,16 @@ class PromptDelegateTest : BaseSessionTest() { }) assertThat("Result should match", - sessionRule.session.waitForJS("confirm('Confirm?')") as Boolean, + mainSession.waitForJS("confirm('Confirm?')") as Boolean, equalTo(false)) } @Test fun onFormResubmissionPrompt() { - sessionRule.session.loadTestPath(RESUBMIT_CONFIRM) + mainSession.loadTestPath(RESUBMIT_CONFIRM) sessionRule.waitForPageStop() - sessionRule.session.evaluateJS( + mainSession.evaluateJS( "document.querySelector('#text').value = 'Some text';" + "document.querySelector('#submit').click();" ) @@ -267,7 +267,7 @@ class PromptDelegateTest : BaseSessionTest() { }) // This should trigger a confirm resubmit prompt - sessionRule.session.reload(); + mainSession.reload(); sessionRule.waitUntilCalled(object : PromptDelegate { @AssertCalled(count = 1) @@ -280,7 +280,7 @@ class PromptDelegateTest : BaseSessionTest() { sessionRule.waitForResult(promptResult) // Trigger it again, this time the load should go through - sessionRule.session.reload(); + mainSession.reload(); sessionRule.waitUntilCalled(object : PromptDelegate { @AssertCalled(count = 1) override fun onRepostConfirmPrompt(session: GeckoSession, prompt: PromptDelegate.RepostConfirmPrompt): GeckoResult? { @@ -298,7 +298,7 @@ class PromptDelegateTest : BaseSessionTest() { sessionRule.setPrefsUntilTestEnd(mapOf( "dom.require_user_interaction_for_beforeunload" to false )) - sessionRule.session.loadTestPath(BEFORE_UNLOAD) + mainSession.loadTestPath(BEFORE_UNLOAD) sessionRule.waitForPageStop() val result = GeckoResult() @@ -323,7 +323,7 @@ class PromptDelegateTest : BaseSessionTest() { // This will try to load "hello.html" but will be denied, if the request // goes through anyway the onLoadRequest delegate above will throw an exception - sessionRule.session.evaluateJS("document.querySelector('#navigateAway').click()") + mainSession.evaluateJS("document.querySelector('#navigateAway').click()") sessionRule.waitUntilCalled(object : PromptDelegate { @AssertCalled(count = 1) override fun onBeforeUnloadPrompt(session: GeckoSession, prompt: PromptDelegate.BeforeUnloadPrompt): GeckoResult? { @@ -336,7 +336,7 @@ class PromptDelegateTest : BaseSessionTest() { // This request will go through and end the test. Doing the negative case first will // ensure that if either of this tests fail the test will fail. - sessionRule.session.evaluateJS("document.querySelector('#navigateAway2').click()") + mainSession.evaluateJS("document.querySelector('#navigateAway2').click()") sessionRule.waitUntilCalled(object : PromptDelegate { @AssertCalled(count = 1) override fun onBeforeUnloadPrompt(session: GeckoSession, prompt: PromptDelegate.BeforeUnloadPrompt): GeckoResult? { @@ -350,8 +350,8 @@ class PromptDelegateTest : BaseSessionTest() { } @Test fun textTest() { - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.waitForPageStop() sessionRule.delegateUntilTestEnd(object : PromptDelegate { @AssertCalled(count = 1) @@ -363,7 +363,7 @@ class PromptDelegateTest : BaseSessionTest() { }) assertThat("Result should match", - sessionRule.session.waitForJS("prompt('Prompt:', 'default')") as String, + mainSession.waitForJS("prompt('Prompt:', 'default')") as String, equalTo("foo")) } @@ -371,10 +371,10 @@ class PromptDelegateTest : BaseSessionTest() { @Test fun choiceTest() { sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(PROMPT_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(PROMPT_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("document.getElementById('selectexample').click();") + mainSession.evaluateJS("document.getElementById('selectexample').click();") sessionRule.waitUntilCalled(object : PromptDelegate { @AssertCalled(count = 1) @@ -387,8 +387,8 @@ class PromptDelegateTest : BaseSessionTest() { @Test fun colorTest() { sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(PROMPT_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(PROMPT_HTML_PATH) + mainSession.waitForPageStop() sessionRule.delegateDuringNextWait(object : PromptDelegate { @AssertCalled(count = 1) @@ -398,11 +398,11 @@ class PromptDelegateTest : BaseSessionTest() { } }) - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" this.c = document.getElementById('colorexample'); """.trimIndent()) - val promise = sessionRule.session.evaluatePromiseJS(""" + val promise = mainSession.evaluatePromiseJS(""" new Promise((resolve, reject) => { this.c.addEventListener( 'change', @@ -411,7 +411,7 @@ class PromptDelegateTest : BaseSessionTest() { ); })""".trimIndent()) - sessionRule.session.evaluateJS("this.c.click();") + mainSession.evaluateJS("this.c.click();") assertThat("Value should match", promise.value as String, @@ -422,10 +422,10 @@ class PromptDelegateTest : BaseSessionTest() { @Test fun dateTest() { sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(PROMPT_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(PROMPT_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("document.getElementById('dateexample').click();") + mainSession.evaluateJS("document.getElementById('dateexample').click();") sessionRule.waitUntilCalled(object : PromptDelegate { @AssertCalled(count = 1) @@ -438,10 +438,10 @@ class PromptDelegateTest : BaseSessionTest() { @Test fun fileTest() { sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false)) - sessionRule.session.loadTestPath(PROMPT_HTML_PATH) - sessionRule.session.waitForPageStop() + mainSession.loadTestPath(PROMPT_HTML_PATH) + mainSession.waitForPageStop() - sessionRule.session.evaluateJS("document.getElementById('fileexample').click();") + mainSession.evaluateJS("document.getElementById('fileexample').click();") sessionRule.waitUntilCalled(object : PromptDelegate { @AssertCalled(count = 1) diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/RuntimeSettingsTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/RuntimeSettingsTest.kt index 833601b857dc..05a86e13e58b 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/RuntimeSettingsTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/RuntimeSettingsTest.kt @@ -81,25 +81,25 @@ class RuntimeSettingsTest : BaseSessionTest() { @Test fun fontSize() { val settings = sessionRule.runtime.settings settings.fontSizeFactor = 1.0f - sessionRule.session.loadTestPath(HELLO_HTML_PATH) + mainSession.loadTestPath(HELLO_HTML_PATH) sessionRule.waitForPageStop() val fontSizeJs = "parseFloat(window.getComputedStyle(document.querySelector('p')).fontSize)" - val initialFontSize = sessionRule.session.evaluateJS(fontSizeJs) as Double + val initialFontSize = mainSession.evaluateJS(fontSizeJs) as Double val textSizeFactor = 2.0f settings.fontSizeFactor = textSizeFactor - sessionRule.session.reload() + mainSession.reload() sessionRule.waitForPageStop() - var fontSize = sessionRule.session.evaluateJS(fontSizeJs) as Double + var fontSize = mainSession.evaluateJS(fontSizeJs) as Double val expectedFontSize = initialFontSize * textSizeFactor assertThat("old text size ${initialFontSize}px, new size should be ${expectedFontSize}px", fontSize, closeTo(expectedFontSize, 0.1)) settings.fontSizeFactor = 1.0f - sessionRule.session.reload() + mainSession.reload() sessionRule.waitForPageStop() - fontSize = sessionRule.session.evaluateJS(fontSizeJs) as Double + fontSize = mainSession.evaluateJS(fontSizeJs) as Double assertThat("text size should be ${initialFontSize}px again", fontSize, closeTo(initialFontSize, 0.1)) } diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ScreenshotTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ScreenshotTest.kt index fc85d9585feb..60001a72e9dc 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ScreenshotTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ScreenshotTest.kt @@ -94,7 +94,7 @@ class ScreenshotTest : BaseSessionTest() { fun capturePixelsSucceeds() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -111,7 +111,7 @@ class ScreenshotTest : BaseSessionTest() { fun capturePixelsCanBeCalledMultipleTimes() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -207,14 +207,14 @@ class ScreenshotTest : BaseSessionTest() { assumeThat(sessionRule.env.isFission, equalTo(false)) val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { } }) - sessionRule.session.setActive(false) + mainSession.setActive(false) // Deactivating the session should trigger a flush state change sessionRule.waitUntilCalled(object : ProgressDelegate { @@ -233,7 +233,7 @@ class ScreenshotTest : BaseSessionTest() { fun screenshotToBitmap() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -250,7 +250,7 @@ class ScreenshotTest : BaseSessionTest() { fun screenshotScaledToSize() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH/2, SCREEN_HEIGHT/2) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -267,7 +267,7 @@ class ScreenshotTest : BaseSessionTest() { fun screenShotScaledWithScale() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH/2, SCREEN_HEIGHT/2) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -284,7 +284,7 @@ class ScreenshotTest : BaseSessionTest() { fun screenShotScaledWithAspectPreservingSize() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH/2, SCREEN_HEIGHT/2) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -301,7 +301,7 @@ class ScreenshotTest : BaseSessionTest() { fun recycleBitmap() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -323,7 +323,7 @@ class ScreenshotTest : BaseSessionTest() { fun screenshotWholeRegion() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -340,7 +340,7 @@ class ScreenshotTest : BaseSessionTest() { fun screenshotWholeRegionScaled() { val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH/2, SCREEN_HEIGHT/2) - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -359,7 +359,7 @@ class ScreenshotTest : BaseSessionTest() { @Test fun screenshotQuarters() { val res = InstrumentationRegistry.getInstrumentation().targetContext.resources - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -382,7 +382,7 @@ class ScreenshotTest : BaseSessionTest() { @Test fun screenshotQuartersScaled() { val res = InstrumentationRegistry.getInstrumentation().targetContext.resources - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { @@ -406,7 +406,7 @@ class ScreenshotTest : BaseSessionTest() { @WithDisplay(height = BIG_SCREEN_HEIGHT, width = BIG_SCREEN_WIDTH) @Test fun giantScreenshot() { - sessionRule.session.loadTestPath(COLORS_HTML_PATH) + mainSession.loadTestPath(COLORS_HTML_PATH) sessionRule.display?.screenshot()!!.source(0,0, BIG_SCREEN_WIDTH, BIG_SCREEN_HEIGHT) .size(BIG_SCREEN_WIDTH, BIG_SCREEN_HEIGHT) .capture() diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/SessionLifecycleTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/SessionLifecycleTest.kt index 8ceb0d26813b..4c78ca82f9cd 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/SessionLifecycleTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/SessionLifecycleTest.kt @@ -35,33 +35,33 @@ class SessionLifecycleTest : BaseSessionTest() { session2.close() session3.close() - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() } @Test fun open_repeated() { for (i in 1..5) { - sessionRule.session.close() - sessionRule.session.open() + mainSession.close() + mainSession.open() } - sessionRule.session.reload() - sessionRule.session.waitForPageStop() + mainSession.reload() + mainSession.waitForPageStop() } @Test fun open_allowCallsWhileClosed() { - sessionRule.session.close() + mainSession.close() - sessionRule.session.loadTestPath(HELLO_HTML_PATH) - sessionRule.session.reload() + mainSession.loadTestPath(HELLO_HTML_PATH) + mainSession.reload() - sessionRule.session.open() - sessionRule.session.waitForPageStops(2) + mainSession.open() + mainSession.waitForPageStops(2) } @Test(expected = IllegalStateException::class) fun open_throwOnAlreadyOpen() { // Throw exception if retrying to open again; otherwise we would leak the old open window. - sessionRule.session.open() + mainSession.open() } @ClosedSessionAtStart diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/StorageControllerTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/StorageControllerTest.kt index 1dc91bc28efe..429e42d1f7be 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/StorageControllerTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/StorageControllerTest.kt @@ -19,19 +19,19 @@ import org.junit.runner.RunWith class StorageControllerTest : BaseSessionTest() { @Test fun clearData() { - sessionRule.session.loadUri("https://example.com") + mainSession.loadUri("https://example.com") sessionRule.waitForPageStop() - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" localStorage.setItem('ctx', 'test'); document.cookie = 'ctx=test'; """) - var localStorage = sessionRule.session.evaluateJS(""" + var localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - var cookie = sessionRule.session.evaluateJS(""" + var cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -46,11 +46,11 @@ class StorageControllerTest : BaseSessionTest() { sessionRule.runtime.storageController.clearData( StorageController.ClearFlags.ALL)) - localStorage = sessionRule.session.evaluateJS(""" + localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - cookie = sessionRule.session.evaluateJS(""" + cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -63,19 +63,19 @@ class StorageControllerTest : BaseSessionTest() { } @Test fun clearDataFlags() { - sessionRule.session.loadUri("https://example.com") + mainSession.loadUri("https://example.com") sessionRule.waitForPageStop() - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" localStorage.setItem('ctx', 'test'); document.cookie = 'ctx=test'; """) - var localStorage = sessionRule.session.evaluateJS(""" + var localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - var cookie = sessionRule.session.evaluateJS(""" + var cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -90,11 +90,11 @@ class StorageControllerTest : BaseSessionTest() { sessionRule.runtime.storageController.clearData( StorageController.ClearFlags.COOKIES)) - localStorage = sessionRule.session.evaluateJS(""" + localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - cookie = sessionRule.session.evaluateJS(""" + cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -114,7 +114,7 @@ class StorageControllerTest : BaseSessionTest() { cookie, equalTo("null")) - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" document.cookie = 'ctx=test'; """) @@ -122,11 +122,11 @@ class StorageControllerTest : BaseSessionTest() { sessionRule.runtime.storageController.clearData( StorageController.ClearFlags.DOM_STORAGES)) - localStorage = sessionRule.session.evaluateJS(""" + localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - cookie = sessionRule.session.evaluateJS(""" + cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -137,7 +137,7 @@ class StorageControllerTest : BaseSessionTest() { cookie, equalTo("ctx=test")) - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" localStorage.setItem('ctx', 'test'); """) @@ -145,11 +145,11 @@ class StorageControllerTest : BaseSessionTest() { sessionRule.runtime.storageController.clearData( StorageController.ClearFlags.SITE_DATA)) - localStorage = sessionRule.session.evaluateJS(""" + localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - cookie = sessionRule.session.evaluateJS(""" + cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -162,19 +162,19 @@ class StorageControllerTest : BaseSessionTest() { } @Test fun clearDataFromHost() { - sessionRule.session.loadUri("https://example.com") + mainSession.loadUri("https://example.com") sessionRule.waitForPageStop() - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" localStorage.setItem('ctx', 'test'); document.cookie = 'ctx=test'; """) - var localStorage = sessionRule.session.evaluateJS(""" + var localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - var cookie = sessionRule.session.evaluateJS(""" + var cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -190,11 +190,11 @@ class StorageControllerTest : BaseSessionTest() { "test.com", StorageController.ClearFlags.ALL)) - localStorage = sessionRule.session.evaluateJS(""" + localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - cookie = sessionRule.session.evaluateJS(""" + cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -210,11 +210,11 @@ class StorageControllerTest : BaseSessionTest() { "example.com", StorageController.ClearFlags.ALL)) - localStorage = sessionRule.session.evaluateJS(""" + localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - cookie = sessionRule.session.evaluateJS(""" + cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -231,19 +231,19 @@ class StorageControllerTest : BaseSessionTest() { // Set site data for both root domain and subdomain. for(domain in domains) { - sessionRule.session.loadUri("https://" + domain) + mainSession.loadUri("https://" + domain) sessionRule.waitForPageStop() - sessionRule.session.evaluateJS(""" + mainSession.evaluateJS(""" localStorage.setItem('ctx', 'test'); document.cookie = 'ctx=test'; """) - var localStorage = sessionRule.session.evaluateJS(""" + var localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - var cookie = sessionRule.session.evaluateJS(""" + var cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -263,14 +263,14 @@ class StorageControllerTest : BaseSessionTest() { StorageController.ClearFlags.ALL)) for(domain in domains) { - sessionRule.session.loadUri("https://" + domain) + mainSession.loadUri("https://" + domain) sessionRule.waitForPageStop() - var localStorage = sessionRule.session.evaluateJS(""" + var localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - var cookie = sessionRule.session.evaluateJS(""" + var cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String @@ -290,14 +290,14 @@ class StorageControllerTest : BaseSessionTest() { StorageController.ClearFlags.ALL)) for(domain in domains) { - sessionRule.session.loadUri("https://" + domain) + mainSession.loadUri("https://" + domain) sessionRule.waitForPageStop() - var localStorage = sessionRule.session.evaluateJS(""" + var localStorage = mainSession.evaluateJS(""" localStorage.getItem('ctx') || 'null' """) as String - var cookie = sessionRule.session.evaluateJS(""" + var cookie = mainSession.evaluateJS(""" document.cookie || 'null' """) as String diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/VerticalClippingTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/VerticalClippingTest.kt index 504d71f4271e..668b2532e5a3 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/VerticalClippingTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/VerticalClippingTest.kt @@ -66,7 +66,7 @@ class VerticalClippingTest : BaseSessionTest() { // Disable failing test on Webrender. Bug 1670267 assumeThat(sessionRule.env.isWebrender, equalTo(false)) sessionRule.display?.setVerticalClipping(45) - sessionRule.session.loadTestPath(FIXED_BOTTOM) + mainSession.loadTestPath(FIXED_BOTTOM) sessionRule.waitUntilCalled(object : ContentDelegate { @AssertCalled(count = 1) override fun onFirstContentfulPaint(session: GeckoSession) { diff --git 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 index 2bfb46d45305..6b011d641273 100644 --- 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 @@ -650,7 +650,7 @@ class WebExtensionTest : BaseSessionTest() { tabsExtension.tabDelegate = object : WebExtension.TabDelegate { override fun onNewTab(source: WebExtension, details: WebExtension.CreateTabDetails): GeckoResult { - val extensionCreatedSession = sessionRule.createClosedSession(sessionRule.session.settings) + val extensionCreatedSession = sessionRule.createClosedSession(mainSession.settings) extensionCreatedSession.webExtensionController.setTabDelegate(tabsExtension, object : WebExtension.SessionTabDelegate { override fun onCloseTab(source: WebExtension?, session: GeckoSession): GeckoResult { @@ -688,7 +688,7 @@ class WebExtensionTest : BaseSessionTest() { val onCloseRequestResult = GeckoResult() val tabsExtension = sessionRule.waitForResult( controller.installBuiltIn(TABS_ACTIVATE_REMOVE_BACKGROUND)) - val newTabSession = sessionRule.createOpenSession(sessionRule.session.settings) + val newTabSession = sessionRule.createOpenSession(mainSession.settings) sessionRule.addExternalDelegateUntilTestEnd( WebExtension.SessionTabDelegate::class, @@ -704,7 +704,7 @@ class WebExtensionTest : BaseSessionTest() { } }) - controller.setTabActive(sessionRule.session, false) + controller.setTabActive(mainSession, false) controller.setTabActive(newTabSession, true) sessionRule.waitForResult(onCloseRequestResult) @@ -1051,7 +1051,7 @@ class WebExtensionTest : BaseSessionTest() { controller.setAllowedInPrivateBrowsing(tabsExtensionPB, true)) - val newTabSession = sessionRule.createOpenSession(sessionRule.session.settings) + val newTabSession = sessionRule.createOpenSession(mainSession.settings) val newPrivateSession = sessionRule.createOpenSession( GeckoSessionSettings.Builder().usePrivateMode(true).build()) @@ -1092,7 +1092,7 @@ class WebExtensionTest : BaseSessionTest() { } }) - controller.setTabActive(sessionRule.session, false) + controller.setTabActive(mainSession, false) controller.setTabActive(newPrivateSession, true) sessionRule.waitForResult(privateBrowsingPrivateSession) @@ -1176,7 +1176,7 @@ class WebExtensionTest : BaseSessionTest() { val extension = sessionRule.waitForResult( controller.installBuiltIn(EXTENSION_PAGE_RESTORE)) - sessionRule.session.loadUri("${extension.metaData.baseUrl}tab.html") + mainSession.loadUri("${extension.metaData.baseUrl}tab.html") sessionRule.waitForPageStop() var savedState : GeckoSession.SessionState? = null @@ -1188,7 +1188,7 @@ class WebExtensionTest : BaseSessionTest() { }) // Test that messages are received in the main session - testExtensionMessages(extension, sessionRule.session) + testExtensionMessages(extension, mainSession) val newSession = sessionRule.createOpenSession() newSession.restoreState(savedState!!) @@ -1246,7 +1246,7 @@ class WebExtensionTest : BaseSessionTest() { } else { webExtension = sessionRule.waitForResult( controller.installBuiltIn(MESSAGING_CONTENT)) - sessionRule.session.webExtensionController + mainSession.webExtensionController .setMessageDelegate(webExtension, messageDelegate, "browser") } @@ -1376,7 +1376,7 @@ class WebExtensionTest : BaseSessionTest() { if (refresh) { // Refreshing the page should disconnect the port - sessionRule.session.reload() + mainSession.reload() } else { // Let's ask the web extension to disconnect this port val message = JSONObject() @@ -1544,7 +1544,7 @@ class WebExtensionTest : BaseSessionTest() { messaging = sessionRule.waitForResult(controller.installBuiltIn( "resource://android/assets/web_extensions/messaging-iframe/")) - sessionRule.session.webExtensionController + mainSession.webExtensionController .setMessageDelegate(messaging, messageDelegate, "browser") sessionRule.waitForResult(portTopLevel) sessionRule.waitForResult(portIframe)