Debian Codegraph @

js/src/tests/test262/language/import/import-defer/deferred-namespace-object/exotic-object-behavior.js

raw
1 // |reftest| skip module -- import-defer is not supported
2 // Copyright (C) 2024 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-modulenamespacecreate
7 description: >
8 Deferred namespace objects have the correct MOP implementation
9 info: |
10 ModuleNamespaceCreate ( _module_, _exports_, _phase_ )
11 1. Let _internalSlotsList_ be the internal slots listed in <emu-xref href="#table-internal-slots-of-module-namespace-exotic-objects"></emu-xref>.
12 1. Let _M_ be MakeBasicObject(_internalSlotsList_).
13 1. Set _M_'s essential internal methods to the definitions specified in <emu-xref href="#sec-module-namespace-exotic-objects"></emu-xref>.
14 1. ...
15
16 [[GetPrototypeOf]] ( )
17 1. Return null.
18
19 [[IsExtensible]] ( )
20 1. Return false.
21
22 flags: [module]
23 features: [import-defer]
24 includes: [propertyHelper.js, compareArray.js]
25 ---*/
26
27 import defer * as ns from "./dep_FIXTURE.js";
28
29 assert.sameValue(typeof ns, "object", "Deferred namespaces are objects");
30
31 assert(!Reflect.isExtensible(ns), "Deferred namespaces are not extensible");
32 assert.sameValue(Reflect.preventExtensions(ns), true, "Deferred namespaces can made non-extensible");
33
34 assert.sameValue(Reflect.getPrototypeOf(ns), null, "Deferred namespaces have a null prototype");
35 assert.sameValue(Reflect.setPrototypeOf(ns, {}), false, "Deferred namespaces' prototype cannot be changed");
36 assert.sameValue(Reflect.setPrototypeOf(ns, null), true, "Deferred namespaces' prototype can be 'set' to null");
37
38 assert.throws(TypeError, () => Reflect.apply(ns, null, []), "Deferred namespaces are not callable");
39 assert.throws(TypeError, () => Reflect.construct(ns, [], ns), "Deferred namespaces are not constructable");
40
41 assert.compareArray(
42 Reflect.ownKeys(ns),
43 ["bar", "foo", Symbol.toStringTag],
44 "Deferred namespaces' keys are the exports sorted alphabetically, followed by @@toStringTag"
45 );
46
47 // We cannot use `verifyProperty` because the property _looks_ writable, but it's actually not
48 const desc = Reflect.getOwnPropertyDescriptor(ns, "foo");
49 assert.sameValue(desc.value, 1, "The value of the 'foo' property is 1");
50 assert.sameValue(desc.writable, true, "The 'foo' property is writable");
51 assert.sameValue(desc.enumerable, true, "The 'foo' property is enumerable");
52 assert.sameValue(desc.configurable, false, "The 'foo' property is not configurable");
53
54 assert.sameValue(Reflect.getOwnPropertyDescriptor(ns, "non-existent"), undefined, "No descriptors for non-exports");
55
56 reportCompare(0, 0);