From 186dd69b3a708171a1309be9509b8985bc20e305 Mon Sep 17 00:00:00 2001 From: arv Date: Mon, 13 Apr 2015 11:59:40 -0700 Subject: [PATCH] [es6] Fix length property of collection constructors {Map, Set, WeakMap, WeakSet}.length should be 0. BUG=v8:4021 LOG=N R=adamk@chromium.org Review URL: https://codereview.chromium.org/1073233002 Cr-Commit-Position: refs/heads/master@{#27798} --- src/collection.js | 2 ++ src/weak-collection.js | 2 ++ test/mjsunit/es6/collections.js | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/collection.js b/src/collection.js index 7effba9f96..4a73ff5d7f 100644 --- a/src/collection.js +++ b/src/collection.js @@ -236,6 +236,7 @@ function SetForEach(f, receiver) { %SetCode($Set, SetConstructor); +%FunctionSetLength($Set, 0); %FunctionSetPrototype($Set, new $Object()); %AddNamedProperty($Set.prototype, "constructor", $Set, DONT_ENUM); %AddNamedProperty( @@ -424,6 +425,7 @@ function MapForEach(f, receiver) { %SetCode($Map, MapConstructor); +%FunctionSetLength($Map, 0); %FunctionSetPrototype($Map, new $Object()); %AddNamedProperty($Map.prototype, "constructor", $Map, DONT_ENUM); %AddNamedProperty( diff --git a/src/weak-collection.js b/src/weak-collection.js index d6d8837563..4244792816 100644 --- a/src/weak-collection.js +++ b/src/weak-collection.js @@ -85,6 +85,7 @@ function SetUpWeakMap() { %CheckIsBootstrapping(); %SetCode($WeakMap, WeakMapConstructor); + %FunctionSetLength($WeakMap, 0); %FunctionSetPrototype($WeakMap, new $Object()); %AddNamedProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM); %AddNamedProperty( @@ -162,6 +163,7 @@ function SetUpWeakSet() { %CheckIsBootstrapping(); %SetCode($WeakSet, WeakSetConstructor); + %FunctionSetLength($WeakSet, 0); %FunctionSetPrototype($WeakSet, new $Object()); %AddNamedProperty($WeakSet.prototype, "constructor", $WeakSet, DONT_ENUM); %AddNamedProperty( diff --git a/test/mjsunit/es6/collections.js b/test/mjsunit/es6/collections.js index 888b6863c1..e1e7758b1a 100644 --- a/test/mjsunit/es6/collections.js +++ b/test/mjsunit/es6/collections.js @@ -346,7 +346,7 @@ function TestConstructor(C) { assertFalse(C === Object.prototype.constructor); assertSame(C, C.prototype.constructor); assertSame(C, (new C).__proto__.constructor); - assertEquals(1, C.length); + assertEquals(0, C.length); } TestConstructor(Set); TestConstructor(Map);