@@ -52,6 +52,8 @@ class BrowserWasmPlatform extends PlatformPlugin
52
52
Uri .parse ('package:test/src/runner/browser/static/favicon.ico' ))),
53
53
p.fromUri (packageConfig.resolve (
54
54
Uri .parse ('package:test/src/runner/wasm/static/default.html.tpl' ))),
55
+ p.fromUri (packageConfig.resolve (
56
+ Uri .parse ('package:test/src/runner/wasm/static/run_wasm_chrome.js' ))),
55
57
root: root);
56
58
}
57
59
@@ -117,8 +119,11 @@ class BrowserWasmPlatform extends PlatformPlugin
117
119
/// The default template for html tests.
118
120
final String _defaultTemplatePath;
119
121
122
+ /// The `package:test` side wrapper for the Dart2Wasm runtime.
123
+ final String _jsRuntimeWrapper;
124
+
120
125
BrowserWasmPlatform ._(this ._server, Configuration config, String faviconPath,
121
- this ._defaultTemplatePath,
126
+ this ._defaultTemplatePath, this ._jsRuntimeWrapper,
122
127
{String ? root})
123
128
: _config = config,
124
129
_root = root ?? p.current {
@@ -159,9 +164,11 @@ class BrowserWasmPlatform extends PlatformPlugin
159
164
var testName = htmlEscape.convert (test);
160
165
var template = _config.customHtmlTemplatePath ?? _defaultTemplatePath;
161
166
var contents = File (template).readAsStringSync ();
167
+ var jsRuntime = 'dart2wasm_runtime.mjs' ;
162
168
var processedContents = contents
163
169
// Checked during loading phase that there is only one {{testScript}} placeholder.
164
170
.replaceFirst ('{{testScript}}' , link)
171
+ .replaceFirst ('{{jsRuntimeUrl}}' , jsRuntime)
165
172
.replaceFirst ('{{wasmUrl}}' ,
166
173
p.basename ('$test .browser_test.dart.wasm' ))
167
174
.replaceAll ('{{testName}}' , testName);
@@ -242,7 +249,8 @@ class BrowserWasmPlatform extends PlatformPlugin
242
249
var baseUrl =
243
250
'${p .toUri (p .relative (dartPath , from : _root )).path }.browser_test.dart' ;
244
251
var wasmUrl = '$baseUrl .wasm' ;
245
- var jsUrl = '$baseUrl .js' ;
252
+ var jsRuntimeWrapperUrl = '$baseUrl .js' ;
253
+ var jsRuntimeUrl = p.join (p.dirname (dartPath), 'dart2wasm_runtime.mjs' );
246
254
var htmlUrl = '$baseUrl .html' ;
247
255
248
256
// TODO: This may need to be specialized, or it may just work. Not sure.
@@ -266,9 +274,14 @@ class BrowserWasmPlatform extends PlatformPlugin
266
274
headers: {'Content-Type' : 'application/wasm' });
267
275
});
268
276
269
- var jsPath = '$baseCompiledPath .js' ;
270
- _wasmHandler.add (jsUrl, (request) {
271
- return shelf.Response .ok (File (jsPath).readAsBytesSync (),
277
+ _wasmHandler.add (jsRuntimeWrapperUrl, (request) {
278
+ return shelf.Response .ok (File (_jsRuntimeWrapper).readAsBytesSync (),
279
+ headers: {'Content-Type' : 'application/javascript' });
280
+ });
281
+
282
+ var jsRuntimePath = p.join (dir, 'dart2wasm_runtime.mjs' );
283
+ _wasmHandler.add (jsRuntimeUrl, (request) {
284
+ return shelf.Response .ok (File (jsRuntimePath).readAsBytesSync (),
272
285
headers: {'Content-Type' : 'application/javascript' });
273
286
});
274
287
0 commit comments