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
680bc17c
Unverified
Commit
680bc17c
authored
May 24, 2022
by
Dacian Florea
Committed by
GitHub
May 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] [fix] Cache resource data only if the fetching succeed (#103816)
parent
f2e6d478
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
232 additions
and
28 deletions
+232
-28
service_worker_test.dart
dev/bots/service_worker_test.dart
+206
-26
test.dart
dev/bots/test.dart
+3
-0
service_worker_test_cached_resources.dart
...n_tests/web/lib/service_worker_test_cached_resources.dart
+18
-0
pubspec.yaml
dev/integration_tests/web/pubspec.yaml
+1
-0
flutter_service_worker_js.dart
...ib/src/web/file_generators/flutter_service_worker_js.dart
+4
-2
No files found.
dev/bots/service_worker_test.dart
View file @
680bc17c
This diff is collapsed.
Click to expand it.
dev/bots/test.dart
View file @
680bc17c
...
...
@@ -1083,6 +1083,9 @@ Future<void> _runWebLongRunningTests() async {
()
=>
runWebServiceWorkerTest
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withoutFlutterJs
),
()
=>
runWebServiceWorkerTest
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withFlutterJs
),
()
=>
runWebServiceWorkerTest
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withFlutterJsShort
),
()
=>
runWebServiceWorkerTestWithCachingResources
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withoutFlutterJs
),
()
=>
runWebServiceWorkerTestWithCachingResources
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withFlutterJs
),
()
=>
runWebServiceWorkerTestWithCachingResources
(
headless:
true
,
testType:
ServiceWorkerTestType
.
withFlutterJsShort
),
()
=>
_runWebStackTraceTest
(
'profile'
,
'lib/stack_trace.dart'
),
()
=>
_runWebStackTraceTest
(
'release'
,
'lib/stack_trace.dart'
),
()
=>
_runWebStackTraceTest
(
'profile'
,
'lib/framework_stack_trace.dart'
),
...
...
dev/integration_tests/web/lib/service_worker_test_cached_resources.dart
0 → 100644
View file @
680bc17c
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
Future
<
void
>
main
()
async
{
runApp
(
Scaffold
(
body:
Center
(
child:
Column
(
children:
const
<
Widget
>[
Icon
(
Icons
.
ac_unit
),
Text
(
'Hello, World'
,
textDirection:
TextDirection
.
ltr
),
],
),
),
));
}
dev/integration_tests/web/pubspec.yaml
View file @
680bc17c
...
...
@@ -8,6 +8,7 @@ flutter:
assets
:
-
lib/a.dart
-
lib/b.dart
uses-material-design
:
true
dependencies
:
flutter
:
...
...
packages/flutter_tools/lib/src/web/file_generators/flutter_service_worker_js.dart
View file @
680bc17c
...
...
@@ -134,9 +134,11 @@ self.addEventListener("fetch", (event) => {
.
then
((
cache
)
=>
{
return
cache
.
match
(
event
.
request
).
then
((
response
)
=>
{
// Either respond with the cached resource, or perform a fetch and
// lazily populate the cache.
// lazily populate the cache
only if the resource was successfully fetched
.
return
response
||
fetch
(
event
.
request
).
then
((
response
)
=>
{
cache
.
put
(
event
.
request
,
response
.
clone
());
if
(
response
&&
Boolean
(
response
.
ok
))
{
cache
.
put
(
event
.
request
,
response
.
clone
());
}
return
response
;
});
})
...
...
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