richard pushed to branch firefox-android-115.2.1-13.5-1 at The Tor Project / Applications / firefox-android

Commits:

9 changed files:

Changes:

  • android-components/components/browser/state/src/main/java/mozilla/components/browser/state/action/BrowserAction.kt
    ... ... @@ -959,6 +959,7 @@ sealed class EngineAction : BrowserAction() {
    959 959
             override val tabId: String,
    
    960 960
             val skipLoading: Boolean = false,
    
    961 961
             val followupAction: BrowserAction? = null,
    
    962
    +        val includeParent: Boolean = false,
    
    962 963
         ) : EngineAction(), ActionWithTab
    
    963 964
     
    
    964 965
         /**
    
    ... ... @@ -969,6 +970,7 @@ sealed class EngineAction : BrowserAction() {
    969 970
             val url: String,
    
    970 971
             val flags: EngineSession.LoadUrlFlags = EngineSession.LoadUrlFlags.none(),
    
    971 972
             val additionalHeaders: Map<String, String>? = null,
    
    973
    +        val includeParent: Boolean = false,
    
    972 974
         ) : EngineAction(), ActionWithTab
    
    973 975
     
    
    974 976
         /**
    
    ... ... @@ -1075,6 +1077,7 @@ sealed class EngineAction : BrowserAction() {
    1075 1077
             val engineSession: EngineSession,
    
    1076 1078
             val timestamp: Long = Clock.elapsedRealtime(),
    
    1077 1079
             val skipLoading: Boolean = false,
    
    1080
    +        val includeParent: Boolean = false,
    
    1078 1081
         ) : EngineAction(), ActionWithTab
    
    1079 1082
     
    
    1080 1083
         /**
    

  • android-components/components/browser/state/src/main/java/mozilla/components/browser/state/engine/middleware/CreateEngineSessionMiddleware.kt
    ... ... @@ -68,6 +68,7 @@ internal class CreateEngineSessionMiddleware(
    68 68
                     logger,
    
    69 69
                     store,
    
    70 70
                     action.tabId,
    
    71
    +                action.includeParent,
    
    71 72
                 )
    
    72 73
     
    
    73 74
                 action.followupAction?.let {
    
    ... ... @@ -84,6 +85,7 @@ private fun getOrCreateEngineSession(
    84 85
         logger: Logger,
    
    85 86
         store: Store<BrowserState, BrowserAction>,
    
    86 87
         tabId: String,
    
    88
    +    includeParent: Boolean,
    
    87 89
     ): EngineSession? {
    
    88 90
         val tab = store.state.findTabOrCustomTab(tabId)
    
    89 91
         if (tab == null) {
    
    ... ... @@ -101,7 +103,7 @@ private fun getOrCreateEngineSession(
    101 103
             return it
    
    102 104
         }
    
    103 105
     
    
    104
    -    return createEngineSession(engine, logger, store, tab)
    
    106
    +    return createEngineSession(engine, logger, store, tab, includeParent)
    
    105 107
     }
    
    106 108
     
    
    107 109
     @MainThread
    
    ... ... @@ -110,6 +112,7 @@ private fun createEngineSession(
    110 112
         logger: Logger,
    
    111 113
         store: Store<BrowserState, BrowserAction>,
    
    112 114
         tab: SessionState,
    
    115
    +    includeParent: Boolean,
    
    113 116
     ): EngineSession {
    
    114 117
         val engineSession = engine.createSession(tab.content.private, tab.contextId)
    
    115 118
         logger.debug("Created engine session for tab ${tab.id}")
    
    ... ... @@ -126,6 +129,7 @@ private fun createEngineSession(
    126 129
                 tab.id,
    
    127 130
                 engineSession,
    
    128 131
                 skipLoading = skipLoading,
    
    132
    +            includeParent = includeParent,
    
    129 133
             ),
    
    130 134
         )
    
    131 135
     
    

  • android-components/components/browser/state/src/main/java/mozilla/components/browser/state/engine/middleware/EngineDelegateMiddleware.kt
    ... ... @@ -60,11 +60,11 @@ internal class EngineDelegateMiddleware(
    60 60
                 // session is already pointing to. Creating an EngineSession will do exactly
    
    61 61
                 // that in the linking step. So let's do that. Otherwise we would load the URL
    
    62 62
                 // twice.
    
    63
    -            store.dispatch(EngineAction.CreateEngineSessionAction(action.tabId))
    
    63
    +            store.dispatch(EngineAction.CreateEngineSessionAction(action.tabId, includeParent = action.includeParent))
    
    64 64
                 return@launch
    
    65 65
             }
    
    66 66
     
    
    67
    -        val parentEngineSession = if (tab is TabSessionState) {
    
    67
    +        val parentEngineSession = if (action.includeParent && tab is TabSessionState) {
    
    68 68
                 tab.parentId?.let { store.state.findTabOrCustomTab(it)?.engineState?.engineSession }
    
    69 69
             } else {
    
    70 70
                 null
    

  • android-components/components/browser/state/src/main/java/mozilla/components/browser/state/engine/middleware/LinkingMiddleware.kt
    ... ... @@ -37,7 +37,13 @@ internal class LinkingMiddleware(
    37 37
             when (action) {
    
    38 38
                 is TabListAction.AddTabAction -> {
    
    39 39
                     if (action.tab.engineState.engineSession != null && action.tab.engineState.engineObserver == null) {
    
    40
    -                    engineObserver = link(context, action.tab.engineState.engineSession, action.tab)
    
    40
    +                    engineObserver = link(
    
    41
    +                        context,
    
    42
    +                        action.tab.engineState.engineSession,
    
    43
    +                        action.tab,
    
    44
    +                        skipLoading = true,
    
    45
    +                        includeParent = false,
    
    46
    +                    )
    
    41 47
                     }
    
    42 48
                 }
    
    43 49
                 is TabListAction.AddMultipleTabsAction -> {
    
    ... ... @@ -58,7 +64,7 @@ internal class LinkingMiddleware(
    58 64
             when (action) {
    
    59 65
                 is EngineAction.LinkEngineSessionAction -> {
    
    60 66
                     context.state.findTabOrCustomTab(action.tabId)?.let { tab ->
    
    61
    -                    engineObserver = link(context, action.engineSession, tab, action.skipLoading)
    
    67
    +                    engineObserver = link(context, action.engineSession, tab, action.skipLoading, action.includeParent)
    
    62 68
                     }
    
    63 69
                 }
    
    64 70
                 else -> {
    
    ... ... @@ -77,6 +83,7 @@ internal class LinkingMiddleware(
    77 83
             engineSession: EngineSession,
    
    78 84
             tab: SessionState,
    
    79 85
             skipLoading: Boolean = true,
    
    86
    +        includeParent: Boolean,
    
    80 87
         ): Pair<String, EngineObserver> {
    
    81 88
             val observer = EngineObserver(tab.id, context.store)
    
    82 89
             engineSession.register(observer)
    
    ... ... @@ -91,7 +98,7 @@ internal class LinkingMiddleware(
    91 98
                 // tab, but opened by an extension e.g. via browser.tabs.update.
    
    92 99
                 performLoadOnMainThread(engineSession, tab.content.url, loadFlags = tab.engineState.initialLoadFlags)
    
    93 100
             } else {
    
    94
    -            val parentEngineSession = if (tab is TabSessionState) {
    
    101
    +            val parentEngineSession = if (includeParent && tab is TabSessionState) {
    
    95 102
                     tab.parentId?.let { context.state.findTabOrCustomTab(it)?.engineState?.engineSession }
    
    96 103
                 } else {
    
    97 104
                     null
    

  • android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/EngineDelegateMiddlewareTest.kt
    ... ... @@ -258,6 +258,7 @@ class EngineDelegateMiddlewareTest {
    258 258
                 EngineAction.LoadUrlAction(
    
    259 259
                     "test-tab",
    
    260 260
                     "https://www.firefox.com",
    
    261
    +                includeParent = true,
    
    261 262
                 ),
    
    262 263
             ).joinBlocking()
    
    263 264
     
    

  • android-components/components/browser/state/src/test/java/mozilla/components/browser/state/engine/middleware/LinkingMiddlewareTest.kt
    ... ... @@ -91,7 +91,9 @@ class LinkingMiddlewareTest {
    91 91
             store.dispatch(EngineAction.LinkEngineSessionAction(parent.id, parentEngineSession)).joinBlocking()
    
    92 92
     
    
    93 93
             val childEngineSession: EngineSession = mock()
    
    94
    -        store.dispatch(EngineAction.LinkEngineSessionAction(child.id, childEngineSession)).joinBlocking()
    
    94
    +        store.dispatch(
    
    95
    +            EngineAction.LinkEngineSessionAction(child.id, childEngineSession, includeParent = true),
    
    96
    +        ).joinBlocking()
    
    95 97
     
    
    96 98
             dispatcher.scheduler.advanceUntilIdle()
    
    97 99
     
    

  • android-components/components/feature/session/src/main/java/mozilla/components/feature/session/SessionUseCases.kt
    ... ... @@ -86,14 +86,8 @@ class SessionUseCases(
    86 86
                 // If we already have an engine session load Url directly to prevent
    
    87 87
                 // context switches.
    
    88 88
                 if (engineSession != null) {
    
    89
    -                val parentEngineSession = if (tab is TabSessionState) {
    
    90
    -                    tab.parentId?.let { store.state.findTabOrCustomTab(it)?.engineState?.engineSession }
    
    91
    -                } else {
    
    92
    -                    null
    
    93
    -                }
    
    94 89
                     engineSession.loadUrl(
    
    95 90
                         url = url,
    
    96
    -                    parent = parentEngineSession,
    
    97 91
                         flags = flags,
    
    98 92
                         additionalHeaders = additionalHeaders,
    
    99 93
                     )
    

  • android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SessionUseCasesTest.kt
    ... ... @@ -128,7 +128,6 @@ class SessionUseCasesTest {
    128 128
             middleware.assertNotDispatched(EngineAction.LoadUrlAction::class)
    
    129 129
             verify(childEngineSession).loadUrl(
    
    130 130
                 url = "https://www.mozilla.org/en-CA/firefox/browsers/mobile/",
    
    131
    -            parent = engineSession,
    
    132 131
             )
    
    133 132
             middleware.assertLastAction(EngineAction.OptimizedLoadUrlTriggeredAction::class) { action ->
    
    134 133
                 assertEquals("bugzilla", action.tabId)
    

  • android-components/components/feature/tabs/src/main/java/mozilla/components/feature/tabs/TabsUseCases.kt
    ... ... @@ -189,6 +189,7 @@ class TabsUseCases(
    189 189
                             tab.id,
    
    190 190
                             url,
    
    191 191
                             flags,
    
    192
    +                        includeParent = true,
    
    192 193
                         ),
    
    193 194
                     )
    
    194 195
                 }
    
    ... ... @@ -259,6 +260,7 @@ class TabsUseCases(
    259 260
                             tab.id,
    
    260 261
                             url,
    
    261 262
                             flags,
    
    263
    +                        includeParent = true,
    
    262 264
                         ),
    
    263 265
                     )
    
    264 266
                 }
    
    ... ... @@ -477,6 +479,7 @@ class TabsUseCases(
    477 479
                             tab.id,
    
    478 480
                             url,
    
    479 481
                             flags,
    
    482
    +                        includeParent = true,
    
    480 483
                         ),
    
    481 484
                     )
    
    482 485
                     tab.id