michael@0: // Copyright 2011 Google Inc. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * @path ch13/13.2/S13.2.3_A1.js michael@0: * @description check that all poisoning use the [[ThrowTypeError]] michael@0: * function object. michael@0: * @onlyStrict michael@0: */ michael@0: michael@0: "use strict"; michael@0: var poison = Object.getOwnPropertyDescriptor(function() {}, 'caller').get; michael@0: michael@0: if (typeof poison !== 'function') { michael@0: $ERROR("#1: A strict function's .caller should be poisoned with a function"); michael@0: } michael@0: var threw = null; michael@0: try { michael@0: poison(); michael@0: } catch (err) { michael@0: threw = err; michael@0: } michael@0: if (!threw || !(threw instanceof TypeError)) { michael@0: $ERROR("#2: Poisoned property should throw TypeError"); michael@0: } michael@0: michael@0: function checkPoison(obj, name) { michael@0: var desc = Object.getOwnPropertyDescriptor(obj, name); michael@0: if (desc.enumerable) { michael@0: $ERROR("#3: Poisoned " + name + " should not be enumerable"); michael@0: } michael@0: if (desc.configurable) { michael@0: $ERROR("#4: Poisoned " + name + " should not be configurable"); michael@0: } michael@0: if (poison !== desc.get) { michael@0: $ERROR("#5: " + name + "'s getter not poisoned with same poison"); michael@0: } michael@0: if (poison !== desc.set) { michael@0: $ERROR("#6: " + name + "'s setter not poisoned with same poison"); michael@0: } michael@0: } michael@0: michael@0: checkPoison(function() {}, 'caller'); michael@0: checkPoison(function() {}, 'arguments'); michael@0: checkPoison((function() { return arguments; })(), 'caller'); michael@0: checkPoison((function() { return arguments; })(), 'callee'); michael@0: checkPoison((function() {}).bind(null), 'caller'); michael@0: checkPoison((function() {}).bind(null), 'arguments'); michael@0: