dom/plugins/test/mochitest/test_propertyAndMethod.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/mochitest/test_propertyAndMethod.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +<html>
     1.5 +  <head>
     1.6 +    <title>NPObject with property and method with the same name</title>
     1.7 +
     1.8 +    <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +    <script type="text/javascript" src="utils.js"></script>
    1.10 +    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.11 +  </head>
    1.12 +
    1.13 +  <body onload="run()">
    1.14 +
    1.15 +    <script class="testbody" type="application/javascript">
    1.16 +      if (typeof Object.getPrototypeOf !== "function") {
    1.17 +        if (typeof "test".__proto__ === "object") {
    1.18 +          Object.getPrototypeOf = function(object) {
    1.19 +            return object.__proto__;
    1.20 +          };
    1.21 +        } else {
    1.22 +          Object.getPrototypeOf = function(object) {
    1.23 +            // May break if the constructor has been tampered with
    1.24 +            return object.constructor.prototype;
    1.25 +          };
    1.26 +        }
    1.27 +      }
    1.28 +
    1.29 +      SimpleTest.waitForExplicitFinish();
    1.30 +      setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    1.31 +
    1.32 +      function run() {
    1.33 +        var plugin = document.getElementById("plugin");
    1.34 +        var pluginProto = Object.getPrototypeOf(plugin);
    1.35 +
    1.36 +        delete pluginProto.propertyAndMethod;
    1.37 +        ok(isNaN(plugin.propertyAndMethod + 0), "Shouldn't be set yet!");
    1.38 +
    1.39 +        plugin.propertyAndMethod = 5;
    1.40 +        is(plugin.propertyAndMethod, 5, "Should be set to 5!");
    1.41 +
    1.42 +        delete pluginProto.propertyAndMethod;
    1.43 +        ok(isNaN(plugin.propertyAndMethod + 0), "Shouldn't be set any more!");
    1.44 +
    1.45 +        var res = plugin.propertyAndMethod();
    1.46 +        is(res, 5, "Method invocation should return 5!");
    1.47 +
    1.48 +        SimpleTest.finish();
    1.49 +      }
    1.50 +    </script>
    1.51 +
    1.52 +    <embed id="plugin" type="application/x-test" wmode="window"></embed>
    1.53 +  </body>
    1.54 +</html>

mercurial