Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / pic / cached-deleted-properties.html
blob9e990b8222dc58215e57efdb0cdbb7f4a1410ea9
1 <p>
2 This test verifies that property caching behaves correctly in the face of deleted
3 properties. If the test passes, 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 Array.equal = function equal(a, b)
32 if (a.length != b.length)
33 return false;
34 for (var i = 0; i < a.length; ++i)
35 if (a[i] != b[i])
36 return false;
37 return true;
40 var expectedProperties = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
42 function getProperties(o)
44 return [
45 o.p1,
46 o.p2,
47 o.p3,
48 o.p4,
49 o.p5,
50 o.p6,
51 o.p7,
52 o.p8,
53 o.p9,
54 o.p10
58 function addProperties(o)
60 o.p1 = 1;
61 o.p2 = 2;
62 o.p3 = 3;
63 o.p4 = 4;
64 o.p5 = 5;
65 o.p6 = 6;
66 o.p7 = 7;
67 o.p8 = 8;
68 o.p9 = 9;
69 o.p10 = 10;
72 function removeProperties(o)
74 delete o.p10;
75 delete o.p9;
76 delete o.p8;
77 delete o.p7;
78 delete o.p6;
79 delete o.p5;
80 delete o.p4;
81 delete o.p3;
82 delete o.p2;
85 function makeO()
87 var o = { };
88 addProperties(o);
89 removeProperties(o);
90 addProperties(o);
91 return o;
94 var o;
95 var properties;
97 for (var i = 0; i < 3; ++i) {
98 o = makeO();
99 properties = getProperties(o);
100 shouldBe(Array.equal(properties, expectedProperties), "Array.equal(properties, expectedProperties)", true);
103 o = { x: 0, y: 0, z: 0 };
104 delete o.z;
105 for (var i = 0; i < 3; ++i) {
106 o.x = 1;
107 shouldBe(o.x, "o.x", 1);
109 })();
110 </script>