instance-restricted-properties.js 968 B

12345678910111213141516171819202122232425262728293031323334353637
  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. description: >
  5. Functions created using GeneratorFunction intrinsic function do not have
  6. own properties "caller" or "arguments", but inherit them from
  7. %FunctionPrototype%.
  8. features: [generators]
  9. ---*/
  10. var Generator = Object.getPrototypeOf(function*() {});
  11. var GeneratorFunction = Generator.constructor;
  12. var generator = new GeneratorFunction();
  13. assert.sameValue(
  14. generator.hasOwnProperty('caller'), false, 'No "caller" own property'
  15. );
  16. assert.sameValue(
  17. generator.hasOwnProperty('arguments'), false, 'No "arguments" own property'
  18. );
  19. assert.throws(TypeError, function() {
  20. return generator.caller;
  21. });
  22. assert.throws(TypeError, function() {
  23. generator.caller = {};
  24. });
  25. assert.throws(TypeError, function() {
  26. return generator.arguments;
  27. });
  28. assert.throws(TypeError, function() {
  29. generator.arguments = {};
  30. });