dom/plugins/test/mochitest/test_propertyAndMethod.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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