Debian Codegraph @

js/src/tests/test262/language/expressions/dynamic-import/assignment-expression/import-meta.js

raw
1 // |reftest| module async
2 // Copyright (C) 2018 Leo Balter. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: >
6 Dynamic Import receives an AssignmentExpression (ImportMeta)
7 esid: prod-ImportCall
8 info: |
9 ImportCall [Yield]:
10 import ( AssignmentExpression[+In, ?Yield] )
11
12 Runtime Semantics: Evaluation
13
14 ImportCall : import ( AssignmentExpression )
15
16 ...
17 5. Let specifierString be ToString(specifier).
18 6. IfAbruptRejectPromise(specifierString, promiseCapability).
19 features: [dynamic-import, import.meta]
20 flags: [module, async]
21 ---*/
22
23 const p = import(import.meta);
24
25 // We can at least assert p is a promise.
26 assert.sameValue(Promise.resolve(p), p, 'Assert that p is a promise');
27
28 // The keys of import.meta are implementation defined, but we know its
29 // [[Prototype]] is null. In this case, import() should reject the
30 // promise it returns, unless a toPrimitive related method is set.
31 if (!Object.prototype.hasOwnProperty.call(import.meta, 'toString') &&
32 !Object.prototype.hasOwnProperty.call(import.meta, 'valueOf') &&
33 !Object.prototype.hasOwnProperty.call(import.meta, Symbol.toPrimitive)) {
34 p.catch(error => assert.sameValue(error.constructor, TypeError, 'import() cannot resolve import.meta')).then($DONE, $DONE);
35 } else {
36 $DONE();
37 }