1 // Copyright 2014 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 function assertIteratorResult(value, done, result) { 6 assertEquals({value: value, done: done}, result); 7 } 8 9 function test(f) { 10 var cdesc = Object.getOwnPropertyDescriptor(f, "caller"); 11 var adesc = Object.getOwnPropertyDescriptor(f, "arguments"); 12 13 assertFalse(cdesc.enumerable); 14 assertFalse(cdesc.configurable); 15 16 assertFalse(adesc.enumerable); 17 assertFalse(adesc.configurable); 18 19 assertSame(cdesc.get, cdesc.set); 20 assertSame(cdesc.get, adesc.get); 21 assertSame(cdesc.get, adesc.set); 22 23 assertTrue(cdesc.get instanceof Function); 24 assertEquals(0, cdesc.get.length); 25 assertThrows(cdesc.get, TypeError); 26 27 assertThrows(function() { return f.caller; }, TypeError); 28 assertThrows(function() { f.caller = 42; }, TypeError); 29 assertThrows(function() { return f.arguments; }, TypeError); 30 assertThrows(function() { f.arguments = 42; }, TypeError); 31 } 32 33 function *sloppy() { test(sloppy); } 34 function *strict() { "use strict"; test(strict); } 35 36 test(sloppy); 37 test(strict); 38 39 assertIteratorResult(undefined, true, sloppy().next()); 40 assertIteratorResult(undefined, true, strict().next()); 41