43f234799e
The generated callback wrappers were referring to exported functions via 'dartInstance.exports' which is always the main module. But in order to avoid bloating the main module we put some of these JS exports into submodules. So the wrapper must be fetched from the correct module that defines the wrapped function. In order to facilitate this we give each module a self-reference that it can then pass up to the JS wrapper as an externref. Change-Id: Id2514de2c13d38a0cee1f6c935e45a9ef826f805 Fixes: https://github.com/dart-lang/sdk/issues/62094 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464820 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Nate Biggs <natebiggs@google.com>
27 lines
776 B
Dart
27 lines
776 B
Dart
// Copyright (c) 2025, 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.
|
|
|
|
// dart2wasmOptions=--enable-deferred-loading
|
|
|
|
import 'dart:js_interop';
|
|
|
|
import 'package:async_helper/async_helper.dart';
|
|
import 'package:expect/expect.dart';
|
|
|
|
import 'deferred_loading_js_callback_helper.dart' deferred as D;
|
|
|
|
main() async {
|
|
asyncStart();
|
|
await D.loadLibrary();
|
|
Expect.equals(D.closureCalled, 0);
|
|
D.deferredMain();
|
|
Expect.equals(D.closureCalled, 1);
|
|
D.func!.callAsFunction();
|
|
Expect.equals(D.closureCalled, 2);
|
|
final jsClosure = D.clos!.toJS;
|
|
jsClosure.callAsFunction();
|
|
Expect.equals(D.closureCalled, 3);
|
|
asyncEnd();
|
|
}
|