From 0a4881600d0a7162038f54969ba521c58f4e6e4d Mon Sep 17 00:00:00 2001 From: mike Date: Sat, 11 Apr 2015 14:14:19 -0700 Subject: [PATCH] Correct property descriptors on GeneratorPrototype The ES6 specification does not explicitly state the attributes for the 'next' and 'throw' property descriptors, so their values are defined by Section 17 [1]: > Every other data property described in clauses 18 through 26 and in > Annex B.2 has the attributes > { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } > unless otherwise specified. [1] https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-standard-built-in-objects BUG=v8:3986 LOG=N R=wingo,arv Review URL: https://codereview.chromium.org/1051363003 Cr-Commit-Position: refs/heads/master@{#27770} --- src/generator.js | 2 +- test/mjsunit/es6/generators-runtime.js | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/generator.js b/src/generator.js index 338b7085a3..031d56e37e 100644 --- a/src/generator.js +++ b/src/generator.js @@ -89,7 +89,7 @@ function SetUpGenerators() { // Set up non-enumerable functions on the generator prototype object. var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype; InstallFunctions(GeneratorObjectPrototype, - DONT_ENUM | DONT_DELETE | READ_ONLY, + DONT_ENUM, ["next", GeneratorObjectNext, "throw", GeneratorObjectThrow]); diff --git a/test/mjsunit/es6/generators-runtime.js b/test/mjsunit/es6/generators-runtime.js index 2500e82f71..6e8ee2ebd3 100644 --- a/test/mjsunit/es6/generators-runtime.js +++ b/test/mjsunit/es6/generators-runtime.js @@ -114,7 +114,28 @@ function TestGeneratorObjectPrototype() { assertArrayEquals(expected_property_names, found_property_names); - iterator_desc = Object.getOwnPropertyDescriptor(GeneratorObjectPrototype, + var constructor_desc = Object.getOwnPropertyDescriptor( + GeneratorObjectPrototype, "constructor"); + assertTrue(constructor_desc !== undefined); + assertFalse(constructor_desc.writable); + assertFalse(constructor_desc.enumerable); + assertTrue(constructor_desc.configurable); + + var next_desc = Object.getOwnPropertyDescriptor(GeneratorObjectPrototype, + "next"); + assertTrue(next_desc !== undefined); + assertTrue(next_desc.writable); + assertFalse(next_desc.enumerable); + assertTrue(next_desc.configurable); + + var throw_desc = Object.getOwnPropertyDescriptor(GeneratorObjectPrototype, + "throw"); + assertTrue(next_desc !== undefined); + assertTrue(next_desc.writable); + assertFalse(next_desc.enumerable); + assertTrue(next_desc.configurable); + + var iterator_desc = Object.getOwnPropertyDescriptor(GeneratorObjectPrototype, Symbol.iterator); assertTrue(iterator_desc !== undefined); assertFalse(iterator_desc.writable);