2018-01-13 23:35:51 -08:00
|
|
|
'use strict';
|
|
|
|
|
2018-08-12 23:37:33 +02:00
|
|
|
// Flags: --experimental-vm-modules --experimental-modules
|
2018-01-13 23:35:51 -08:00
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
|
|
|
|
const assert = require('assert');
|
2018-07-27 21:21:30 -05:00
|
|
|
const { SourceTextModule, createContext } = require('vm');
|
2018-01-13 23:35:51 -08:00
|
|
|
|
|
|
|
const finished = common.mustCall();
|
|
|
|
|
|
|
|
(async function() {
|
2018-07-27 21:21:30 -05:00
|
|
|
const m = new SourceTextModule('import("foo")', { context: createContext() });
|
2018-01-13 23:35:51 -08:00
|
|
|
await m.link(common.mustNotCall());
|
|
|
|
m.instantiate();
|
|
|
|
const { result } = await m.evaluate();
|
|
|
|
let threw = false;
|
|
|
|
try {
|
|
|
|
await result;
|
|
|
|
} catch (err) {
|
|
|
|
threw = true;
|
|
|
|
assert.strictEqual(err.message, 'import() called outside of main context');
|
|
|
|
}
|
|
|
|
assert(threw);
|
|
|
|
finished();
|
|
|
|
}());
|