2 This page tests cached access to getters and setters. If the test passes,
3 you'll see a series of PASS messages below.
6 <pre id=
"console"></pre>
10 if (window
.testRunner
)
11 testRunner
.dumpAsText();
16 document
.getElementById("console").appendChild(document
.createTextNode(s
+ "\n"));
21 function shouldBe(a
, aDescription
, b
)
24 log("PASS: " + aDescription
+ " should be " + b
+ " and is.");
26 log("FAIL: " + aDescription
+ " should be " + b
+ " but instead is " + a
+ ".");
35 get x() { return this.x_
; },
36 set x(x
) { this.x_
= x
; },
39 get y() { return this.y_
; },
40 set y(y
) { this.y_
= y
; }
44 for (var i
= 0; i
< 3; ++i
) {
46 shouldBe(o
.x
, "o.x", i
);
49 for (var i
= 0; i
< 3; ++i
) {
51 shouldBe(o
.y
, "o.y", i
);
55 function testGetter(o
) {
57 for (var i
= 0; i
< 10; i
++)
61 function testProtoGetter(o
) {
63 for (var i
= 0; i
< 10; i
++)
67 function testProtoChainGetter(o
) {
69 for (var i
= 0; i
< 10; i
++)
73 shouldBe(testGetter({__proto__
: {count
: 'FAIL'}, get getter(){ return ++this.count
; }, count
: 0}),
74 "testGetter({__proto__: {count: 'FAIL'}, get getter(){ return ++this.count; }, count: 0})", 10);
75 shouldBe(testGetter({__proto__
: {count
: 'FAIL'}, get getter(){ return ++this.count
; }, count
: 0, newProperty
: 0}),
76 "testGetter({__proto__: {count: 'FAIL'}, get getter(){ return ++this.count; }, count: 0, newProperty: 0})", 10);
77 shouldBe(testGetter({__proto__
: {count
: 'FAIL'}, get getter(){ return ++this.count
; }, count
: 0, newProperty2
: 0}),
78 "testGetter({__proto__: {count: 'FAIL'}, get getter(){ return ++this.count; }, count: 0, newProperty2: 0})", 10);
79 shouldBe(testProtoGetter({__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }}, count
: 0}),
80 "testProtoGetter({__proto__: {count: 'FAIL', get getter(){ return ++this.count; }}, count: 0})", 10);
81 shouldBe(testProtoGetter({__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }}, count
: 0, newProperty
: 0}),
82 "testProtoGetter({__proto__: {count: 'FAIL', get getter(){ return ++this.count; }}, count: 0, newProperty: 0})", 10);
83 shouldBe(testProtoGetter({__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }}, count
: 0, newProperty2
: 0}),
84 "testProtoGetter({__proto__: {count: 'FAIL', get getter(){ return ++this.count; }}, count: 0, newProperty2: 0})", 10);
85 shouldBe(testProtoChainGetter({__proto__
: {__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }}}, count
: 0}),
86 "testProtoChainGetter({__proto__: {__proto__: {count: 'FAIL', get getter(){ return ++this.count; }}}, count: 0})", 10);
87 shouldBe(testProtoChainGetter({__proto__
: {__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }}}, count
: 0, newProperty
: 0}),
88 "testProtoChainGetter({__proto__: {__proto__: {count: 'FAIL', get getter(){ return ++this.count; }}}, count: 0, newProperty: 0})", 10);
89 shouldBe(testProtoChainGetter({__proto__
: {__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }}}, count
: 0, newProperty2
: 0}),
90 "testProtoChainGetter({__proto__: {__proto__: {count: 'FAIL', get getter(){ return ++this.count; }}}, count: 0, newProperty2: 0})", 10);
92 function testGetterBigObject(o
) {
94 for (var i
= 0; i
< 10; i
++)
98 function testProtoGetterBigObject(o
) {
100 for (var i
= 0; i
< 10; i
++)
104 function testProtoChainGetterBigObject(o
) {
106 for (var i
= 0; i
< 10; i
++)
110 shouldBe(testGetterBigObject({__proto__
: {count
: 'FAIL'}, get getter(){ return ++this.count
; }, count
: 0, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}),
111 "testGetterBigObject({__proto__: {count: 'FAIL'}, get getter(){ return ++this.count; }, count: 0, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9})", 10);
112 shouldBe(testGetterBigObject({__proto__
: {count
: 'FAIL'}, get getter(){ return ++this.count
; }, count
: 0, newProperty
: 0, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}),
113 "testGetterBigObject({__proto__: {count: 'FAIL'}, get getter(){ return ++this.count; }, count: 0, newProperty: 0, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9})", 10);
114 shouldBe(testGetterBigObject({__proto__
: {count
: 'FAIL'}, get getter(){ return ++this.count
; }, count
: 0, newProperty2
: 0, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}),
115 "testGetterBigObject({__proto__: {count: 'FAIL'}, get getter(){ return ++this.count; }, count: 0, newProperty2: 0, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9})", 10);
116 shouldBe(testProtoGetterBigObject({__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}, count
: 0}),
117 "testProtoGetterBigObject({__proto__: {count: 'FAIL', get getter(){ return ++this.count; }, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}, count: 0})", 10);
118 shouldBe(testProtoGetterBigObject({__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}, count
: 0, newProperty
: 0}),
119 "testProtoGetterBigObject({__proto__: {count: 'FAIL', get getter(){ return ++this.count; }, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}, count: 0, newProperty: 0})", 10);
120 shouldBe(testProtoGetterBigObject({__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}, count
: 0, newProperty2
: 0}),
121 "testProtoGetterBigObject({__proto__: {count: 'FAIL', get getter(){ return ++this.count; }, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}, count: 0, newProperty2: 0})", 10);
122 shouldBe(testProtoChainGetterBigObject({__proto__
: {__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}}, count
: 0}),
123 "testProtoChainGetterBigObject({__proto__: {__proto__: {count: 'FAIL', get getter(){ return ++this.count; }, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}}, count: 0})", 10);
124 shouldBe(testProtoChainGetterBigObject({__proto__
: {__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}}, count
: 0, newProperty
: 0}),
125 "testProtoChainGetterBigObject({__proto__: {__proto__: {count: 'FAIL', get getter(){ return ++this.count; }, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}}, count: 0, newProperty: 0})", 10);
126 shouldBe(testProtoChainGetterBigObject({__proto__
: {__proto__
: {count
: 'FAIL', get getter(){ return ++this.count
; }, a
:1, b
:2, c
:3, d
: 4, e
: 5, f
: 6, g
: 7, h
: 8, i
: 9}}, count
: 0, newProperty2
: 0}),
127 "testProtoChainGetterBigObject({__proto__: {__proto__: {count: 'FAIL', get getter(){ return ++this.count; }, a:1, b:2, c:3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}}, count: 0, newProperty2: 0})", 10);
151 o
.__defineGetter__("x", function() { return 3; });
152 o
.__defineSetter__("x", function(x
) { });
154 shouldBe(getX(o
), "getX(o)", 3);
156 shouldBe(getX(o
), "getX(o)", 3);