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
+ ".");
30 function testGetter(o
) {
32 for (var i
= 0; i
< 10; i
++)
36 function testProtoGetter(o
) {
38 for (var i
= 0; i
< 10; i
++)
42 function testProtoChainGetter(o
) {
44 for (var i
= 0; i
< 10; i
++)
48 function getterTest(str
, expected
) {
49 shouldBe(eval(str
), str
, expected
);
51 var testFunction3 = function(a
,b
,c
){}
52 var testFunction5 = function(a
,b
,c
,d
,e
){}
53 getterTest("testGetter({__proto__: {count: 'FAIL'}, get length(){ return this.count; }, count: 7})", 7);
54 getterTest("testGetter(testFunction3)", 3);
55 getterTest("testGetter(testFunction5)", 5);
57 getterTest("testProtoGetter({__proto__: {count: 'FAIL', get length(){ return this.count; }}, count: 7})", 7);
58 getterTest("testProtoGetter({__proto__: testFunction3, count: 'FAIL'})", 3);
59 getterTest("testProtoGetter({__proto__: testFunction5, count: 'FAIL'})", 5);
61 getterTest("testProtoChainGetter({__proto__: {__proto__: {count: 'FAIL', get length(){ return this.count; }}}, count: 7})", 7);
62 getterTest("testProtoChainGetter({__proto__: {__proto__: testFunction3}, count: 'FAIL'})", 3);
63 getterTest("testProtoChainGetter({__proto__: {__proto__: testFunction5}, count: 'FAIL'})", 5);
65 function testCustomGetter(o
) {
66 for (var i
= 0; i
< 10; i
++)
70 testCustomGetter({__proto__
: r
});
71 testCustomGetter({__proto__
: {__proto__
: r
}});