Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / pic / cached-named-property-getter.html
blob3b874f65e164b6f9de978e7c368d9e79f64561c7
1 <p>
2 This page tests cached access to getters and setters. If the test passes,
3 you'll see a series of PASS messages below.
4 </p>
6 <pre id="console"></pre>
8 <script>
9 (function() {
10 if (window.testRunner)
11 testRunner.dumpAsText();
13 function log(s)
15 if (this.document)
16 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
17 else
18 print(s + "\n");
21 function shouldBe(a, aDescription, b)
23 if (a === b) {
24 log("PASS: " + aDescription + " should be " + b + " and is.");
25 } else {
26 log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
30 function testGetter(o) {
31 var result;
32 for (var i = 0; i < 10; i++)
33 result = o.length;
34 return result;
36 function testProtoGetter(o) {
37 var result;
38 for (var i = 0; i < 10; i++)
39 result = o.length;
40 return result;
42 function testProtoChainGetter(o) {
43 var result;
44 for (var i = 0; i < 10; i++)
45 result = o.length;
46 return result;
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++)
67 o.ignoreCase;
69 var r=/a/;
70 testCustomGetter({__proto__: r});
71 testCustomGetter({__proto__: {__proto__: r}});
73 })();
74 </script>