Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / js / src / tests / non262 / class / superPropNoOverwriting.js
blobdb44b509c590e4113db939e95a71e1d955419249
1 class X {
2     constructor() {
3         Object.defineProperty(this, "prop1", {
4             configurable: true,
5             writable: false,
6             value: 1
7         });
9         Object.defineProperty(this, "prop2", {
10             configurable: true,
11             get: function() { return 15; }
12         });
14         Object.defineProperty(this, "prop3", {
15             configurable: true,
16             set: function(a) { }
17         });
19         Object.defineProperty(this, "prop4", {
20             configurable: true,
21             get: function() { return 20; },
22             set: function(a) { }
23         });
24     }
26     f1() {
27         super.prop1 = 2;
28     }
30     f2() {
31         super.prop2 = 3;
32     }
34     f3() {
35         super.prop3 = 4;
36     }
38     f4() {
39         super.prop4 = 5;
40     }
43 var x = new X();
45 assertThrowsInstanceOf(() => x.f1(), TypeError);
46 assertEq(x.prop1, 1);
48 assertThrowsInstanceOf(() => x.f2(), TypeError);
49 assertEq(x.prop2, 15);
51 assertThrowsInstanceOf(() => x.f3(), TypeError);
52 assertEq(x.prop3, undefined);
54 assertThrowsInstanceOf(() => x.f4(), TypeError);
55 assertEq(x.prop4, 20);
57 if (typeof reportCompare === 'function')
58     reportCompare(0,0,"OK");