mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
test: testcase demonstrating issue 59541
Check that we lose the execution flow in the outer context, upon resolving a promise created in in the inner context. PR-URL: https://github.com/nodejs/node/pull/59801 Fixes: https://github.com/nodejs/node/issues/59541 Refs: https://issues.chromium.org/issues/441679231 Refs: https://groups.google.com/g/v8-dev/c/YIeRg8CUNS8/m/rEQdFuNZAAAJ Refs: https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
396cc8ec65
commit
ce8435b003
1 file changed
+34
@@ -0,0 +1,34 @@
|
||||
// Flags: --experimental-vm-modules
|
||||
'use strict';
|
||||
|
||||
// https://github.com/nodejs/node/issues/59541
|
||||
//
|
||||
// Promises created in a context using microtaskMode: "aferEvaluate" (meaning it
|
||||
// has its own microtask queue), when resolved in the surrounding context, will
|
||||
// schedule a task back onto the inner context queue.
|
||||
|
||||
const common = require('../common');
|
||||
const vm = require('vm');
|
||||
|
||||
const microtaskMode = 'afterEvaluate';
|
||||
|
||||
(async () => {
|
||||
const mustNotCall1 = common.mustNotCall();
|
||||
const mustNotCall2 = common.mustNotCall();
|
||||
|
||||
const inner = {};
|
||||
|
||||
const context = vm.createContext({ inner }, { microtaskMode });
|
||||
|
||||
const module = new vm.SourceTextModule(
|
||||
'inner.promise = Promise.resolve();',
|
||||
{ context },
|
||||
);
|
||||
|
||||
await module.link(mustNotCall1);
|
||||
await module.evaluate();
|
||||
|
||||
// This is Issue 59541, the next statement is not executed, of course
|
||||
// it should be.
|
||||
mustNotCall2();
|
||||
})().then(common.mustNotCall());
|
||||
Reference in new issue
Block a user