Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
645cb643
Unverified
Commit
645cb643
authored
Feb 09, 2021
by
Jonah Williams
Committed by
GitHub
Feb 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] do not crash if shared profile restoration fails (#75718)
parent
3aece335
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
4 deletions
+47
-4
chrome.dart
packages/flutter_tools/lib/src/web/chrome.dart
+7
-3
chrome_test.dart
...ges/flutter_tools/test/general.shard/web/chrome_test.dart
+40
-1
No files found.
packages/flutter_tools/lib/src/web/chrome.dart
View file @
645cb643
...
...
@@ -344,9 +344,13 @@ class ChromiumLauncher {
final
Directory
sourceChromeDefault
=
_fileSystem
.
directory
(
_fileSystem
.
path
.
join
(
cacheDir
.
path
??
''
,
_chromeDefaultPath
));
final
Directory
targetChromeDefault
=
_fileSystem
.
directory
(
_fileSystem
.
path
.
join
(
userDataDir
.
path
,
_chromeDefaultPath
));
if
(
sourceChromeDefault
.
existsSync
())
{
targetChromeDefault
.
createSync
(
recursive:
true
);
_fileSystemUtils
.
copyDirectorySync
(
sourceChromeDefault
,
targetChromeDefault
);
try
{
if
(
sourceChromeDefault
.
existsSync
())
{
targetChromeDefault
.
createSync
(
recursive:
true
);
_fileSystemUtils
.
copyDirectorySync
(
sourceChromeDefault
,
targetChromeDefault
);
}
}
on
FileSystemException
catch
(
err
)
{
_logger
.
printError
(
'Failed to restore Chrome preferences:
$err
'
);
}
}
...
...
packages/flutter_tools/test/general.shard/web/chrome_test.dart
View file @
645cb643
...
...
@@ -13,7 +13,6 @@ import 'package:flutter_tools/src/base/os.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/web/chrome.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -143,6 +142,46 @@ void main() {
expect
(
logger
.
errorText
,
contains
(
'Failed to save Chrome preferences'
));
});
testWithoutContext
(
'does not crash if restoring profile information fails due to a file system exception.'
,
()
async
{
final
MockFileSystemUtils
fileSystemUtils
=
MockFileSystemUtils
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
chromeLauncher
=
ChromiumLauncher
(
fileSystem:
fileSystem
,
platform:
platform
,
processManager:
processManager
,
operatingSystemUtils:
operatingSystemUtils
,
browserFinder:
findChromeExecutable
,
logger:
logger
,
fileSystemUtils:
fileSystemUtils
,
);
when
(
fileSystemUtils
.
copyDirectorySync
(
any
,
any
))
.
thenThrow
(
const
FileSystemException
());
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=1234'
,
...
kChromeArgs
,
'example_url'
,
],
stderr:
kDevtoolsStderr
,
));
fileSystem
.
currentDirectory
.
childDirectory
(
'Default'
).
createSync
();
final
Chromium
chrome
=
await
chromeLauncher
.
launch
(
'example_url'
,
skipCheck:
true
,
cacheDir:
fileSystem
.
currentDirectory
,
);
// Create cache dir that the Chrome launcher will atttempt to persist.
fileSystem
.
directory
(
'/.tmp_rand0/flutter_tools_chrome_device.rand0/Default/Local Storage'
)
.
createSync
(
recursive:
true
);
await
chrome
.
close
();
// does not exit with error.
expect
(
logger
.
errorText
,
contains
(
'Failed to restore Chrome preferences'
));
});
testWithoutContext
(
'can launch chrome with a custom debug port'
,
()
async
{
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment