Skip to content

Commit

Permalink
Bugfix FXIOS-8426 [v124] Fix contextual tabs showing incorrectly in I…
Browse files Browse the repository at this point in the history
…nactive Tabs section (backport #18813) (#18840)

* [8426] Ensure newly created tabs default to a sensible firstCreatedTime timestamp instead of 1970

* [8426] Update to testGetInactiveTabs()

(cherry picked from commit a6349a6)

Co-authored-by: mattreaganmozilla <[email protected]>
  • Loading branch information
mergify[bot] and mattreaganmozilla authored Mar 4, 2024
1 parent e20687d commit 9e23f38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions firefox-ios/Client/TabManagement/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ class Tab: NSObject, ThemeApplicable {
self.logger = logger
super.init()
self.isPrivate = isPrivate
self.firstCreatedTime = Date().toTimestamp()
debugTabCount += 1

TelemetryWrapper.recordEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,21 @@ class TabManagerTests: XCTestCase {
func testGetInactiveTabs() {
let subject = createSubject()
addTabs(to: subject, count: 3)
guard let tab = subject.tabs.first else {
XCTFail("First tab was expected to be found")
return
}
// Override session data to make tab active
tab.sessionData = LegacySessionData(currentPage: 0, urls: [], lastUsedTime: Date.now.toTimestamp())
XCTAssert(subject.tabs.count == 3, "Expected 3 newly added tabs.")

// Set createdAt date for all tabs to be distant past (inactive by default)
subject.tabs.forEach { $0.firstCreatedTime = Timestamp(0) }

// Override session data lastUsedTime of 1st tab to indicate tab active
let tab1 = subject.tabs[0]
tab1.sessionData = LegacySessionData(currentPage: 0,
urls: [],
lastUsedTime: Date.now.toTimestamp())

let inactiveTabs = subject.getInactiveTabs()
let expectedInactiveTabs = 2

// Expect 2 of 3 tabs are inactive (except 1st)
XCTAssertEqual(inactiveTabs.count, expectedInactiveTabs)
}

Expand Down

0 comments on commit 9e23f38

Please sign in to comment.