js/src/tests/ecma_5/extensions/arguments-property-access-in-function.js

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 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  * Contributor:
     5  *   Jeff Walden <jwalden+code@mit.edu>
     6  */
     8 //-----------------------------------------------------------------------------
     9 var BUGNUMBER = 721322;
    10 var summary =
    11   'f.arguments must trigger an arguments object in non-strict mode functions';
    13 print(BUGNUMBER + ": " + summary);
    15 /**************
    16  * BEGIN TEST *
    17  **************/
    19 var obj =
    20   {
    21     test: function()
    22     {
    23       var args = obj.test.arguments;
    24       assertEq(args !== null, true);
    25       assertEq(args[0], 5);
    26       assertEq(args[1], undefined);
    27       assertEq(args.length, 2);
    28     }
    29   };
    30 obj.test(5, undefined);
    32 var sobj =
    33   {
    34     test: function()
    35     {
    36      "use strict";
    38       try
    39       {
    40         var args = sobj.test.arguments;
    41         throw new Error("access to arguments property of strict mode " +
    42                         "function didn't throw");
    43       }
    44       catch (e)
    45       {
    46         assertEq(e instanceof TypeError, true,
    47                  "should have thrown TypeError, instead got: " + e);
    48       }
    49     }
    50   };
    51 sobj.test(5, undefined);
    53 /******************************************************************************/
    55 if (typeof reportCompare === "function")
    56   reportCompare(true, true);
    58 print("Tests complete");

mercurial