mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 05:27:23 +00:00
host promise rejection
This commit is contained in:
@@ -100,6 +100,7 @@ void main() async {
|
||||
moduleHandler: (name) {
|
||||
return "export default '${new DateTime.now()}'";
|
||||
},
|
||||
hostPromiseRejectionHandler: (_) {},
|
||||
);
|
||||
qjs.dispatch();
|
||||
await testEvaluate(qjs);
|
||||
@@ -112,6 +113,7 @@ void main() async {
|
||||
moduleHandler: (name) async {
|
||||
return "export default '${new DateTime.now()}'";
|
||||
},
|
||||
hostPromiseRejectionHandler: (_) {},
|
||||
);
|
||||
await testEvaluate(qjs);
|
||||
qjs.close();
|
||||
@@ -141,4 +143,22 @@ void main() async {
|
||||
}
|
||||
qjs.close();
|
||||
});
|
||||
test('host promise rejection', () async {
|
||||
final completer = Completer();
|
||||
final qjs = FlutterQjs(
|
||||
hostPromiseRejectionHandler: (reason) {
|
||||
completer.complete(reason);
|
||||
},
|
||||
);
|
||||
qjs.dispatch();
|
||||
qjs.evaluate(
|
||||
"(() => { Promise.resolve().then(() => { throw 'unhandle' }) })()",
|
||||
name: "<eval>");
|
||||
Future.delayed(Duration(seconds: 10)).then((value) {
|
||||
if (!completer.isCompleted) completer.completeError("not host reject");
|
||||
});
|
||||
expect(await completer.future, "unhandle",
|
||||
reason: "host promise rejection");
|
||||
qjs.close();
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user