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
6e57ed60
Unverified
Commit
6e57ed60
authored
Aug 25, 2022
by
Yegor
Committed by
GitHub
Aug 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] fix hot restart in entrypoint generated by `flutter create` (#110229)
parent
db51e5d9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
4 deletions
+46
-4
service_worker_test.dart
dev/bots/service_worker_test.dart
+38
-0
test.dart
dev/bots/test.dart
+1
-0
.gitignore
dev/integration_tests/web/web/.gitignore
+2
-0
index.html.tmpl
...es/flutter_tools/templates/app_shared/web/index.html.tmpl
+5
-4
No files found.
dev/bots/service_worker_test.dart
View file @
6e57ed60
...
...
@@ -30,10 +30,16 @@ enum ServiceWorkerTestType {
withFlutterJs
,
withFlutterJsShort
,
withFlutterJsEntrypointLoadedEvent
,
// Entrypoint generated by `flutter create`.
generatedEntrypoint
,
}
// Run a web service worker test as a standalone Dart program.
Future
<
void
>
main
()
async
{
// When updating this list, also update `dev/bots/test.dart`. This `main()`
// function is only here for convenience. Adding tests here will not add them
// to LUCI.
await
runWebServiceWorkerTest
(
headless:
false
,
testType:
ServiceWorkerTestType
.
withoutFlutterJs
);
await
runWebServiceWorkerTest
(
headless:
false
,
testType:
ServiceWorkerTestType
.
withFlutterJs
);
await
runWebServiceWorkerTest
(
headless:
false
,
testType:
ServiceWorkerTestType
.
withFlutterJsShort
);
...
...
@@ -42,13 +48,42 @@ Future<void> main() async {
await
runWebServiceWorkerTestWithCachingResources
(
headless:
false
,
testType:
ServiceWorkerTestType
.
withFlutterJs
);
await
runWebServiceWorkerTestWithCachingResources
(
headless:
false
,
testType:
ServiceWorkerTestType
.
withFlutterJsShort
);
await
runWebServiceWorkerTestWithCachingResources
(
headless:
false
,
testType:
ServiceWorkerTestType
.
withFlutterJsEntrypointLoadedEvent
);
await
runWebServiceWorkerTestWithGeneratedEntrypoint
(
headless:
false
);
await
runWebServiceWorkerTestWithBlockedServiceWorkers
(
headless:
false
);
if
(
hasError
)
{
print
(
'One or more tests failed.'
);
reportErrorsAndExit
();
}
}
// Regression test for https://github.com/flutter/flutter/issues/109093.
//
// Tests the entrypoint that's generated by `flutter create`.
Future
<
void
>
runWebServiceWorkerTestWithGeneratedEntrypoint
({
required
bool
headless
,
})
async
{
await
_generateEntrypoint
();
await
runWebServiceWorkerTestWithCachingResources
(
headless:
headless
,
testType:
ServiceWorkerTestType
.
generatedEntrypoint
);
}
Future
<
void
>
_generateEntrypoint
()
async
{
final
Directory
tempDirectory
=
Directory
.
systemTemp
.
createTempSync
(
'flutter_web_generated_entrypoint.'
);
await
runCommand
(
_flutter
,
<
String
>[
'create'
,
'generated_entrypoint_test'
],
workingDirectory:
tempDirectory
.
path
,
);
final
File
generatedEntrypoint
=
File
(
path
.
join
(
tempDirectory
.
path
,
'generated_entrypoint_test'
,
'web'
,
'index.html'
));
final
String
generatedEntrypointCode
=
generatedEntrypoint
.
readAsStringSync
();
final
File
testEntrypoint
=
File
(
path
.
join
(
_testAppWebDirectory
,
_testTypeToIndexFile
(
ServiceWorkerTestType
.
generatedEntrypoint
),
));
testEntrypoint
.
writeAsStringSync
(
generatedEntrypointCode
);
tempDirectory
.
deleteSync
(
recursive:
true
);
}
Future
<
void
>
_setAppVersion
(
int
version
)
async
{
final
File
targetFile
=
File
(
_targetPath
);
await
targetFile
.
writeAsString
(
...
...
@@ -77,6 +112,9 @@ String _testTypeToIndexFile(ServiceWorkerTestType type) {
case
ServiceWorkerTestType
.
withFlutterJsEntrypointLoadedEvent
:
indexFile
=
'index_with_flutterjs_entrypoint_loaded.html'
;
break
;
case
ServiceWorkerTestType
.
generatedEntrypoint
:
indexFile
=
'generated_entrypoint.html'
;
break
;
}
return
indexFile
;
}
...
...
dev/bots/test.dart
View file @
6e57ed60
...
...
@@ -1179,6 +1179,7 @@ Future<void> _runWebLongRunningTests() async {
()
=>
runWebServiceWorkerTestWithCachingResources
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withFlutterJs
),
()
=>
runWebServiceWorkerTestWithCachingResources
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withFlutterJsShort
),
()
=>
runWebServiceWorkerTestWithCachingResources
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withFlutterJsEntrypointLoadedEvent
),
()
=>
runWebServiceWorkerTestWithGeneratedEntrypoint
(
headless:
true
),
()
=>
runWebServiceWorkerTestWithBlockedServiceWorkers
(
headless:
true
),
()
=>
_runWebStackTraceTest
(
'profile'
,
'lib/stack_trace.dart'
),
()
=>
_runWebStackTraceTest
(
'release'
,
'lib/stack_trace.dart'
),
...
...
dev/integration_tests/web/web/.gitignore
0 → 100644
View file @
6e57ed60
# This file is generated by a test. It should not be committed to source control.
generated_entrypoint.html
packages/flutter_tools/templates/app_shared/web/index.html.tmpl
View file @
6e57ed60
...
...
@@ -46,11 +46,12 @@
_flutter
.
loader
.
loadEntrypoint
({
serviceWorker
:
{
serviceWorkerVersion
:
serviceWorkerVersion
,
},
onEntrypointLoaded
:
function
(
engineInitializer
)
{
engineInitializer
.
initializeEngine
().
then
(
function
(
appRunner
)
{
appRunner
.
runApp
();
});
}
}).
then
(
function
(
engineInitializer
)
{
return
engineInitializer
.
initializeEngine
();
}).
then
(
function
(
appRunner
)
{
return
appRunner
.
runApp
();
});
});
</script>
...
...
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