Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1469,9 +1469,7 @@ class BrowserViewController: UIViewController,
}

func willNavigateAway(from tab: Tab?) {
guard let tab else {
return
}
guard let tab else { return }

let screenshotHelper = self.screenshotHelper
let windowUUID = self.windowUUID
Expand Down
3 changes: 3 additions & 0 deletions firefox-ios/Client/Frontend/Browser/ScreenshotHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class ScreenshotHelper {
// The screenshot is then set for the tab, and a TabEvent is posted to indicate
// that a screenshot has been set for the homepage.
if tab.isFxHomeTab {
// Skip the screenshot if this tab is no longer selected to avoid capturing another tab's content.
guard controller?.tabManager.selectedTab?.tabUUID == tab.tabUUID else { return }

// For complex views like homepage the Screenshot tool could be the controller directly
// so check the contentController first otherwise fallback to the contentView.
let screenshotTool = controller?.contentContainer.contentController as? Screenshotable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ final class ScreenshotHelperTests: XCTestCase, StoreTestUtility {
let tab = Tab(profile: profile, windowUUID: .XCTestDefaultUUID)
let homeURL = URL(string: "internal://local/about/home")
let mockTabWebView = MockTabWebView(tab: tab)
tabManager.selectedTab = tab

mockTabWebView.loadedURL = homeURL
tab.webView = mockTabWebView
Expand Down
Loading