test_lookupGetter.html (1359B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=462428 5 --> 6 <head> 7 <title>Test for Bug 462428</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=462428">Mozilla Bug 462428</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script type="application/javascript"> 19 20 /** Test for Bug 462428 */ 21 var x = new XMLHttpRequest; 22 x.open("GET", ""); 23 var getter = x.__lookupGetter__("readyState"); 24 ok(getter !== undefined, "But able to look it up the normal way"); 25 ok(!x.hasOwnProperty("readyState"), "property should still be on the prototype"); 26 27 var sawProp = false; 28 for (var i in x) { 29 if (i === "readyState") { 30 sawProp = true; 31 } 32 } 33 34 ok(sawProp, "property should be enumerable"); 35 36 is(getter.call(x), 1, "the getter actually works"); 37 38 Object.getPrototypeOf(x).__defineSetter__("readyState", function() {}); 39 is(getter.call(x), 1, "the getter works after defineSetter"); 40 41 is(x.responseType, "", "Should have correct responseType up front"); 42 var setter = x.__lookupSetter__("responseType"); 43 setter.call(x, "document"); 44 is(x.responseType, "document", "the setter is bound correctly"); 45 46 </script> 47 </pre> 48 </body> 49 </html>