Skip to content
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

support local storage fireproofing #3612

Merged
merged 18 commits into from
Dec 3, 2024

Conversation

brindy
Copy link
Contributor

@brindy brindy commented Nov 22, 2024

Task/Issue URL: https://app.asana.com/0/392891325557410/1204888209490842/f
Tech Design URL:
CC: @samsymons, @bwaresiak

Description:

Revert to using default persistence container for website data storage.

Also various refactoring to make future singleton slaying quests a bit easier.

Steps to test this PR:

  1. Using an older version of the app (any before this PR should be fine). Open some tabs, sign into to some websites, and fire proof them. Check the fire proofing is working by using the fire button and leave the tabs open to simulate users receiving this update. Then update the app to this branch.
  2. Use the fire button and ensure previously signed in sites still work as before.
  3. Use the Fireproofing UI in settings to remove fireproofed sites and use the fire button to clear them, ensuring their data has been cleared.
  4. Use the Cookies UI in debug to check there's no cookies.
  5. Navigate to https://privacy-test-pages.site/features/local-storage.html and start the counter.
  6. Use the fire button and navigate back to https://privacy-test-pages.site/features/local-storage.html - previous values should be removed.
  7. Fireproof the site and start the counter. Wait for a while, then use the fire button. Navigate back to https://privacy-test-pages.site/features/local-storage.html and the previous values should be set.
  8. Remove fireproofing for the site and use the fire button. Navigate to it once more and ensure the values are again unset.
  9. Do similar smoke testing using the fire button on the tab switcher
  10. Do so similar smoke testing using auto-clear setting on
  11. Run the release_tests/local-storage UI test and validate it works

Definition of Done (Internal Only):

Copy Testing:

  • Use of correct apostrophes in new copy, ie rather than '

Device Testing:

  • iPhone
  • iPad (smoke testing)

OS Testing:

  • iOS 15
  • iOS 16 (option)
  • iOS 17 (option)
  • iOS 18

Internal references:

Software Engineering Expectations
Technical Design Template

Copy link

github-actions bot commented Nov 22, 2024

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against ffe3448

@brindy brindy marked this pull request as ready for review November 29, 2024 01:08
@brindy brindy requested a review from jaceklyp November 29, 2024 01:09
///
/// The migration code removes the key that is used to check for the isConsumed flag so will only be
/// true if the data needs to be migrated.
public func consumeCookies(intoHTTPCookieStore httpCookieStore: WKHTTPCookieStore) async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

httpCookieStore is strongly typed, so I believe it should be consumeCookies(into httpCookieStore: WKHTTPCookieStore) async {


/// Supports an existing ID set in previous versions of the app, but moving forward does not allocate an ID. We have gone back to using the default
/// peristence for the webview storage so that we can fireproof types that don't have an API for accessing their data. (e.g. localStorage)
public protocol DataStoreIdManaging {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick; I think we should be using ID (not Id) just like Apple uses it in their libs, e.g. UUID or https://developer.apple.com/documentation/swiftui/scrollposition/viewid(type:)

@@ -51,15 +54,19 @@ public class UserDefaultsFireproofing: Fireproofing {
}
}

var allowedDomainsIncludingDuckDuckGo: [String] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Comment on lines +24 to +28
static func cookieDomain(_ cookieDomain: String, matchesTestDomain testDomain: String) -> Bool {
return testDomain == cookieDomain
|| ".\(testDomain)" == cookieDomain
|| (cookieDomain.hasPrefix(".") && testDomain.hasSuffix(cookieDomain))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you provide a piece of documentation what do we test here for and possible e.g of what matches means for us

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment and note to look at some unit tests

Comment on lines +67 to +74
/// Called after consuming cookies but migration has not happened.
/// This can happen in the following flow
/// * User presses fire button on container based app and then backgrounds it/switches to another app
/// * Installs update to this version of the app without using the browser
/// * Starts browsing
func setConsumed() {
resetStore()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im a bit confused, should anything else happen here besides "resetStore"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just wanted an API that made sense from where it was used. This is "behinds the scenes" behaviour related to migration.


var uuids = await WKWebsiteDataStore.allDataStoreIdentifiers
// Check version here rather than on function so that we don't need complicated logic related to verison in the calling function
guard #available(iOS 17, *) else { return }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor optimisation - < iOS 17 no migration is needed. Will add comment.

@brindy brindy requested a review from jaceklyp December 2, 2024 16:47
Copy link
Contributor

@jaceklyp jaceklyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@brindy brindy changed the base branch from main to release/7.148.0 December 2, 2024 20:13
@brindy brindy merged commit d3a068a into release/7.148.0 Dec 3, 2024
18 checks passed
@brindy brindy deleted the brindy/support-local-storage-fireproofing branch December 3, 2024 10:07
samsymons added a commit that referenced this pull request Dec 3, 2024
* release/7.148.0:
  Release 7.148.0-1 (#3661)
  Make a simple state machine to identify incorrect transitions  (#3660)
  support local storage fireproofing (#3612)
  Make NTP Grid layout adaptive for various screen sizes (#3657)
  Release 7.148.0-0 (#3659)
  Bump BSK, add Free Trials Feature Flag (#3655)
samsymons added a commit that referenced this pull request Dec 5, 2024
* main:
  Release 7.148.0-2 (#3676)
  Merge hotfix changes from 7.147.1 (#3674)
  Add `install` pixel (#3656)
  AI Chat browsing menu (#3635)
  Release 7.147.1-0 (#3672)
  Use actor isolation for `SubscriptionFeatureMappingCache` (#3670)
  cherry picked - already approved in #3666
  fix suggestion scrolling (#3654)
  Update autoconsent to v12.1.0 (#3650)
  Malware protection: bump BSK (#3617)
  Release 7.148.0-1 (#3661)
  Make a simple state machine to identify incorrect transitions  (#3660)
  support local storage fireproofing (#3612)
  Make NTP Grid layout adaptive for various screen sizes (#3657)
  Release 7.148.0-0 (#3659)
  Bump BSK, add Free Trials Feature Flag (#3655)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants