|
1 <html> |
|
2 <head> |
|
3 <title>NPObject with property and method with the same name</title> |
|
4 |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="text/javascript" src="utils.js"></script> |
|
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
8 </head> |
|
9 |
|
10 <body onload="run()"> |
|
11 |
|
12 <script class="testbody" type="application/javascript"> |
|
13 if (typeof Object.getPrototypeOf !== "function") { |
|
14 if (typeof "test".__proto__ === "object") { |
|
15 Object.getPrototypeOf = function(object) { |
|
16 return object.__proto__; |
|
17 }; |
|
18 } else { |
|
19 Object.getPrototypeOf = function(object) { |
|
20 // May break if the constructor has been tampered with |
|
21 return object.constructor.prototype; |
|
22 }; |
|
23 } |
|
24 } |
|
25 |
|
26 SimpleTest.waitForExplicitFinish(); |
|
27 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
|
28 |
|
29 function run() { |
|
30 var plugin = document.getElementById("plugin"); |
|
31 var pluginProto = Object.getPrototypeOf(plugin); |
|
32 |
|
33 delete pluginProto.propertyAndMethod; |
|
34 ok(isNaN(plugin.propertyAndMethod + 0), "Shouldn't be set yet!"); |
|
35 |
|
36 plugin.propertyAndMethod = 5; |
|
37 is(plugin.propertyAndMethod, 5, "Should be set to 5!"); |
|
38 |
|
39 delete pluginProto.propertyAndMethod; |
|
40 ok(isNaN(plugin.propertyAndMethod + 0), "Shouldn't be set any more!"); |
|
41 |
|
42 var res = plugin.propertyAndMethod(); |
|
43 is(res, 5, "Method invocation should return 5!"); |
|
44 |
|
45 SimpleTest.finish(); |
|
46 } |
|
47 </script> |
|
48 |
|
49 <embed id="plugin" type="application/x-test" wmode="window"></embed> |
|
50 </body> |
|
51 </html> |