summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/dynamic-import/update-to-dynamic-import.js
blob: d1a9469ed5e175750549eaecf95908341c9d435b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// |reftest| async
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
    Resolve imports after a binding update
esid: sec-finishdynamicimport
info: |
    Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion )

    2. Otherwise,
        a. Assert: completion is a normal completion and completion.[[Value]] is undefined.
        b. Let moduleRecord be ! HostResolveImportedModule(referencingScriptOrModule, specifier).
        c. Assert: Evaluate has already been invoked on moduleRecord and successfully completed.
        d. Let namespace be GetModuleNamespace(moduleRecord).
        ...
        f. Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »).
flags: [async]
features: [dynamic-import]
includes: [asyncHelpers.js]
---*/

async function fn() {
    const first = await import('./update-to-dynamic-import_FIXTURE.js');
    assert.sameValue(first.x, 'first', 'the other module has not been evaluated yet');

    const other = await first.default();

    assert.sameValue(first.x, 'other', 'the other module is only evaluated after calling import()');
    assert.sameValue(other.default, 42);
}

asyncTest(fn);