js/src/tests/ecma_5/Function/builtin-no-construct.js

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 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 function checkMethod(method) {
     7     try {
     8         new method();
     9         assertEq(0, 1, "not reached " + method);
    10     } catch (e) {
    11         assertEq(e.message, "method is not a constructor");
    12     }
    13 }
    15 function checkMethods(proto) {
    16     var names = Object.getOwnPropertyNames(proto);
    17     for (var i = 0; i < names.length; i++) {
    18         var name = names[i];
    19         if (name == "constructor")
    20             continue;
    21         var prop = proto[name];
    22         if (typeof prop === "function")
    23             checkMethod(prop);
    24     }
    25 }
    27 checkMethod(Function.prototype);
    28 checkMethods(JSON);
    29 checkMethods(Math);
    30 checkMethods(Proxy);
    32 var builtin_ctors = [
    33     Object, Function, Array, String, Boolean, Number, Date, RegExp, Error,
    34     EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError,
    35 ];
    37 for (var i = 0; i < builtin_ctors.length; i++) {
    38     checkMethods(builtin_ctors[i]);
    39     checkMethods(builtin_ctors[i].prototype);
    40 }
    42 var builtin_funcs = [
    43     eval, isFinite, isNaN, parseFloat, parseInt,
    44     decodeURI, decodeURIComponent, encodeURI, encodeURIComponent
    45 ];
    47 for (var i = 0; i < builtin_funcs.length; i++) {
    48     checkMethod(builtin_funcs[i]);
    49 }
    51 if (typeof reportCompare == 'function')
    52     reportCompare(0, 0, "ok");

mercurial