dom/plugins/test/mochitest/test_propertyAndMethod.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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