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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/ch13/13.2/S13.2.3_A1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +// Copyright 2011 Google Inc.  All rights reserved.
     1.5 +// This code is governed by the BSD license found in the LICENSE file.
     1.6 +
     1.7 +/**
     1.8 + * @path ch13/13.2/S13.2.3_A1.js
     1.9 + * @description check that all poisoning use the [[ThrowTypeError]]
    1.10 + * function object.
    1.11 + * @onlyStrict
    1.12 + */
    1.13 +
    1.14 +"use strict";
    1.15 +var poison = Object.getOwnPropertyDescriptor(function() {}, 'caller').get;
    1.16 +
    1.17 +if (typeof poison !== 'function') {
    1.18 +  $ERROR("#1: A strict function's .caller should be poisoned with a function");
    1.19 +}
    1.20 +var threw = null;
    1.21 +try {
    1.22 +  poison();
    1.23 +} catch (err) {
    1.24 +  threw = err;
    1.25 +}
    1.26 +if (!threw || !(threw instanceof TypeError)) {
    1.27 +  $ERROR("#2: Poisoned property should throw TypeError");
    1.28 +}
    1.29 +
    1.30 +function checkPoison(obj, name) {
    1.31 +  var desc = Object.getOwnPropertyDescriptor(obj, name);
    1.32 +  if (desc.enumerable) {
    1.33 +    $ERROR("#3: Poisoned " + name + " should not be enumerable");
    1.34 +  }
    1.35 +  if (desc.configurable) {
    1.36 +    $ERROR("#4: Poisoned " + name + " should not be configurable");
    1.37 +  }
    1.38 +  if (poison !== desc.get) {
    1.39 +    $ERROR("#5: " + name + "'s getter not poisoned with same poison");
    1.40 +  }
    1.41 +  if (poison !== desc.set) {
    1.42 +    $ERROR("#6: " + name + "'s setter not poisoned with same poison");
    1.43 +  }
    1.44 +}
    1.45 +
    1.46 +checkPoison(function() {}, 'caller');
    1.47 +checkPoison(function() {}, 'arguments');
    1.48 +checkPoison((function() { return arguments; })(), 'caller');
    1.49 +checkPoison((function() { return arguments; })(), 'callee');
    1.50 +checkPoison((function() {}).bind(null), 'caller');
    1.51 +checkPoison((function() {}).bind(null), 'arguments');
    1.52 +

mercurial