restricted-properties.js (868B)
1 // Copyright (C) 2015 Caitlin Potter. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: > 6 Functions created using GeneratorFunction syntactic form do not have own 7 properties "caller" or "arguments", but inherit them from 8 %FunctionPrototype%. 9 features: [generators] 10 ---*/ 11 12 function* generator() {} 13 14 assert.sameValue( 15 generator.hasOwnProperty('caller'), false, 'No "caller" own property' 16 ); 17 assert.sameValue( 18 generator.hasOwnProperty('arguments'), false, 'No "arguments" own property' 19 ); 20 21 assert.throws(TypeError, function() { 22 return generator.caller; 23 }); 24 25 assert.throws(TypeError, function() { 26 generator.caller = {}; 27 }); 28 29 assert.throws(TypeError, function() { 30 return generator.arguments; 31 }); 32 33 assert.throws(TypeError, function() { 34 generator.arguments = {}; 35 }); 36 37 reportCompare(0, 0);