mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Ensure isolates have a root library so createMirrorSystem() and spawnUri() are happy.
https://github.com/domokit/mojo/issues/98 R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1088263004
This commit is contained in:
parent
11315b5314
commit
a6ffc52bea
@ -204,6 +204,10 @@ static Dart_Isolate IsolateCreateCallback(const char* script_uri,
|
||||
DartApiScope apiScope;
|
||||
Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
|
||||
Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary);
|
||||
|
||||
// Ensure the isolate has a root library.
|
||||
Dart_LoadScript(Dart_NewStringFromCString("dart:empty"),
|
||||
Dart_NewStringFromCString(""), 0, 0);
|
||||
}
|
||||
|
||||
Dart_ExitIsolate();
|
||||
@ -273,6 +277,10 @@ void DartController::CreateIsolateFor(Document* document) {
|
||||
{
|
||||
DartApiScope apiScope;
|
||||
|
||||
// Ensure the isolate has a root library.
|
||||
Dart_LoadScript(Dart_NewStringFromCString("dart:empty"),
|
||||
Dart_NewStringFromCString(""), 0, 0);
|
||||
|
||||
Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
|
||||
Builtin::SetNativeResolver(Builtin::kMojoInternalLibrary);
|
||||
BuiltinNatives::Init();
|
||||
|
||||
1
tests/dart/mirror-system-expected.txt
Normal file
1
tests/dart/mirror-system-expected.txt
Normal file
@ -0,0 +1 @@
|
||||
PASS
|
||||
14
tests/dart/mirror-system.sky
Normal file
14
tests/dart/mirror-system.sky
Normal file
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import "dart:mirrors";
|
||||
import "dart:sky.internals" as internals;
|
||||
|
||||
// Regression test for the embedder not setting up the root library.
|
||||
// Used to crash.
|
||||
|
||||
void main() {
|
||||
if (currentMirrorSystem().isolate.rootLibrary == null) {
|
||||
throw "Missing root library";
|
||||
}
|
||||
internals.notifyTestComplete("PASS");
|
||||
}
|
||||
</script>>
|
||||
Loading…
x
Reference in New Issue
Block a user