Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroboron committed Dec 10, 2024
1 parent 160bc30 commit b6dbf5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import Foundation
import MaliciousSiteProtection

class MaliciousSiteProtectionManager: MaliciousSiteDetecting {
final class MaliciousSiteProtectionManager: MaliciousSiteDetecting {

func evaluate(_ url: URL) async -> ThreatKind? {
try? await Task.sleep(interval: 0.3)
Expand All @@ -34,4 +34,5 @@ class MaliciousSiteProtectionManager: MaliciousSiteDetecting {
return .none
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ extension SpecialErrorPageNavigationHandler: WebViewNavigationHandling {

switch result {
case let .navigationHandled(.mainFrame(response)):
// Re-use the same request to avoid that the new sideload request is intercepted and cancelled
// due to parameters added to the header.
var request = response.navigationAction.request
request.url = response.errorData.url
isSpecialErrorPageRequest = true
Expand Down Expand Up @@ -132,11 +134,11 @@ extension SpecialErrorPageNavigationHandler: SpecialErrorPageUserScriptDelegate
if webView?.canGoBack == true {
_ = webView?.goBack()
} else {
forceCloseTab()
closeTab()
}
}

func forceCloseTab() {
func closeTab() {
delegate?.closeSpecialErrorPageTab()
}

Expand All @@ -148,7 +150,7 @@ extension SpecialErrorPageNavigationHandler: SpecialErrorPageUserScriptDelegate
navigateBackIfPossible()
case .maliciousSite:
maliciousSiteProtectionNavigationHandler.leaveSite()
forceCloseTab()
closeTab()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ struct MaliciousSiteProtectionNavigationHandlerTests {
}

@MainActor
@Test("Bypassed Malicious Site does not create a Malicious Detection Task", arguments: [ThreatKind.phishing, .malware])
@Test(
"Bypassed Malicious Site does not create a Malicious Detection Task",
arguments: [
ThreatKind.phishing,
.malware
]
)
func whenBypassedMaliciousSiteThreatKindIsSetThenReturnNavigationNotHandled(threat: ThreatKind) throws {
// GIVEN
let url = try #require(URL(string: "https://www.example.com"))
Expand Down

0 comments on commit b6dbf5c

Please sign in to comment.