forked from firka/flutter
[web] DRY up access to headers required for multi-threaded WebAssembly (#163555)
This commit is contained in:
@@ -41,6 +41,7 @@ import '../web/chrome.dart';
|
||||
import '../web/compile.dart';
|
||||
import '../web/memory_fs.dart';
|
||||
import '../web/module_metadata.dart';
|
||||
import '../web/web_constants.dart';
|
||||
import '../web_template.dart';
|
||||
|
||||
typedef DwdsLauncher =
|
||||
@@ -1315,11 +1316,8 @@ class ReleaseAssetServer {
|
||||
'Content-Type': mimeType,
|
||||
'Cross-Origin-Resource-Policy': 'cross-origin',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
if (_needsCoopCoep &&
|
||||
_fileSystem.path.extension(file.path) == '.html') ...<String, String>{
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'credentialless',
|
||||
},
|
||||
if (_needsCoopCoep && _fileSystem.path.extension(file.path) == '.html')
|
||||
...kMultiThreadedHeaders,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1329,10 +1327,7 @@ class ReleaseAssetServer {
|
||||
file.readAsBytesSync(),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'text/html',
|
||||
if (_needsCoopCoep) ...<String, String>{
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'credentialless',
|
||||
},
|
||||
if (_needsCoopCoep) ...kMultiThreadedHeaders,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import '../web/bootstrap.dart';
|
||||
import '../web/chrome.dart';
|
||||
import '../web/compile.dart';
|
||||
import '../web/memory_fs.dart';
|
||||
import '../web/web_constants.dart';
|
||||
import 'test_compiler.dart';
|
||||
import 'test_golden_comparator.dart';
|
||||
import 'test_time_recorder.dart';
|
||||
@@ -57,10 +58,7 @@ shelf.Handler createDirectoryHandler(Directory directory, {required bool crossOr
|
||||
file.openRead(),
|
||||
headers: <String, String>{
|
||||
if (contentType != null) 'Content-Type': contentType,
|
||||
if (needsCrossOriginIsolated) ...<String, String>{
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'credentialless',
|
||||
},
|
||||
if (needsCrossOriginIsolated) ...kMultiThreadedHeaders,
|
||||
},
|
||||
);
|
||||
};
|
||||
@@ -551,10 +549,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
''',
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'text/html',
|
||||
if (webRenderer == WebRendererMode.skwasm) ...<String, String>{
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'credentialless',
|
||||
},
|
||||
if (webRenderer == WebRendererMode.skwasm) ...kMultiThreadedHeaders,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,3 +3,12 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
const String kWasmMoreInfo = 'See https://flutter.dev/to/wasm for more information.';
|
||||
|
||||
/// Headers required to run Wasm-compiled applications with multi-threading.
|
||||
///
|
||||
/// See https://developer.chrome.com/blog/coep-credentialless-origin-trial
|
||||
/// for more information.
|
||||
const Map<String, String> kMultiThreadedHeaders = <String, String>{
|
||||
'Cross-Origin-Opener-Policy': 'same-origin',
|
||||
'Cross-Origin-Embedder-Policy': 'credentialless',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user