Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / pic / cached-getter-dictionary-and-proto.html
blob167e44faf6050d9350e8ea145f1b78341d65da22
1 <p>
2 This page tests cached access to properties of dictionary objects and objects
3 with changing prototypes. If the test passes, you'll see a series of PASS messages
4 below.
5 </p>
7 <pre id="console"></pre>
9 <script>
10 (function() {
11 if (window.testRunner)
12 testRunner.dumpAsText();
14 function log(s)
16 if (this.document)
17 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
18 else
19 print(s + "\n");
22 function shouldBe(a, aDescription, b)
24 if (a === b) {
25 log("PASS: " + aDescription + " should be " + b + " and is.\n");
26 } else {
27 log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".\n");
31 (function() {
32 function getX(o)
34 return o.x;
37 var o = {
38 x: 0,
39 y: 0
42 getX(o);
43 getX(o);
45 for (var i = 0; i < 128; ++i)
46 o["p" + i] = 1;
48 shouldBe(getX(o), "getX(o)", 0);
49 })();
51 (function() {
52 function getProtoX(o)
54 return o.protoX;
57 var o = {
58 __proto__ : {
59 protoX: 0,
60 protoY: 0
64 getProtoX(o);
65 getProtoX(o);
67 o.__proto__ = {
68 protoY: 1,
69 protoX: 2
72 shouldBe(getProtoX(o), "getProtoX(o)", 2);
73 })();
75 (function() {
76 function getProtoX(o)
78 return o.protoX;
81 var o = {
82 __proto__ : {
83 protoX: 0,
84 protoY: 0
88 getProtoX(o);
89 getProtoX(o);
91 delete o.__proto__.protoX;
93 shouldBe(getProtoX(o), "getProtoX(o)", undefined);
94 })();
95 })();
96 </script>