js/src/tests/test262/ch13/13.2/S13.2.3_A1.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 // Copyright 2011 Google Inc.  All rights reserved.
     2 // This code is governed by the BSD license found in the LICENSE file.
     4 /**
     5  * @path ch13/13.2/S13.2.3_A1.js
     6  * @description check that all poisoning use the [[ThrowTypeError]]
     7  * function object.
     8  * @onlyStrict
     9  */
    11 "use strict";
    12 var poison = Object.getOwnPropertyDescriptor(function() {}, 'caller').get;
    14 if (typeof poison !== 'function') {
    15   $ERROR("#1: A strict function's .caller should be poisoned with a function");
    16 }
    17 var threw = null;
    18 try {
    19   poison();
    20 } catch (err) {
    21   threw = err;
    22 }
    23 if (!threw || !(threw instanceof TypeError)) {
    24   $ERROR("#2: Poisoned property should throw TypeError");
    25 }
    27 function checkPoison(obj, name) {
    28   var desc = Object.getOwnPropertyDescriptor(obj, name);
    29   if (desc.enumerable) {
    30     $ERROR("#3: Poisoned " + name + " should not be enumerable");
    31   }
    32   if (desc.configurable) {
    33     $ERROR("#4: Poisoned " + name + " should not be configurable");
    34   }
    35   if (poison !== desc.get) {
    36     $ERROR("#5: " + name + "'s getter not poisoned with same poison");
    37   }
    38   if (poison !== desc.set) {
    39     $ERROR("#6: " + name + "'s setter not poisoned with same poison");
    40   }
    41 }
    43 checkPoison(function() {}, 'caller');
    44 checkPoison(function() {}, 'arguments');
    45 checkPoison((function() { return arguments; })(), 'caller');
    46 checkPoison((function() { return arguments; })(), 'callee');
    47 checkPoison((function() {}).bind(null), 'caller');
    48 checkPoison((function() {}).bind(null), 'arguments');

mercurial