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.

     1 <html>
     2   <head>
     3     <title>NPObject with property and method with the same name</title>
     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>
    10   <body onload="run()">
    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       }
    26       SimpleTest.waitForExplicitFinish();
    27       setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    29       function run() {
    30         var plugin = document.getElementById("plugin");
    31         var pluginProto = Object.getPrototypeOf(plugin);
    33         delete pluginProto.propertyAndMethod;
    34         ok(isNaN(plugin.propertyAndMethod + 0), "Shouldn't be set yet!");
    36         plugin.propertyAndMethod = 5;
    37         is(plugin.propertyAndMethod, 5, "Should be set to 5!");
    39         delete pluginProto.propertyAndMethod;
    40         ok(isNaN(plugin.propertyAndMethod + 0), "Shouldn't be set any more!");
    42         var res = plugin.propertyAndMethod();
    43         is(res, 5, "Method invocation should return 5!");
    45         SimpleTest.finish();
    46       }
    47     </script>
    49     <embed id="plugin" type="application/x-test" wmode="window"></embed>
    50   </body>
    51 </html>

mercurial