summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2019-11-22 22:06:43 -0500
committerbcoe <bencoe@google.com>2019-11-30 20:07:52 -0800
commit49fb529139ff4b43f472e24f2015482af82446b6 (patch)
treee6eca7fb0ec36c92d6afbb45a3cbe1fd5affd09f /test
parent6bf5a1d691291cdfcc4941e68f00d0003e565476 (diff)
downloadandroid-node-v8-49fb529139ff4b43f472e24f2015482af82446b6.tar.gz
android-node-v8-49fb529139ff4b43f472e24f2015482af82446b6.tar.bz2
android-node-v8-49fb529139ff4b43f472e24f2015482af82446b6.zip
repl: fix referrer for dynamic import
The ESM loader does not accept a directory as the referrer, it requires a path within the directory. Add `/repl` to ensure relative dynamic imports can succeed. Fixes: https://github.com/nodejs/node/issues/19570 PR-URL: https://github.com/nodejs/node/pull/30609 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Coe <bencoe@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-repl-import-referrer.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-repl-import-referrer.js b/test/parallel/test-repl-import-referrer.js
new file mode 100644
index 0000000000..33bc442e6f
--- /dev/null
+++ b/test/parallel/test-repl-import-referrer.js
@@ -0,0 +1,24 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const cp = require('child_process');
+const fixtures = require('../common/fixtures');
+
+const args = ['--interactive', '--experimental-repl-await'];
+const opts = { cwd: fixtures.path('es-modules') };
+const child = cp.spawn(process.execPath, args, opts);
+
+let output = '';
+child.stdout.setEncoding('utf8');
+child.stdout.on('data', (data) => {
+ output += data;
+});
+
+child.on('exit', common.mustCall(() => {
+ const results = output.replace(/^> /mg, '').split('\n').slice(2);
+ assert.deepStrictEqual(results, ['[Module] { message: \'A message\' }', '']);
+}));
+
+child.stdin.write('await import(\'./message.mjs\');\n');
+child.stdin.write('.exit');
+child.stdin.end();