dom/plugins/test/mochitest/test_propertyAndMethod.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial