mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:35:01 +00:00
Remove remaining support for dart:isolate on web
Closes #37153 Isolate.resolvePackageUri was the only API which had an implementation across DDC and dart2js. The implementation in dart2js has been broken by default since Dart 2.0.0 without a user implemented hook that is not used on any public repo on github. Our current supported path for invoking the compilers on projects disallows the import altogether on the web and it is only usable with an older version of the `build_web_compilers` package, or by invoking the compiler manually outside of the build system. This CL does not break the ability to have the import when invoking outside of the build system. - Drop implementation for `Isolate.resolvePackageUri` from the dart2js and DDC patch files. - Drop all references to `defaultPackagesBase` since it is not used. - Drop all tests under `isolate/browser` since we do not expect any support on the web. Most of these tests would have already been failing. Remove status file entries that refer to the deleted tests. Change-Id: I4a19213b0946d835c00e9c107a714f3bc5672f86 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105080 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Nate Bosch <nbosch@google.com>
This commit is contained in:
parent
7a1af14458
commit
8614f86c9b
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -56,6 +56,17 @@ class B<X> extends A<void Function(X)> {};
|
|||
interface, this is a breaking change, as implementing classes will need to
|
||||
implement the new getter.
|
||||
|
||||
#### `dart:isolate`
|
||||
|
||||
* **Breaking change**: `Isolate.resolvePackageUri` will always throw an
|
||||
`UnsupportedError` when compiled with dart2js or DDC. This was the only
|
||||
remaining API in `dart:isolate` that didn't automatically throw since we
|
||||
dropped support for this library in [Dart 2.0.0][1]. Note that the API already
|
||||
throws in dart2js if the API is used directly without setting up manually a
|
||||
`defaultPackagesBase` hook.
|
||||
|
||||
[1]: https://github.com/dart-lang/sdk/blob/master/CHANGELOG.md#200---2018-08-07
|
||||
|
||||
### Dart VM
|
||||
|
||||
### Tools
|
||||
|
|
|
@ -37,8 +37,4 @@ const String HOOKS_API_USAGE = """
|
|||
// if this function is defined, it will be called at each entry of a
|
||||
// method or constructor. Used only when compiling programs with
|
||||
// --experiment-call-instrumentation.
|
||||
//
|
||||
// defaultPackagesBase:
|
||||
// Override the location where `package:` uris are resolved from. By default
|
||||
// they are resolved under "packages/" from the current window location.
|
||||
""";
|
||||
|
|
|
@ -23,13 +23,8 @@ class Isolate {
|
|||
@patch
|
||||
static Future<Uri> get packageConfig => _unsupported();
|
||||
|
||||
static Uri _packageBase = Uri.base.resolve('packages/');
|
||||
|
||||
@patch
|
||||
static Future<Uri> resolvePackageUri(Uri packageUri) async {
|
||||
if (packageUri.scheme != 'package') return packageUri;
|
||||
return _packageBase.resolveUri(packageUri.replace(scheme: ''));
|
||||
}
|
||||
static Future<Uri> resolvePackageUri(Uri packageUri) => _unsupported();
|
||||
|
||||
@patch
|
||||
static Future<Isolate> spawn<T>(void entryPoint(T message), T message,
|
||||
|
|
|
@ -33,11 +33,7 @@ class Isolate {
|
|||
|
||||
@patch
|
||||
static Future<Uri> resolvePackageUri(Uri packageUri) {
|
||||
if (packageUri.scheme != 'package') {
|
||||
return new Future<Uri>.value(packageUri);
|
||||
}
|
||||
return new Future<Uri>.value(
|
||||
_packagesBase.resolveUri(packageUri.replace(scheme: '')));
|
||||
throw new UnsupportedError("Isolate.resolvePackageUri");
|
||||
}
|
||||
|
||||
@patch
|
||||
|
@ -154,10 +150,3 @@ abstract class TransferableTypedData {
|
|||
throw new UnsupportedError('TransferableTypedData.fromList');
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the base path added to Uri.base to resolve `package:` Uris.
|
||||
///
|
||||
/// This is used by `Isolate.resolvePackageUri` to load resources. The default
|
||||
/// value is `packages/` but users can override this by using the
|
||||
/// `defaultPackagesBase` hook.
|
||||
Uri _packagesBase = Uri.base.resolve(JS('String', r'self.defaultPackagesBase'));
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// Test that spawn works even when there are many script files in the page.
|
||||
// This requires computing correctly the URL to the orignal script, so we can
|
||||
// pass it to the web worker APIs.
|
||||
library compute_this_script;
|
||||
|
||||
import 'dart:html';
|
||||
import 'dart:isolate';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import "../remote_unittest_helper.dart";
|
||||
|
||||
child(var message) {
|
||||
var data = message[0];
|
||||
var reply = message[1];
|
||||
reply.send('re: $data');
|
||||
}
|
||||
|
||||
void main([args, port]) {
|
||||
if (testRemote(main, port)) return;
|
||||
useHtmlConfiguration();
|
||||
var script = new ScriptElement();
|
||||
document.body.append(script);
|
||||
test('spawn with other script tags in page', () {
|
||||
ReceivePort port = new ReceivePort();
|
||||
port.listen(expectAsync((msg) {
|
||||
expect(msg, equals('re: hi'));
|
||||
port.close();
|
||||
}));
|
||||
|
||||
Isolate.spawn(child, ['hi', port.sendPort]);
|
||||
});
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
import 'dart:isolate';
|
||||
import 'package:issue_12474_lib.dart';
|
||||
|
||||
void main([args, port]) {
|
||||
testPackageRoot(args);
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
import 'dart:isolate';
|
||||
|
||||
final SPAWN_PACKAGE_ROOT = Uri.parse(".");
|
||||
|
||||
void main([args, port]) {
|
||||
var p = new ReceivePort();
|
||||
Isolate.spawnUri(
|
||||
Uri.parse("issue_12474_child.dart"), [p.sendPort as dynamic], {},
|
||||
packageRoot: SPAWN_PACKAGE_ROOT);
|
||||
p.listen((msg) {
|
||||
print("Received message");
|
||||
p.close();
|
||||
});
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
// Copyright (c) 2015, 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 testPackageRoot(args) {
|
||||
args[0].send(null);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
import 'dart:js';
|
||||
import 'dart:isolate';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
|
||||
main() async {
|
||||
useHtmlConfiguration();
|
||||
|
||||
setUp(() {
|
||||
context['defaultPackagesBase'] = 'path1/';
|
||||
});
|
||||
|
||||
test('hook overrides package-uri resolution', () async {
|
||||
var uri = await Isolate.resolvePackageUri(Uri.parse('package:foo/bar.txt'));
|
||||
expect(uri, Uri.base.resolve('path1/foo/bar.txt'));
|
||||
});
|
||||
|
||||
test('hook is read once, on the first use of resolvePackageUri', () async {
|
||||
await Isolate.resolvePackageUri(Uri.parse('package:foo/bar.txt'));
|
||||
context['defaultPackagesBase'] = 'path2/';
|
||||
var uri = await Isolate.resolvePackageUri(Uri.parse('package:foo/bar.txt'));
|
||||
expect(uri, Uri.base.resolve('path1/foo/bar.txt'));
|
||||
});
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
import 'dart:isolate';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
|
||||
main() async {
|
||||
useHtmlConfiguration();
|
||||
|
||||
test('defaultPackagesBase hook overrides package-uri resolution', () async {
|
||||
var uri = await Isolate.resolvePackageUri(Uri.parse('package:foo/bar.txt'));
|
||||
expect(uri, Uri.base.resolve('path/set/from/hook/foo/bar.txt'));
|
||||
});
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="dart.unittest" content="full-stack-traces">
|
||||
<title> mirrors_test </title>
|
||||
<style>
|
||||
.unittest-table { font-family:monospace; border:1px; }
|
||||
.unittest-pass { background: #6b3;}
|
||||
.unittest-fail { background: #d55;}
|
||||
.unittest-error { background: #a11;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1> Running mirrors_test </h1>
|
||||
<script type="text/javascript"
|
||||
src="/root_dart/tools/testing/dart/test_controller.js"></script>
|
||||
<script>
|
||||
// Dart2js exposes this hook to override the default base path where resource
|
||||
// package uris are resolved from.
|
||||
defaultPackagesBase = 'path/set/from/hook/';
|
||||
</script>
|
||||
%TEST_SCRIPTS%
|
||||
</body>
|
||||
</html>
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
import 'dart:isolate';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
|
||||
main() {
|
||||
useHtmlConfiguration();
|
||||
|
||||
test('by default package-uri resolve under base/packages/', () async {
|
||||
var uri = await Isolate.resolvePackageUri(Uri.parse('package:foo/bar.txt'));
|
||||
expect(uri, Uri.base.resolve('packages/foo/bar.txt'));
|
||||
});
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// Dart test program for testing serialization of messages.
|
||||
// VMOptions=--enable_type_checks --enable_asserts
|
||||
|
||||
library TypedDataMessageTest;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:isolate';
|
||||
import 'dart:typed_data';
|
||||
import 'package:unittest/unittest.dart';
|
||||
import "../remote_unittest_helper.dart";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Message passing test.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
List elements;
|
||||
|
||||
void initializeList() {
|
||||
elements = new List(3);
|
||||
elements[0] = new Int8List(10);
|
||||
for (int j = 0; j < 10; j++) {
|
||||
elements[0][j] = j;
|
||||
}
|
||||
elements[1] = new ByteData.view(elements[0].buffer, 0, 10);
|
||||
for (int j = 0; j < 10; j++) {
|
||||
elements[1].setInt8(j, j + 100);
|
||||
}
|
||||
elements[2] = new Int8List.view(new Int8List(100).buffer, 50, 10);
|
||||
for (int j = 0; j < 10; j++) {
|
||||
elements[2][j] = j + 250;
|
||||
}
|
||||
}
|
||||
|
||||
void VerifyList(List expected, List actual) {
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
expect(actual[i], expected[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void VerifyBytedata(ByteData expected, ByteData actual) {
|
||||
for (int i = 0; i < expected.lengthInBytes; i++) {
|
||||
expect(actual.getInt8(i), expected.getInt8(i));
|
||||
}
|
||||
}
|
||||
|
||||
void VerifyObject(int index, var actual) {
|
||||
var expected = elements[index];
|
||||
if (expected is List) {
|
||||
expect(actual, isList);
|
||||
VerifyList(expected, actual);
|
||||
} else {
|
||||
expect(true, actual is ByteData);
|
||||
VerifyBytedata(expected, actual);
|
||||
}
|
||||
expect(actual.length, expected.length);
|
||||
}
|
||||
|
||||
pingPong(SendPort initialReplyTo) {
|
||||
var port = new ReceivePort();
|
||||
initialReplyTo.send(port.sendPort);
|
||||
initializeList();
|
||||
int count = 0;
|
||||
port.listen((var message) {
|
||||
var data = message[0];
|
||||
SendPort replyTo = message[1];
|
||||
if (data == -1) {
|
||||
port.close();
|
||||
replyTo.send(count);
|
||||
} else {
|
||||
// Check if the received object is correct.
|
||||
if (count < elements.length) {
|
||||
VerifyObject(count, data);
|
||||
}
|
||||
// Bounce the received object back so that the sender
|
||||
// can make sure that the object matches.
|
||||
replyTo.send(data);
|
||||
count++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future sendReceive(SendPort port, msg) {
|
||||
ReceivePort response = new ReceivePort();
|
||||
port.send([msg, response.sendPort]);
|
||||
return response.first;
|
||||
}
|
||||
|
||||
void main([args, port]) {
|
||||
if (testRemote(main, port)) return;
|
||||
initializeList();
|
||||
test("send objects and receive them back", () {
|
||||
ReceivePort response = new ReceivePort();
|
||||
Isolate.spawn(pingPong, response.sendPort);
|
||||
response.first.then((_remote) {
|
||||
SendPort remote = _remote;
|
||||
// Send objects and receive them back.
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
var sentObject = elements[i];
|
||||
var idx = i;
|
||||
sendReceive(remote, sentObject).then(expectAsync((var receivedObject) {
|
||||
VerifyObject(idx, receivedObject);
|
||||
}));
|
||||
}
|
||||
|
||||
// Shutdown the MessageServer.
|
||||
sendReceive(remote, -1).then(expectAsync((int message) {
|
||||
expect(message, elements.length);
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
|
@ -139,7 +139,6 @@ async/periodic_timer3_test: Pass, RuntimeError # Flaky. Issue 32094
|
|||
async/periodic_timer4_test: Pass, RuntimeError # Flaky. Issue 32094
|
||||
|
||||
[ $csp ]
|
||||
isolate/browser/package_resolve_browser_hook_test: SkipByDesign # Test written in a way that violates CSP.
|
||||
isolate/deferred_in_isolate2_test: Skip # Issue 16898. Deferred loading does not work from an isolate in CSP-mode
|
||||
|
||||
[ $hot_reload ]
|
||||
|
@ -215,7 +214,6 @@ async/slow_consumer2_test: SkipSlow # Times out. Issue 22050
|
|||
async/stream_timeout_test: SkipSlow # Times out. Issue 22050
|
||||
|
||||
[ $runtime == dart_precompiled || $runtime == vm ]
|
||||
isolate/browser/*: SkipByDesign # Browser specific tests
|
||||
isolate/isolate_stress_test: Skip # Issue 12588: Uses dart:html. This should be able to pass when we have wrapper-less tests.
|
||||
isolate/stacktrace_message_test: RuntimeError # Fails to send stacktrace object.
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ mirrors/method_mirror_location_test: Crash # runtime/lib/mirrors.cc: 1634: error
|
|||
|
||||
[ $compiler == fasta ]
|
||||
html/*: Skip # TODO(ahe): Make dart:html available.
|
||||
isolate/browser/*: Skip # TODO(ahe): Make dart:html available.
|
||||
isolate/isolate_stress_test: CompileTimeError
|
||||
js/*: Skip # TODO(ahe): Make dart:js available.
|
||||
mirrors/deferred_type_test: CompileTimeError
|
||||
|
@ -221,7 +220,6 @@ mirrors/library_uri_package_test: Skip # Timeout
|
|||
|
||||
[ $compiler == app_jitk || $compiler == dartk || $compiler == dartkb || $compiler == dartkp ]
|
||||
html/*: SkipByDesign
|
||||
isolate/browser/*: SkipByDesign
|
||||
js/*: SkipByDesign
|
||||
|
||||
[ $compiler == dartk || $compiler == dartkb ]
|
||||
|
|
Loading…
Reference in a new issue