| 1 |
// |jit-test| module |
| 2 |
|
| 3 |
// import.meta is an object. |
| 4 |
assertEq(typeof import.meta, "object"); |
| 5 |
assertEq(import.meta !== null, true); |
| 6 |
|
| 7 |
// import.meta always returns the same object. |
| 8 |
let obj = import.meta; |
| 9 |
assertEq(import.meta, obj); |
| 10 |
|
| 11 |
// Test calling from lazily compile function. |
| 12 |
function get() { |
| 13 |
return import.meta; |
| 14 |
} |
| 15 |
assertEq(get(), import.meta); |
| 16 |
|
| 17 |
// import.meta.url: This property will contain the module script's base URL, |
| 18 |
// serialized. |
| 19 |
|
| 20 |
assertEq("url" in import.meta, true); |
| 21 |
assertEq(import.meta.url.endsWith("import-meta.js"), true); |
| 22 |
|
| 23 |
assertEq("resolve" in import.meta, true); |
| 24 |
|
| 25 |
assertEq(import.meta.resolve("./x"), |
| 26 |
import.meta.url.replace("import-meta.js", "x")); |
| 27 |
|
| 28 |
import getOtherMetaObject from "exportImportMeta.js"; |
| 29 |
|
| 30 |
let otherImportMeta = getOtherMetaObject(); |
| 31 |
assertEq(otherImportMeta.url.endsWith("exportImportMeta.js"), true); |
| 32 |
|
| 33 |
// By default the import.meta object will be extensible, and its properties will |
| 34 |
// be writable, configurable, and enumerable. |
| 35 |
|
| 36 |
assertEq(Object.isExtensible(import.meta), true); |
| 37 |
|
| 38 |
for (const name of Reflect.ownKeys(import.meta)) { |
| 39 |
const desc = Object.getOwnPropertyDescriptor(import.meta, name); |
| 40 |
assertEq(desc.writable, true); |
| 41 |
assertEq(desc.enumerable, true); |
| 42 |
assertEq(desc.configurable, true); |
| 43 |
assertEq(desc.value, import.meta[name]); |
| 44 |
} |
| 45 |
|
| 46 |
// The import.meta object's prototype is null. |
| 47 |
assertEq(Object.getPrototypeOf(import.meta), null); |
| 48 |
|
| 49 |
import.meta.url = 0; |
| 50 |
assertEq(import.meta.url, 0); |
| 51 |
|
| 52 |
import.meta.newProp = 42; |
| 53 |
assertEq(import.meta.newProp, 42); |
| 54 |
|
| 55 |
let found = new Set(Reflect.ownKeys(import.meta)); |
| 56 |
|
| 57 |
assertEq(found.size, 3); |
| 58 |
assertEq(found.has("url"), true); |
| 59 |
assertEq(found.has("newProp"), true); |
| 60 |
assertEq(found.has("resolve"), true); |
| 61 |
|
| 62 |
delete import.meta.url; |
| 63 |
delete import.meta.newProp; |
| 64 |
delete import.meta.resolve; |
| 65 |
|
| 66 |
found = new Set(Reflect.ownKeys(import.meta)); |
| 67 |
assertEq(found.size, 0); |