[flutter_tools] cache-bust in service worker (#56786)
This commit is contained in:
19
dev/integration_tests/web/lib/service_worker_test.dart
Normal file
19
dev/integration_tests/web/lib/service_worker_test.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
// 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 'dart:html' as html;
|
||||
Future<void> main() async {
|
||||
final html.ServiceWorkerRegistration worker = await html.window.navigator.serviceWorker.ready;
|
||||
if (worker.active != null) {
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
await html.HttpRequest.getString('CLOSE');
|
||||
return;
|
||||
}
|
||||
worker.addEventListener('statechange', (event) async {
|
||||
if (worker.active != null) {
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
await html.HttpRequest.getString('CLOSE');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -5,6 +5,11 @@ environment:
|
||||
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
|
||||
sdk: ">=2.6.0 <3.0.0"
|
||||
|
||||
flutter:
|
||||
assets:
|
||||
- lib/a.dart
|
||||
- lib/b.dart
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
@@ -2,12 +2,25 @@
|
||||
<!-- 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. -->
|
||||
<html lang="en">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>web_integration</title>
|
||||
<script defer src="main.dart.js" type="application/javascript"></script>
|
||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||
|
||||
<title>Web Test</title>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
</head>
|
||||
<body>
|
||||
<!-- This script installs service_worker.js to provide PWA functionality to
|
||||
application. For more information, see:
|
||||
https://developers.google.com/web/fundamentals/primers/service-workers -->
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function () {
|
||||
navigator.serviceWorker.register('flutter_service_worker.js');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script src="main.dart.js" type="application/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
12
dev/integration_tests/web/web/manifest.json
Normal file
12
dev/integration_tests/web/web/manifest.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "web_integration_test",
|
||||
"short_name": "web_integration_test",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"background_color": "#0175C2",
|
||||
"theme_color": "#0175C2",
|
||||
"description": "A new Flutter project.",
|
||||
"orientation": "portrait-primary",
|
||||
"prefer_related_applications": false,
|
||||
"icons": []
|
||||
}
|
||||
Reference in New Issue
Block a user