4 https://bugzilla.mozilla.org/show_bug.cgi?id=1700052
8 <title>Test for Bug
1700052</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1700052">Mozilla Bug
1700052</a>
15 <form id=
"theform"></form>
18 function expandoTests() {
19 // Get a DOM proxy with an expando object. Define/redefine a "foo" getter/setter
20 // and ensure the right function is called.
22 var obj
= document
.getElementById("theform");
23 var count1
= 0, count2
= 0, count3
= 0;
24 var fun1 = function() { count1
++; };
25 var fun2 = function() { count2
++; };
26 var fun3 = function() { count3
++; };
28 Object
.defineProperty(obj
, "foo", {configurable
: true, get: fun1
, set: fun1
});
30 for (var i
= 0; i
< 100; i
++) {
34 Object
.defineProperty(obj
, "foo", {configurable
: true, get: fun2
, set: fun2
});
35 } else if (i
=== 80) {
36 Object
.defineProperty(obj
, "foo", {configurable
: true, get: fun3
, set: fun3
});
40 is(count1
, 102, "call count for fun1 must match");
41 is(count2
, 60, "call count for fun2 must match");
42 is(count3
, 38, "call count for fun3 must match");
46 function unshadowedTests() {
47 // Same as above, but for non-shadowing properties on the prototype.
49 var obj
= document
.getElementById("theform");
50 var proto
= Object
.getPrototypeOf(obj
);
52 var count1
= 0, count2
= 0;
53 var fun1 = function() { count1
++; };
54 var fun2 = function() { count2
++; };
56 for (var i
= 0; i
< 100; i
++) {
60 let desc
= Object
.getOwnPropertyDescriptor(proto
, "name");
61 desc
.get = desc
.set = fun1
;
62 Object
.defineProperty(proto
, "name", desc
);
65 let desc
= Object
.getOwnPropertyDescriptor(proto
, "name");
66 desc
.get = desc
.set = fun2
;
67 Object
.defineProperty(proto
, "name", desc
);
71 is(count1
, 80, "call count for fun1 must match");
72 is(count2
, 18, "call count for fun2 must match");