save and restore the chrome session local storage information#53030
save and restore the chrome session local storage information#53030devoncarew merged 3 commits intoflutter:masterfrom
Conversation
| destinationFile.parent.createSync(recursive: true); | ||
| savedPreferencesFile.copySync(destinationFile.path); | ||
| } | ||
| final Directory userDataDir = _fileSystem.systemTempDirectory.createTempSync('flutter_tool.'); |
There was a problem hiding this comment.
The tool already creates a few other temp directories with the prefix flutter_tool or flutter_tools, so it might be helpful to have a more specific name for this. Maybe 'flutter_tools_chrome_device.'? Longer term, we can have a more organized way of writing to system temp. I filed #53104 to track.
There was a problem hiding this comment.
Happy to change the name (note however that this is the name used by the existing code).
| targetPreferencesFile.parent.createSync(recursive: true); | ||
| // If the file contains a crash string, remove it to hide the popup on next run. | ||
| final String contents = sourcePreferencesFile.readAsStringSync(); | ||
| targetPreferencesFile.writeAsStringSync(contents |
There was a problem hiding this comment.
Is there a link you can add in a comment either describing the schema of this file, or at least of this field?
Also, is there a test for the find/replace?
There was a problem hiding this comment.
I don't believe there's a schema. The existing test (this portion of the PR is existing code) does contain a check for the find / replace for the crash string.
There was a problem hiding this comment.
I found one of file locations by reading chrome source, we could link to that?
There was a problem hiding this comment.
Can you link it here, and I'll add to the PR?
There was a problem hiding this comment.
I can't find it, It might have just been grepping the user data dir for strings
There was a problem hiding this comment.
I found some info here: https://www.chromium.org/developers/design-documents/preferences; will in-line into the source code.
|
ptal - updated based on review comments |
Description
This PR saves and restores the chrome session local storage information for flutter web chrome devices. When running chrome devices, we already save and restore the userDataDir preferences file, containing things like the window size and location. This PR also saves are restores the local storage info for web apps, allowing the local storage info to persist across app runs.
Related Issues
None, but this addresses an issue found while developing DevTools. I'll link the PR in here once that work is complete.
Tests
I updated the following tests:
flutter_tools/test/general.shard/web/chrome_test.dart:'can seed chrome temp directory with existing preferences'(renamed to'can seed chrome temp directory with existing session data')Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.