diff --git a/DuckDuckGo/Tab/TabExtensions/DownloadsTabExtension.swift b/DuckDuckGo/Tab/TabExtensions/DownloadsTabExtension.swift
index 1aae34f4c6..339aca0a9a 100644
--- a/DuckDuckGo/Tab/TabExtensions/DownloadsTabExtension.swift
+++ b/DuckDuckGo/Tab/TabExtensions/DownloadsTabExtension.swift
@@ -224,11 +224,12 @@ extension DownloadsTabExtension: NavigationResponder {
let task = downloadManager.add(download, fromBurnerWindow: self.isBurner, delegate: self, destination: .auto)
var isMainFrameNavigationActionWithNoHistory: Bool {
- guard let navigationAction,
+ // get the first navigation action in the redirect series
+ guard let navigationAction = navigationAction?.redirectHistory?.first ?? navigationAction,
navigationAction.isForMainFrame,
navigationAction.isTargetingNewWindow,
// webView has no navigation history (downloaded navigationAction has started from an empty state)
- (navigationAction.redirectHistory?.first ?? navigationAction).fromHistoryItemIdentity == nil
+ navigationAction.fromHistoryItemIdentity == nil
else { return false }
return true
}
diff --git a/IntegrationTests/Common/TestsURLExtension.swift b/IntegrationTests/Common/TestsURLExtension.swift
index 95da2cd8ca..b1bd1f7a8f 100644
--- a/IntegrationTests/Common/TestsURLExtension.swift
+++ b/IntegrationTests/Common/TestsURLExtension.swift
@@ -37,7 +37,7 @@ extension URL {
let url = URL.testsServer
.appendingPathComponent("filename") // "http://localhost:8085/filename"
.appendingTestParameters(status: 301,
- reason: "Moved"
+ reason: "Moved",
data: Data(),
headers: ["Location": "/redirect-location.html"])
Tab.setUrl(url)
diff --git a/IntegrationTests/Downloads/DownloadsIntegrationTests.swift b/IntegrationTests/Downloads/DownloadsIntegrationTests.swift
index fbe3f5f557..f74e6e42e5 100644
--- a/IntegrationTests/Downloads/DownloadsIntegrationTests.swift
+++ b/IntegrationTests/Downloads/DownloadsIntegrationTests.swift
@@ -185,6 +185,133 @@ class DownloadsIntegrationTests: XCTestCase {
}
}
+ @MainActor
+ func testWhenDownloadIsStartedInNewTab_tabIsClosed() async throws {
+ let preferences = DownloadsPreferences.shared
+ preferences.alwaysRequestDownloadLocation = false
+ preferences.selectedDownloadLocation = FileManager.default.temporaryDirectory
+ let dirURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
+ try FileManager.default.createDirectory(at: dirURL, withIntermediateDirectories: true)
+
+ let downloadUrl = URL.testsServer
+ .appendingPathComponent("fname.dat")
+ .appendingTestParameters(data: data.html,
+ headers: ["Content-Disposition": "attachment; filename=\"fname.dat\"",
+ "Content-Type": "text/html"])
+
+ let pageUrl = URL.testsServer
+ .appendingTestParameters(data: """
+
+
+
+
+ Clickable Body
+
+
+ Click anywhere on the page to open the link
+
+
+ """.utf8data)
+ let tab = tabViewModel.tab
+ _=await tab.setUrl(pageUrl, source: .link)?.result
+
+ NSApp.activate(ignoringOtherApps: true)
+ let downloadTaskFuture = FileDownloadManager.shared.downloadsPublisher.timeout(5).first().promise()
+
+ let e1 = expectation(description: "new tab opened")
+ var e2: XCTestExpectation!
+ let c = tabCollectionViewModel.$selectedTabViewModel.dropFirst()
+ .receive(on: DispatchQueue.main)
+ .sink { [unowned self] tabViewModel in
+ guard let tabViewModel else { return }
+ print("tabViewModel", tabViewModel.tab, tab)
+ if tabViewModel.tab !== tab {
+ e1.fulfill()
+ e2 = expectation(description: "new tab closed")
+ } else {
+ e2.fulfill()
+ }
+ }
+
+ // click to open a new (download) tab and instantly deactivate it
+ click(tab.webView)
+
+ // download should start in the background tab
+ _=try await downloadTaskFuture.get()
+
+ // expect for the download tab to close
+ await fulfillment(of: [e1, e2], timeout: 10)
+ withExtendedLifetime(c, {})
+ }
+
+ @MainActor
+ func testWhenDownloadIsStartedInNewTabAfterRedirect_tabIsClosed() async throws {
+ let preferences = DownloadsPreferences.shared
+ preferences.alwaysRequestDownloadLocation = false
+ preferences.selectedDownloadLocation = FileManager.default.temporaryDirectory
+ let dirURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
+ try FileManager.default.createDirectory(at: dirURL, withIntermediateDirectories: true)
+
+ let downloadUrl = URL.testsServer
+ .appendingPathComponent("fname.dat")
+ .appendingTestParameters(data: data.html,
+ headers: ["Content-Disposition": "attachment; filename=\"fname.dat\"",
+ "Content-Type": "text/html"])
+
+ let redirectUrl = URL.testsServer
+ .appendingTestParameters(data: """
+
+
+
+ """.utf8data)
+
+ let pageUrl = URL.testsServer
+ .appendingTestParameters(data: """
+
+
+
+
+ Clickable Body
+
+
+ Click anywhere on the page to open the link
+
+
+ """.utf8data)
+ let tab = tabViewModel.tab
+ _=await tab.setUrl(pageUrl, source: .link)?.result
+
+ NSApp.activate(ignoringOtherApps: true)
+ let downloadTaskFuture = FileDownloadManager.shared.downloadsPublisher.timeout(5).first().promise()
+
+ let e1 = expectation(description: "new tab opened")
+ var e2: XCTestExpectation!
+ let c = tabCollectionViewModel.$selectedTabViewModel.dropFirst()
+ .receive(on: DispatchQueue.main)
+ .sink { [unowned self] tabViewModel in
+ guard let tabViewModel else { return }
+ print("tabViewModel", tabViewModel.tab, tab)
+ if tabViewModel.tab !== tab {
+ e1.fulfill()
+ e2 = expectation(description: "new tab closed")
+ } else {
+ e2.fulfill()
+ }
+ }
+
+ // click to open a new (download) tab and instantly deactivate it
+ click(tab.webView)
+
+ // download should start in the background tab
+ _=try await downloadTaskFuture.get()
+
+ // expect for the download tab to close
+ await fulfillment(of: [e1, e2], timeout: 10)
+ withExtendedLifetime(c, {})
+ }
+
@MainActor
func testWhenSaveDialogOpenInBackgroundTabAndTabIsClosed_downloadIsCancelled() async throws {
let persistor = DownloadsPreferencesUserDefaultsPersistor()
diff --git a/IntegrationTests/Tab/AddressBarTests.swift b/IntegrationTests/Tab/AddressBarTests.swift
index e5297ed96b..9323afb45c 100644
--- a/IntegrationTests/Tab/AddressBarTests.swift
+++ b/IntegrationTests/Tab/AddressBarTests.swift
@@ -23,7 +23,6 @@ import XCTest
@testable import DuckDuckGo_Privacy_Browser
@available(macOS 12.0, *)
-@MainActor
class AddressBarTests: XCTestCase {
var window: MainWindow!
@@ -141,6 +140,7 @@ class AddressBarTests: XCTestCase {
// MARK: - Tests
+ @MainActor
func testWhenUserStartsTypingOnNewTabPageLoad_userInputIsNotReset() async throws {
// open Tab with newtab page
let tab = Tab(content: .newtab, privacyFeatures: privacyFeaturesMock)
@@ -190,6 +190,7 @@ class AddressBarTests: XCTestCase {
}
+ @MainActor
func testWhenSwitchingBetweenTabs_addressBarFocusStateIsCorrect() async throws {
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [
Tab(content: .newtab, privacyFeatures: privacyFeaturesMock),
@@ -220,24 +221,28 @@ class AddressBarTests: XCTestCase {
}
}
+ @MainActor
func testWhenRestoringToOnboarding_addressBarIsNotActive() async throws {
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [Tab(content: .onboarding, privacyFeatures: privacyFeaturesMock)]))
window = WindowsManager.openNewWindow(with: viewModel)!
XCTAssertEqual(window.firstResponder, mainViewController.browserTabViewController.transientTabContentViewController!.view)
}
+ @MainActor
func testWhenRestoringToSettings_addressBarIsNotActive() async throws {
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [Tab(content: .settings(pane: .appearance), privacyFeatures: privacyFeaturesMock)]))
window = WindowsManager.openNewWindow(with: viewModel)!
XCTAssertEqual(window.firstResponder, mainViewController.browserTabViewController.preferencesViewController!.view)
}
+ @MainActor
func testWhenRestoringToBookmarks_addressBarIsNotActive() async throws {
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [Tab(content: .bookmarks, privacyFeatures: privacyFeaturesMock)]))
window = WindowsManager.openNewWindow(with: viewModel)!
XCTAssertEqual(window.firstResponder, mainViewController.browserTabViewController.bookmarksViewController!.view)
}
+ @MainActor
func testWhenRestoringToURL_addressBarIsNotActive() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .loadedByStateRestoration), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -245,12 +250,14 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenRestoringToNewTab_addressBarIsActive() async throws {
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [Tab(content: .newtab, privacyFeatures: privacyFeaturesMock)]))
window = WindowsManager.openNewWindow(with: viewModel)!
XCTAssertTrue(isAddressBarFirstResponder)
}
+ @MainActor
func testWhenOpeningNewTab_addressBarIsActivated() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .loadedByStateRestoration), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -274,6 +281,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenSwitchingBetweenTabsWithTypedValue_typedValueIsPreserved() async throws {
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [
Tab(content: .newtab, privacyFeatures: privacyFeaturesMock),
@@ -312,6 +320,7 @@ class AddressBarTests: XCTestCase {
}
}
+ @MainActor
func testWhenSwitchingBetweenURLTabs_addressBarIsDeactivated() async throws {
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [
Tab(content: .url(.duckDuckGo, credential: nil, source: .pendingStateRestoration), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock),
@@ -332,6 +341,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, viewModel.tabs[0].webView)
}
+ @MainActor
func testWhenDeactivatingAddressBar_webViewShouldBecomeFirstResponder() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .pendingStateRestoration), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -346,6 +356,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenGoingBack_addressBarIsDeactivated() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .loadedByStateRestoration), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -372,6 +383,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenGoingBackToNewtabPage_addressBarIsActivated() async throws {
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -409,6 +421,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenGoingBackToNewtabPageFromSettings_addressBarIsActivated() async throws {
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -434,6 +447,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, mainViewController.browserTabViewController.preferencesViewController!.view)
}
+ @MainActor
func testWhenGoingBackToNewtabPageFromBookmarks_addressBarIsActivated() async throws {
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -459,6 +473,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, mainViewController.browserTabViewController.bookmarksViewController!.view)
}
+ @MainActor
func testWhenTabReloaded_addressBarIsDeactivated() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .webViewUpdated), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -476,6 +491,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenReloadingFailingPage_addressBarIsDeactivated() async throws {
// first navigation should fail
schemeHandler.middleware = [{ _ in
@@ -499,6 +515,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenTabReloadedBySubmittingSameAddressAndAddressIsActivated_addressBarIsKeptActiveOnPageLoad() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .userEntered("")), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -520,6 +537,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(addressBarValue, "some-text")
}
+ @MainActor
func testWhenEditingSerpURL_serpIconIsDisplayed() async throws {
let tab = Tab(content: .url(.makeSearchUrl(from: "catz")!, credential: nil, source: .userEntered("catz")), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -527,10 +545,9 @@ class AddressBarTests: XCTestCase {
_=try await tab.webViewDidFinishNavigationPublisher.timeout(5).first().promise().value
_=window.makeFirstResponder(addressBarTextField)
-
-// try await Task.sleep(interval: 60.01)
}
+ @MainActor
func testWhenOpeningBookmark_addressBarIsDeactivated() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .webViewUpdated), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -545,6 +562,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenOpeningHistoryEntry_addressBarIsDeactivated() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .webViewUpdated), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -559,6 +577,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenOpeningURLfromUI_addressBarIsDeactivated() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .webViewUpdated), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -573,6 +592,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenHomePageIsOpened_addressBarIsDeactivated() async throws {
StartupPreferences.shared.launchToCustomHomePage = true
@@ -592,6 +612,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenAddressSubmitted_addressBarIsDeactivated() async throws {
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -605,6 +626,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window.firstResponder, tab.webView)
}
+ @MainActor
func testWhenAddressSubmittedAndAddressBarIsReactivated_addressBarIsKeptActiveOnPageLoad() async throws {
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
let viewModel = TabCollectionViewModel(tabCollection: TabCollection(tabs: [tab]))
@@ -624,6 +646,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(addressBarValue, "some-text")
}
+ @MainActor
func testWhenPageRedirected_addressBarStaysActivePreservingUserInput() async throws {
let expectation = expectation(description: "request sent")
schemeHandler.middleware = [{ request in
@@ -669,6 +692,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(addressBarValue, "replacement-url")
}
+ @MainActor
func testWhenPageRedirectedWhenAddressBarIsInactive_addressBarShouldReset() async throws {
AppearancePreferences.shared.showFullURL = true
@@ -717,6 +741,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(addressBarValue, "https://redirected.com/")
}
+ @MainActor
func testWhenActivatingWindowWithPinnedTabOpen_webViewBecomesFirstResponder() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .userEntered("")), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
WindowControllersManager.shared.pinnedTabsManager.setUp(with: TabCollection(tabs: [tab]))
@@ -748,6 +773,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window2.firstResponder, window2)
}
+ @MainActor
func testWhenActivatingWindowWithPinnedTabWhenAddressBarIsActive_addressBarIsKeptActive() async throws {
let tab = Tab(content: .url(.duckDuckGo, credential: nil, source: .userEntered("")), webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
WindowControllersManager.shared.pinnedTabsManager.setUp(with: TabCollection(tabs: [tab]))
@@ -780,6 +806,7 @@ class AddressBarTests: XCTestCase {
XCTAssertEqual(window2.firstResponder, window2)
}
+ @MainActor
func test_WhenSiteCertificateNil_ThenAddressBarShowsStandardShieldIcon() async throws {
// GIVEN
let expectedImage = NSImage(named: "Shield")!
@@ -797,6 +824,7 @@ class AddressBarTests: XCTestCase {
XCTAssertTrue(shieldImage.isEqualToImage(expectedImage))
}
+ @MainActor
func test_WhenSiteCertificateValid_ThenAddressBarShowsStandardShieldIcon() async throws {
// GIVEN
let expectedImage = NSImage(named: "Shield")!
@@ -815,6 +843,7 @@ class AddressBarTests: XCTestCase {
XCTAssertTrue(shieldImage.isEqualToImage(expectedImage))
}
+ @MainActor
func test_WhenSiteCertificateInvalid_ThenAddressBarShowsDottedShieldIcon() async throws {
// GIVEN
let expectedImage = NSImage(named: "ShieldDot")!
diff --git a/IntegrationTests/Tab/ErrorPageTests.swift b/IntegrationTests/Tab/ErrorPageTests.swift
index b4dc46832c..a6dab00d9d 100644
--- a/IntegrationTests/Tab/ErrorPageTests.swift
+++ b/IntegrationTests/Tab/ErrorPageTests.swift
@@ -23,7 +23,6 @@ import XCTest
@testable import DuckDuckGo_Privacy_Browser
@available(macOS 12.0, *)
-@MainActor
class ErrorPageTests: XCTestCase {
var window: NSWindow!
@@ -146,6 +145,7 @@ class ErrorPageTests: XCTestCase {
// MARK: - Tests
+ @MainActor
func testWhenPageFailsToLoad_errorPageShown() async throws {
// open Tab with newtab page
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
@@ -186,6 +186,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertEqual(tab.content.userEditableUrl, .test)
}
+ @MainActor
func testWhenTabWithNoConnectionErrorActivated_reloadTriggered() async throws {
// open 2 Tabs with newtab page
let tab1 = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
@@ -231,6 +232,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertNil(tab1.error)
}
+ @MainActor
func testWhenTabWithConnectionLostErrorActivatedAndReloadFailsAgain_errorPageIsShownOnce() async throws {
// open 2 Tabs with newtab page
// navigate to a failing url right away
@@ -284,6 +286,7 @@ class ErrorPageTests: XCTestCase {
withExtendedLifetime(c) {}
}
+ @MainActor
func testWhenTabWithOtherErrorActivated_reloadNotTriggered() async throws {
// open 2 Tabs with newtab page
// navigate to a failing url right away
@@ -314,6 +317,7 @@ class ErrorPageTests: XCTestCase {
withExtendedLifetime(c) {}
}
+ @MainActor
func testWhenGoingBackToFailingPage_reloadIsTriggered() async throws {
// open Tab with newtab page
// navigate to a failing url right away
@@ -366,6 +370,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertTrue(tab.canReload)
}
+ @MainActor
func testWhenGoingBackToFailingPageAndItFailsAgain_errorPageIsUpdated() async throws {
// open Tab with newtab page
// navigate to a failing url right away
@@ -424,6 +429,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertTrue(tab.canReload)
}
+ @MainActor
func testWhenPageLoadedAndFailsOnRefreshAndOnConsequentRefresh_errorPageIsUpdatedKeepingForwardHistory() async throws {
// open Tab with newtab page
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
@@ -500,6 +506,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertTrue(tab.canReload)
}
+ @MainActor
func testWhenPageLoadedAndFailsOnRefreshAndSucceedsOnConsequentRefresh_forwardHistoryIsPreserved() async throws {
// open Tab with newtab page
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
@@ -568,6 +575,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertTrue(tab.canReload)
}
+ @MainActor
func testWhenReloadingBySubmittingSameURL_errorPageRemainsSame() async throws {
// open Tab with newtab page
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
@@ -643,6 +651,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertTrue(tab.canReload)
}
+ @MainActor
func testWhenGoingToAnotherUrlFails_newBackForwardHistoryItemIsAdded() async throws {
// open Tab with newtab page
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
@@ -718,6 +727,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertTrue(tab.canReload)
}
+ @MainActor
func testWhenGoingToAnotherUrlSucceeds_newBackForwardHistoryItemIsAdded() async throws {
// open Tab with newtab page
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
@@ -787,6 +797,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertTrue(tab.canReload)
}
+ @MainActor
func testWhenLoadingFailsAfterSessionRestoration_navigationHistoryIsPreserved() async throws {
schemeHandler.middleware = [{ _ in
.failure(NSError.noConnection)
@@ -827,6 +838,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertTrue(tab.canReload)
}
+ @MainActor
func testPinnedTabDoesNotNavigateAway() async throws {
schemeHandler.middleware = [{ _ in
return .ok(.html(Self.testHtml))
@@ -874,6 +886,7 @@ class ErrorPageTests: XCTestCase {
XCTAssertEqual(viewModel.tabs.count, 1)
}
+ @MainActor
func testWhenPageFailsToLoadAfterRedirect_errorPageShown() async throws {
// open Tab with newtab page
let tab = Tab(content: .newtab, webViewConfiguration: webViewConfiguration, privacyFeatures: privacyFeaturesMock)
diff --git a/IntegrationTests/Tab/TabContentTests.swift b/IntegrationTests/Tab/TabContentTests.swift
index 16434f7a3b..bf851f09c8 100644
--- a/IntegrationTests/Tab/TabContentTests.swift
+++ b/IntegrationTests/Tab/TabContentTests.swift
@@ -24,7 +24,6 @@ import XCTest
@testable import DuckDuckGo_Privacy_Browser
@available(macOS 12.0, *)
-@MainActor
class TabContentTests: XCTestCase {
var window: NSWindow!