[dart2wasm] Fix Uri.base in d8
Currently when the .wasm file path passed to run_wasm.js is a relative path, `Uri.base` becomes something like `file://test.wasm`, which is not a valid file URI, so it causes crashes in `Uri.toFilePath`. When the file path is relative add a omit `file://` prefix. `Uri.base` values before and after: - Before, relative .wasm path: `file://test.wasm` (invalid) - Before, absolute .wasm path: `file:///home/user/test.wasm` - After, relative .wasm path: `test.wasm` (fixed) - After, absolute .wasm path: `file:///home/user/test.wasm` (same as before) Change-Id: I0d1c43716e07a9ee926e7feeeab514c2c66bac16 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385700 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
committed by
Commit Queue
parent
3932452322
commit
f80214eb86
@@ -364,7 +364,11 @@ if (argsSplit != -1) {
|
||||
self.Response = function () { }
|
||||
|
||||
self.location = {}
|
||||
self.location.href = 'file://' + args[wasmArg];
|
||||
if (args[wasmArg].startsWith('/')) {
|
||||
self.location.href = 'file://' + args[wasmArg];
|
||||
} else {
|
||||
self.location.href = args[wasmArg];
|
||||
}
|
||||
|
||||
// Signals `Stopwatch._initTicker` to use `Date.now` to get ticks instead of
|
||||
// `performance.now`, as it's not available in d8.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
void main() {
|
||||
print(Uri.base.toFilePath()); // should not crash
|
||||
}
|
||||
@@ -57,6 +57,7 @@ code_motion_exception_test: Skip # Required V8 specific format of JavaScript err
|
||||
[ $compiler == dart2wasm && $runtime != d8 ]
|
||||
wasm/source_map_simple_test: SkipByDesign # Reads source map file using d8's readbuffer
|
||||
wasm/source_map_simple_optimized_test: SkipByDesign # Reads source map file using d8's readbuffer
|
||||
wasm/uri_base_test: SkipByDesign # Converts Uri.base to file path
|
||||
|
||||
[ $compiler == dartk && $runtime == vm ]
|
||||
new_from_env_test: SkipByDesign # dart2js only test
|
||||
|
||||
Reference in New Issue
Block a user