Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / pic / undictionary.html
blob79b581ddfbc5bf7d492e758e4ac17b19ff3e0e57
1 <p>
2 This page tests for a caching error when transitioning prototypes away from being dictionaries.
3 If the test passes, you'll see a series of PASS messages below.
4 </p>
6 <pre id="console"></pre>
8 <script>
9 if (window.testRunner)
10 testRunner.dumpAsText();
12 function log(s)
14 if (this.document)
15 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
16 else
17 print(s + "\n");
20 function shouldBe(aDescription, a, b)
22 if (a === b) {
23 log("PASS: " + aDescription + " should be " + b + " and is.");
24 } else {
25 log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
29 // Prototype tests
30 (function () {
31 function getB(o)
33 return o.b;
36 var o = {
37 __proto__ : {
38 a: "a",
39 b: "b"
43 delete o.__proto__.a;
44 o.__proto__.c = "c"; // if o.__proto__ un-dictionaries itself, .c will overwrite the deleted .b slot.
45 for (var i = 0; i < 3; ++i)
46 shouldBe("getB(o)", getB(o), "b");
48 var o2 = {
49 __proto__ : {
50 a2: "a2",
51 b: "b"
55 delete o2.__proto__.a2;
56 o2.__proto__.c2 = "c2"; // if o2.__proto__ un-dictionaries itself, .c2 will overwrite the deleted .b slot.
57 for (var i = 0; i < 3; ++i)
58 shouldBe("getB(o2)", getB(o2), "b");
59 })();
61 // Prototype chain tests
62 (function () {
63 function getB(o)
65 return o.b;
68 var o = {
69 __proto__ : {
70 __proto__ : {
71 a: "a",
72 b: "b"
77 delete o.__proto__.__proto__.a;
78 o.__proto__.__proto__.c = "c"; // if o.__proto__.__proto__ un-dictionaries itself, .c will overwrite the deleted .b slot.
79 for (var i = 0; i < 3; ++i)
80 shouldBe("getB(o)", getB(o), "b");
82 var o2 = {
83 __proto__ : {
84 __proto__ : {
85 a2: "a",
86 b: "b"
91 delete o2.__proto__.__proto__.a2;
92 o2.__proto__.__proto__.c = "c"; // if o2.__proto__.__proto__ un-dictionaries itself, .c will overwrite the deleted .b slot.
93 for (var i = 0; i < 3; ++i)
94 shouldBe("getB(o2)", getB(o2), "b");
95 })();
96 </script>