Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit dad17da

Browse files
committed
Add integration test for address bar spoofing vulnerability into NavigationProtectionIntegrationTests.
Dependent on this PR: duckduckgo/privacy-test-pages#169
1 parent f6b6876 commit dad17da

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

IntegrationTests/NavigationProtection/NavigationProtectionIntegrationTests.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,19 @@ class NavigationProtectionIntegrationTests: XCTestCase {
274274
}
275275
}
276276

277+
@MainActor
278+
func testUrlBarSpoofingWithLongLoadingNavigations() async throws {
279+
let tab = Tab(content: .none)
280+
window = WindowsManager.openNewWindow(with: tab)!
281+
let tabViewModel = (window.contentViewController as! MainViewController).browserTabViewController.tabViewModel!
282+
let url = URL(string: "https://privacy-test-pages.site/security/spoof-js-page-rewrite-simple.html")!
283+
_=try await tab.setUrl(url, userEntered: nil)?.result.get()
284+
_=try await tab.webView.evaluateJavaScript("(function() { run(); return true; })()")
285+
try await Task.sleep(nanoseconds: UInt64(0.5 * Double(NSEC_PER_SEC)))
286+
// Address Bar should not be updated this early
287+
XCTAssertNotEqual(tabViewModel.addressBarString, "https://duckduckgo.com:8443/")
288+
}
289+
277290
}
278291

279292
private extension Tab {

0 commit comments

Comments
 (0)