-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[navigation #4] SERP headers navigation responder #887
[navigation #4] SERP headers navigation responder #887
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mallexxx, I am getting an assertion right after I run the app. Let me know if I am doing something wrong or you can't reproduce it.
The code looks good, I like the code coverage 🥇 . I just added few notes below.
|
||
func decidePolicy(for navigationAction: NavigationAction, preferences: inout NavigationPreferences) async -> NavigationActionPolicy? { | ||
guard let mainFrame = navigationAction.mainFrameTarget, | ||
navigationAction.url.isDuckDuckGo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to speed things up, do you think it makes sense to have navigationAction.url.isDuckDuckGo
as first condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don‘t think it makes sense since the main frame check is actually faster than comparing strings, but it‘s microoptimization anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main frame check is definitely faster, but useless for 99 percent of request since the URL isn't duckduckgo.com. Anyway, I don't mind leaving it as it is.
|
||
print(url) | ||
tab.setContent(.url(url)) | ||
waitForExpectations(timeout: 50) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use a lower value than 50?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgotten test value 🙄
|
||
override func setUp() { | ||
// disable waiting for CBR compilation on navigation | ||
MockPrivacyConfiguration.isFeatureKeyEnabled = { _, _ in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it isn't the scope of this PR, but why is MockPrivacyConfiguration global? I am afraid it breaks the encapsulation of unit tests
@MainActor | ||
func testOnDDGRequest_headersAdded() { | ||
var onNavAction: (@MainActor (NavigationAction) -> NavigationActionPolicy?)! | ||
TestTabExtensionsBuilder.shared = TestTabExtensionsBuilder(load: []) { builder in { _, _ in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, the test uses TestTabExtensionsBuilder.shared
, which is a global state. Can it be refactored to use an instance of TestTabExtensionsBuilder
instead of static reference to TestTabExtensionsBuilder
? It doesn't need to be refactored in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! 👍
|
||
let tab = Tab(content: .none, shouldLoadInBackground: true) | ||
|
||
for child in Mirror(reflecting: urls).children.filter({ $0.label!.hasPrefix("ddg") }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to refactor this to more readable variant by declaring two structs:
- DDGUrls
- NotDDGUrls
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍 Works like a charm! 👏
Do you plan to address the issue of accessing the global state from unit tests in future, or is this a final design?
updated the PR cleaning up things |
* canGoBack, canGoForward RePublished, Tab.publishers refactored * redo redirect(_:NavigationAction, invalidatingBackItemIfNeeded) * tests * don‘t use shared state in tests * fix RELEASE * rollback renaming * drop RePublished * fix header name * [navigation #4] SERP headers navigation responder (#887) * SERP headers handling in SerpHeadersNavigationResponder
* AdClickAttributionTabExtension+NavigationResponder * fix TabExtension test overrides, adClick extension tests * fix AdClickAttributionTabExtensionTests teardown * cleanup * don‘t use shared state in tests * fix adClick inherited attribution initialization * cleanup * Adjust adClick tests to better match UserScripts/UserContentController behaviour; cleanup * fix RELEASE * remove Swifter dependency * fix file header * [navigation #3+4] canGoBack/GoForward; SERP headers (#885) * canGoBack, canGoForward RePublished, Tab.publishers refactored * redo redirect(_:NavigationAction, invalidatingBackItemIfNeeded) * tests * don‘t use shared state in tests * fix RELEASE * rollback renaming * drop RePublished * fix header name * [navigation #4] SERP headers navigation responder (#887) * SERP headers handling in SerpHeadersNavigationResponder * convert TabTests to custom SchemeHandler
Task/Issue URL: https://app.asana.com/0/0/1203487090719126/f
Tech Design URL: https://app.asana.com/0/481882893211075/1203268245242140
CC: @tomasstrba @bwaresiak
Description:
Moves adding headers to Search Queries to a separate Navigation Responder
Steps to test this PR: