summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/freeze-builtins.js
blob: 086551135abf749f5d52846971381f54e83d101b (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
34
35
36
37
var g = newGlobal({freezeBuiltins: true});

g.evaluate("" + function checkFrozen(name) {
  // Check constructor on the global is non-writable/non-configurable.
  let desc = Object.getOwnPropertyDescriptor(this, name);
  assertEq(desc.writable, false);
  assertEq(desc.configurable, false);

  // Constructor must be frozen.
  let ctor = desc.value;
  assertEq(Object.isFrozen(ctor), true);

  // Prototype must be sealed.
  if (ctor.prototype) {
    assertEq(Object.isSealed(ctor.prototype), true);
  }
});

g.checkFrozen("Object");
g.checkFrozen("Array");
g.checkFrozen("Function");

g.checkFrozen("ArrayBuffer");
g.checkFrozen("Int32Array");
g.checkFrozen("Number");
g.checkFrozen("String");
g.checkFrozen("Proxy");
g.checkFrozen("Promise");
g.checkFrozen("RegExp");
g.checkFrozen("Map");
g.checkFrozen("WeakMap");
g.checkFrozen("WeakRef");
g.checkFrozen("Error");
g.checkFrozen("TypeError");

g.checkFrozen("JSON");
g.checkFrozen("Math");