Implement the built-in Set and Map classes for ES6.

Implement these two new classes from the spec and enable relevant
test262 tests for them.

These new classes are only available when the version is
VERSION_ES6 or higher.

WeakSet and WeakMap will come next once we have these squared away.
diff --git a/src/org/mozilla/javascript/ES6Iterator.java b/src/org/mozilla/javascript/ES6Iterator.java
index c29b60d..431effd 100644
--- a/src/org/mozilla/javascript/ES6Iterator.java
+++ b/src/org/mozilla/javascript/ES6Iterator.java
@@ -28,17 +28,19 @@
     }
 
     protected boolean exhausted = false;
+    private String tag;
 
     ES6Iterator() {}
 
-    ES6Iterator(Scriptable scope) {
+    ES6Iterator(Scriptable scope, String tag) {
         // Set parent and prototype properties. Since we don't have a
         // "Iterator" constructor in the top scope, we stash the
         // prototype in the top scope's associated value.
+        this.tag = tag;
         Scriptable top = ScriptableObject.getTopLevelScope(scope);
         this.setParentScope(top);
         IdScriptableObject prototype = (IdScriptableObject)
-            ScriptableObject.getTopScopeValue(top, getTag());
+            ScriptableObject.getTopScopeValue(top, tag);
         setPrototype(prototype);
     }
 
@@ -49,11 +51,11 @@
             case Id_next:
                 initPrototypeMethod(getTag(), id, NEXT_METHOD, 0);
                 return;
-            case Id_iterator:
-                initPrototypeMethod(getTag(), id, SymbolKey.ITERATOR, "[Symbol.iterator]", 0);
+            case SymbolId_iterator:
+                initPrototypeMethod(getTag(), id, SymbolKey.ITERATOR, "[Symbol.iterator]", DONTENUM | READONLY);
                 return;
-            case Id_toStringTag:
-                initPrototypeValue(Id_toStringTag, SymbolKey.TO_STRING_TAG, getClassName(), DONTENUM | READONLY);
+            case SymbolId_toStringTag:
+                initPrototypeValue(SymbolId_toStringTag, SymbolKey.TO_STRING_TAG, getClassName(), DONTENUM | READONLY);
                 return;
             default: throw new IllegalArgumentException(String.valueOf(id));
         }
@@ -76,7 +78,7 @@
         switch (id) {
         case Id_next:
             return iterator.next(cx, scope);
-        case Id_iterator:
+        case SymbolId_iterator:
             return iterator;
         default:
             throw new IllegalArgumentException(String.valueOf(id));
@@ -86,9 +88,9 @@
     @Override
     protected int findPrototypeId(Symbol k) {
         if (SymbolKey.ITERATOR.equals(k)) {
-            return Id_iterator;
+            return SymbolId_iterator;
         } else if (SymbolKey.TO_STRING_TAG.equals(k)) {
-            return Id_toStringTag;
+            return SymbolId_toStringTag;
         }
         return 0;
     }
@@ -116,7 +118,9 @@
         return makeIteratorResult(cx, scope, done, value);
     }
 
-    abstract protected String getTag();
+    protected String getTag() {
+        return tag;
+    }
 
     // 25.1.1.3 The IteratorResult Interface
     private Scriptable makeIteratorResult(Context cx, Scriptable scope, boolean done, Object value) {
@@ -127,10 +131,10 @@
     }
 
     private static final int
-        Id_next             = 1,
-        Id_iterator         = 2,
-        Id_toStringTag      = 3,
-        MAX_PROTOTYPE_ID    = Id_toStringTag;
+        Id_next              = 1,
+        SymbolId_iterator    = 2,
+        SymbolId_toStringTag = 3,
+        MAX_PROTOTYPE_ID     = SymbolId_toStringTag;
 
     public static final String NEXT_METHOD = "next";
     public static final String DONE_PROPERTY = "done";
diff --git a/src/org/mozilla/javascript/Hashtable.java b/src/org/mozilla/javascript/Hashtable.java
new file mode 100644
index 0000000..53f8fdc
--- /dev/null
+++ b/src/org/mozilla/javascript/Hashtable.java
@@ -0,0 +1,250 @@
+package org.mozilla.javascript;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * This generic hash table class is used by Set and Map. It uses
+ * a standard HashMap for storing keys and values so that we can handle
+ * lots of hash collisions if necessary, and a doubly-linked list to support the iterator
+ * capability.
+ * <p>
+ * This second one is important because JavaScript handling of
+ * the iterator is completely different from the way that Java does it. In Java
+ * an attempt to modify a collection on a HashMap or LinkedHashMap while iterating
+ * through it (except by using the "remove" method on the Iterator object itself) results in a
+ * ConcurrentModificationException. JavaScript Maps and Sets explicitly allow
+ * the collection to be modified, or even cleared completely, while iterators
+ * exist, and even lets an iterator keep on iterating on a collection that was
+ * empty when it was created..
+ */
+public class Hashtable
+    implements Serializable, Iterable<Hashtable.Entry>
+{
+    private final HashMap<Object, Entry> map = new HashMap<>();
+    private Entry first = null;
+    private Entry last = null;
+
+    /**
+     * One entry in the hash table. Override equals and hashcode because
+     * this is another area in which JavaScript and Java differ. This entry
+     * also becomes a node in the linked list.
+     */
+    public static final class Entry
+        implements Serializable {
+        protected Object key;
+        protected Object value;
+        protected boolean deleted;
+        protected Entry next;
+        protected Entry prev;
+        private final int hashCode;
+
+        Entry() {
+            hashCode = 0;
+        }
+
+        Entry(Object k, Object value) {
+            if ((k instanceof Number) && ( ! ( k instanceof Double))) {
+                // Hash comparison won't work if we don't do this
+                this.key = ((Number)k).doubleValue();
+            } else {
+                this.key = k;
+            }
+
+            if (key == null) {
+                hashCode = 0;
+            } else if (k.equals(ScriptRuntime.negativeZero)) {
+                hashCode = 0;
+            } else {
+                hashCode = key.hashCode();
+            }
+
+            this.value = value;
+        }
+
+        public Object key() {
+            return key;
+        }
+
+        public Object value() {
+            return value;
+        }
+
+        /**
+         * Zero out key and value and return old value.
+         */
+        Object clear() {
+            final Object ret = value;
+            key = Undefined.instance;
+            value = Undefined.instance;
+            deleted = true;
+            return ret;
+        }
+
+        @Override
+        public int hashCode() {
+            return hashCode;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            try {
+                return ScriptRuntime.sameZero(key, ((Entry)o).key);
+            } catch (ClassCastException cce) {
+                return false;
+            }
+        }
+    }
+
+    private Entry makeDummy() {
+        final Entry d = new Entry();
+        d.clear();
+        return d;
+    }
+
+    public int size() {
+        return map.size();
+    }
+
+    public void put(Object key, Object value) {
+        final Entry nv = new Entry(key, value);
+        final Entry ev = map.putIfAbsent(nv, nv);
+        if (ev == null) {
+            // New value -- insert to end of doubly-linked list
+            if (first == null) {
+                first = last = nv;
+            } else {
+                last.next = nv;
+                nv.prev = last;
+                last = nv;
+            }
+        } else {
+            // Update the existing value and keep it in the same place in the list
+            ev.value = value;
+        }
+    }
+
+    public Object get(Object key) {
+        final Entry e = new Entry(key, null);
+        final Entry v = map.get(e);
+        if (v == null) {
+            return null;
+        }
+        return v.value;
+    }
+
+    public boolean has(Object key) {
+        final Entry e = new Entry(key, null);
+        return map.containsKey(e);
+    }
+
+    public Object delete(Object key) {
+        final Entry e = new Entry(key, null);
+        final Entry v = map.remove(e);
+        if (v == null) {
+            return null;
+        }
+
+        // To keep existing iterators moving forward as specified in EC262,
+        // we will remove the "prev" pointers from the list but leave the "next"
+        // pointers intact. Once we do that, then the only things pointing to
+        // the deleted nodes are existing iterators. Once those are gone, then
+        // these objects will be GCed.
+        // This way, new iterators will not "see" the deleted elements, and
+        // existing iterators will continue from wherever they left off to
+        // continue iterating in insertion order.
+        if (v == first) {
+            if (v == last) {
+                // Removing the only element. Leave it as a dummy or existing iterators
+                // will never stop.
+                v.clear();
+                v.prev = null;
+            } else {
+                first = v.next;
+                first.prev = null;
+                if (first.next != null) {
+                    first.next.prev = first;
+                }
+            }
+        } else {
+            final Entry prev = v.prev;
+            prev.next = v.next;
+            v.prev = null;
+            if (v.next != null) {
+                v.next.prev = prev;
+            } else {
+                assert(v == last);
+                last = prev;
+            }
+        }
+        // Still clear the node in case it is in the chain of some iterator
+        return v.clear();
+    }
+
+    public void clear() {
+        // Zero out all the entries so that existing iterators will skip them all
+        Iterator<Entry> it = iterator();
+        it.forEachRemaining(Entry::clear);
+
+        // Replace the existing list with a dummy, and make it the last node
+        // of the current list. If new nodes are added now, existing iterators
+        // will drive forward right into the new list. If they are not, then
+        // nothing is referencing the old list and it'll get GCed.
+        if (first != null) {
+            Entry dummy = new Entry();
+            dummy.clear();
+            last.next = dummy;
+            first = last = dummy;
+        }
+
+        // Now we can clear the actual hashtable!
+        map.clear();
+    }
+
+    public Iterator<Entry> iterator() {
+        return new Iter(first);
+    }
+
+    // The iterator for this class works directly on the linked list so that it implements
+    // the specified iteration behavior, which is very different from Java.
+    private final class Iter
+        implements Iterator<Entry>
+    {
+        private Entry pos;
+
+        Iter(Entry start) {
+            // Keep the logic simpler by having a dummy at the start
+            Entry dummy = makeDummy();
+            dummy.next = start;
+            this.pos = dummy;
+        }
+
+        private void skipDeleted() {
+            // Skip forward past deleted elements, which could appear due to
+            // "delete" or a "clear" operation after this iterator was created.
+            // End up just before the next non-deleted node.
+            while ((pos.next != null) && pos.next.deleted) {
+                pos = pos.next;
+            }
+        }
+
+        @Override
+        public boolean hasNext() {
+            skipDeleted();
+            return ((pos != null) && (pos.next != null));
+        }
+
+        @Override
+        public Entry next() {
+            skipDeleted();
+            if ((pos == null) || (pos.next == null)) {
+                throw new NoSuchElementException();
+            }
+            final Entry e = pos.next;
+            pos = pos.next;
+            return e;
+        }
+    }
+}
diff --git a/src/org/mozilla/javascript/IdScriptableObject.java b/src/org/mozilla/javascript/IdScriptableObject.java
index eb9facb..bd19e83 100644
--- a/src/org/mozilla/javascript/IdScriptableObject.java
+++ b/src/org/mozilla/javascript/IdScriptableObject.java
@@ -112,10 +112,10 @@
                 return;
             }
 
-            initSlot(id, "", value, attributes);
+            initSlot(id, key, value, attributes);
         }
 
-        private void initSlot(int id, String name, Object value,
+        private void initSlot(int id, Object name, Object value,
                               int attributes)
         {
             Object[] array = valueArray;
@@ -253,7 +253,7 @@
             }
         }
 
-        final Object[] getNames(boolean getAll, Object[] extraEntries)
+        final Object[] getNames(boolean getAll, boolean getSymbols, Object[] extraEntries)
         {
             Object[] names = null;
             int count = 0;
@@ -262,11 +262,18 @@
                 if (getAll || (attributeArray[id - 1] & DONTENUM) == 0) {
                     if (value != NOT_FOUND) {
                         int nameSlot = (id  - 1) * SLOT_SPAN + NAME_SLOT;
-                        String name = (String)valueArray[nameSlot];
-                        if (names == null) {
-                            names = new Object[maxId];
+                        Object name = valueArray[nameSlot];
+                        if (name instanceof String) {
+                            if (names == null) {
+                                names = new Object[maxId];
+                            }
+                            names[count++] = name;
+                        } else if (getSymbols && (name instanceof Symbol)) {
+                            if (names == null) {
+                                names = new Object[maxId];
+                            }
+                            names[count++] = name.toString();
                         }
-                        names[count++] = name;
                     }
                 }
             }
@@ -634,7 +641,7 @@
         Object[] result = super.getIds(getNonEnumerable, getSymbols);
 
         if (prototypeValues != null) {
-            result = prototypeValues.getNames(getNonEnumerable, result);
+            result = prototypeValues.getNames(getNonEnumerable, getSymbols, result);
         }
 
         int maxInstanceId = getMaxInstanceId();
diff --git a/src/org/mozilla/javascript/IteratorLikeIterable.java b/src/org/mozilla/javascript/IteratorLikeIterable.java
new file mode 100644
index 0000000..f429c4d
--- /dev/null
+++ b/src/org/mozilla/javascript/IteratorLikeIterable.java
@@ -0,0 +1,82 @@
+package org.mozilla.javascript;
+
+import java.io.Closeable;
+import java.util.Iterator;
+
+/**
+ * This is a class that makes it easier to iterate over "iterator-like" objects as defined
+ * in the ECMAScript spec. The caller is responsible for retrieving an object that implements
+ * the "iterator" pattern. This class will follow that pattern and throw appropriate
+ * JavaScript exceptions.
+ *
+ * The pattern that the target class should follow is:
+ * * It should have a function property called "next"
+ * * The property should return an object with a boolean value called "done".
+ * * If "done" is true, then the returned object should also contain a "value" property.
+ * * If it has a function property called "return" then it will be called
+ *   when the caller is done iterating.
+ */
+public class IteratorLikeIterable
+    implements Iterable<Object>, Closeable
+{
+    private final Context cx;
+    private final Scriptable scope;
+    private final Callable next;
+    private final Callable returnFunc;
+    private final Scriptable iterator;
+    private boolean closed;
+
+    public IteratorLikeIterable(Context cx, Scriptable scope, Object target) {
+        this.cx = cx;
+        this.scope = scope;
+        next = ScriptRuntime.getPropFunctionAndThis(target, "next", cx, scope);
+        iterator = ScriptRuntime.lastStoredScriptable(cx);
+        Scriptable st = ScriptableObject.ensureScriptable(target);
+        if (st.has("return", st)) {
+            returnFunc = ScriptRuntime.getPropFunctionAndThis(target, "return", cx, scope);
+            ScriptRuntime.lastStoredScriptable(cx);
+        } else {
+            returnFunc = null;
+        }
+    }
+
+    @Override
+    public void close() {
+        if (!closed) {
+            closed = true;
+            if (returnFunc != null) {
+                returnFunc.call(cx, scope, iterator, ScriptRuntime.emptyArgs);
+            }
+        }
+    }
+
+    @Override
+    public Itr iterator() {
+        return new Itr();
+    }
+
+    public final class Itr
+        implements Iterator<Object>
+    {
+        private Object nextVal;
+
+        @Override
+        public boolean hasNext() {
+            final Object val = next.call(cx, scope, iterator, ScriptRuntime.emptyArgs);
+            final Object doneval = ScriptRuntime.getObjectProp(val, "done", cx, scope);
+            if (Undefined.instance.equals(doneval)) {
+                throw ScriptRuntime.undefReadError(val, "done");
+            }
+            if (Boolean.TRUE.equals(doneval)) {
+                return false;
+            }
+            nextVal = ScriptRuntime.getObjectProp(val, "value", cx, scope);
+            return true;
+        }
+
+        @Override
+        public Object next() {
+            return nextVal;
+        }
+    }
+}
diff --git a/src/org/mozilla/javascript/NativeArrayIterator.java b/src/org/mozilla/javascript/NativeArrayIterator.java
index 1507095..b8eeccd 100644
--- a/src/org/mozilla/javascript/NativeArrayIterator.java
+++ b/src/org/mozilla/javascript/NativeArrayIterator.java
@@ -22,7 +22,7 @@
     }
 
     public NativeArrayIterator(Scriptable scope, Scriptable arrayLike) {
-        super(scope);
+        super(scope, ITERATOR_TAG);
         this.index = 0;
         this.arrayLike = arrayLike;
     }
diff --git a/src/org/mozilla/javascript/NativeCollectionIterator.java b/src/org/mozilla/javascript/NativeCollectionIterator.java
new file mode 100644
index 0000000..b9ff787
--- /dev/null
+++ b/src/org/mozilla/javascript/NativeCollectionIterator.java
@@ -0,0 +1,60 @@
+package org.mozilla.javascript;
+
+import java.util.Collections;
+import java.util.Iterator;
+
+public class NativeCollectionIterator
+    extends ES6Iterator
+{
+    private final Iterator<Hashtable.Entry> iterator;
+    private final String className;
+    private final Type type;
+
+    enum Type { KEYS, VALUES, BOTH };
+
+    static void init(ScriptableObject scope, String tag, boolean sealed) {
+        ES6Iterator.init(scope, sealed, new NativeCollectionIterator(tag), tag);
+    }
+
+    public NativeCollectionIterator(String tag)
+    {
+        this.className = tag;
+        this.iterator = Collections.emptyIterator();
+        this.type = Type.BOTH;
+    }
+
+    public NativeCollectionIterator(
+        Scriptable scope, String className,
+        Type type, Iterator<Hashtable.Entry> iterator)
+    {
+        super(scope, className);
+        this.className = className;
+        this.iterator = iterator;
+        this.type = type;
+    }
+
+    @Override
+    public String getClassName() {
+        return className;
+    }
+
+    @Override
+    protected boolean isDone(Context cx, Scriptable scope) {
+        return !iterator.hasNext();
+    }
+
+    @Override
+    protected Object nextValue(Context cx, Scriptable scope) {
+        final Hashtable.Entry e = iterator.next();
+        switch (type) {
+            case KEYS:
+                return e.key;
+            case VALUES:
+                return e.value;
+            case BOTH:
+                return cx.newArray(scope, new Object[] { e.key, e.value });
+            default:
+                throw new AssertionError();
+        }
+    }
+}
diff --git a/src/org/mozilla/javascript/NativeMap.java b/src/org/mozilla/javascript/NativeMap.java
new file mode 100644
index 0000000..53e1e7d
--- /dev/null
+++ b/src/org/mozilla/javascript/NativeMap.java
@@ -0,0 +1,301 @@
+package org.mozilla.javascript;
+
+import java.util.Iterator;
+
+public class NativeMap
+    extends IdScriptableObject
+{
+    private static final Object MAP_TAG = "Map";
+    static final String ITERATOR_TAG = "Map Iterator";
+
+    private final Hashtable entries = new Hashtable();
+
+    private boolean instanceOfMap = false;
+
+    static void init(Context cx, Scriptable scope, boolean sealed)
+    {
+        NativeMap obj = new NativeMap();
+        obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, false);
+
+        ScriptableObject desc = (ScriptableObject)cx.newObject(scope);
+        desc.put("enumerable", desc, false);
+        desc.put("configurable", desc, true);
+        desc.put("get", desc, obj.get(NativeSet.GETSIZE, obj));
+        obj.defineOwnProperty(cx, "size", desc);
+
+        if (sealed) {
+            obj.sealObject();
+        }
+    }
+
+    @Override
+    public String getClassName() {
+        return "Map";
+    }
+
+    @Override
+    public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope,
+                             Scriptable thisObj, Object[] args)
+    {
+        if (!f.hasTag(MAP_TAG)) {
+            return super.execIdCall(f, cx, scope, thisObj, args);
+        }
+        int id = f.methodId();
+        switch (id) {
+            case Id_constructor:
+                if (thisObj == null) {
+                    NativeMap nm = new NativeMap();
+                    nm.instanceOfMap = true;
+                    if (args.length > 0) {
+                        nm.js_load(cx, scope, args[0]);
+                    }
+                    return nm;
+                } else {
+                    throw ScriptRuntime.typeError1("msg.no.new", "Map");
+                }
+            case Id_set:
+                return realThis(thisObj, f).js_set(
+                    args.length > 0 ? args[0] : Undefined.instance,
+                    args.length > 1 ? args[1] : Undefined.instance);
+            case Id_delete:
+                return realThis(thisObj, f).js_delete(args.length > 0 ? args[0] : Undefined.instance);
+            case Id_get:
+                return realThis(thisObj, f).js_get(args.length > 0 ? args[0] : Undefined.instance);
+            case Id_has:
+                return realThis(thisObj, f).js_has(args.length > 0 ? args[0] : Undefined.instance);
+            case Id_clear:
+                return realThis(thisObj, f).js_clear();
+            case Id_keys:
+                return realThis(thisObj, f).js_iterator(scope, NativeCollectionIterator.Type.KEYS);
+            case Id_values:
+                return realThis(thisObj, f).js_iterator(scope, NativeCollectionIterator.Type.VALUES);
+            case Id_entries:
+                return realThis(thisObj, f).js_iterator(scope, NativeCollectionIterator.Type.BOTH);
+            case Id_forEach:
+                return realThis(thisObj, f).js_forEach(cx, scope,
+                        args.length > 0 ? args[0] : Undefined.instance,
+                        args.length > 1 ? args[1] : Undefined.instance);
+            case SymbolId_getSize:
+                return realThis(thisObj, f).js_getSize();
+        }
+        throw new IllegalArgumentException("Map.prototype has no method: " + f.getFunctionName());
+    }
+
+    private Object js_set(Object arg1, Object arg2)
+    {
+        entries.put(arg1, arg2);
+        return this;
+    }
+
+    private Object js_delete(Object arg)
+    {
+        final Object e = entries.delete(arg);
+        return (e != null);
+    }
+
+    private Object js_get(Object arg)
+    {
+        final Object val = entries.get(arg);
+        return val == null ? Undefined.instance : val;
+    }
+
+    private Object js_has(Object arg)
+    {
+        return entries.has(arg);
+    }
+
+    private Object js_getSize()
+    {
+        return entries.size();
+    }
+
+    private Object js_iterator(Scriptable scope, NativeCollectionIterator.Type type)
+    {
+        return new NativeCollectionIterator(scope, ITERATOR_TAG, type, entries.iterator());
+    }
+
+    private Object js_clear()
+    {
+        entries.clear();
+        return Undefined.instance;
+    }
+
+    private Object js_forEach(Context cx, Scriptable scope, Object arg1, Object arg2)
+    {
+        if (!(arg1 instanceof Callable)) {
+            throw ScriptRuntime.typeError2("msg.isnt.function", arg1, ScriptRuntime.typeof(arg1));
+        }
+        final Callable f = (Callable)arg1;
+
+        Iterator<Hashtable.Entry> i = entries.iterator();
+        while (i.hasNext()) {
+            // Per spec must convert every time so that primitives are always regenerated...
+            Scriptable thisObj = ScriptRuntime.toObjectOrNull(cx, arg2, scope);
+            if (thisObj == null) {
+                thisObj = Undefined.SCRIPTABLE_UNDEFINED;
+            }
+            final Hashtable.Entry e = i.next();
+            f.call(cx, scope, thisObj,
+                    new Object[] { e.value, e.key, this });
+        }
+        return Undefined.instance;
+    }
+
+    /**
+     * If an "iterable" object was passed to the constructor, there are many many things
+     * to do...
+     */
+    private void js_load(Context cx, Scriptable scope, Object arg1)
+    {
+        if ((arg1 == null) || Undefined.instance.equals(arg1)) {
+            return;
+        }
+
+        // Call the "[Symbol.iterator]" property as a function.
+        final Object ito = ScriptRuntime.callIterator(arg1, cx, scope);
+        if (Undefined.instance.equals(ito)) {
+            // Per spec, ignore if the iterator is undefined
+            return;
+        }
+
+        // Find the "add" function of our own prototype, since it might have
+        // been replaced. Since we're not fully constructed yet, create a dummy instance
+        // so that we can get our own prototype.
+        ScriptableObject dummy = ensureScriptableObject(cx.newObject(scope, getClassName()));
+        final Callable set =
+                ScriptRuntime.getPropFunctionAndThis(dummy.getPrototype(), "set", cx, scope);
+        ScriptRuntime.lastStoredScriptable(cx);
+
+        // Finally, run through all the iterated values and add them!
+        try (IteratorLikeIterable it = new IteratorLikeIterable(cx, scope, ito)) {
+            for (Object val : it) {
+                Scriptable sVal = ScriptableObject.ensureScriptable(val);
+                if (sVal instanceof Symbol) {
+                    throw ScriptRuntime.typeError1("msg.arg.not.object", ScriptRuntime.typeof(sVal));
+                }
+                Object finalKey = sVal.get(0, sVal);
+                Object finalVal = sVal.get(1, sVal);
+                set.call(cx, scope, this, new Object[] { finalKey, finalVal });
+            }
+        }
+    }
+
+    private NativeMap realThis(Scriptable thisObj, IdFunctionObject f)
+    {
+        if (thisObj == null) {
+            throw incompatibleCallError(f);
+        }
+        try {
+            final NativeMap nm = (NativeMap)thisObj;
+            if (!nm.instanceOfMap) {
+                // Check for "Map internal data tag"
+                throw incompatibleCallError(f);
+            }
+            return nm;
+        } catch (ClassCastException cce) {
+            throw incompatibleCallError(f);
+        }
+    }
+
+    @Override
+    protected void initPrototypeId(int id)
+    {
+        switch (id) {
+            case SymbolId_getSize:
+                initPrototypeMethod(MAP_TAG, id, NativeSet.GETSIZE, "get size", 0);
+                return;
+            case SymbolId_toStringTag:
+                initPrototypeValue(SymbolId_toStringTag, SymbolKey.TO_STRING_TAG,
+                    getClassName(), DONTENUM | READONLY);
+                return;
+            // fallthrough
+        }
+
+        String s, fnName = null;
+        int arity;
+        switch (id) {
+            case Id_constructor:       arity=0; s="constructor";       break;
+            case Id_set:               arity=2; s="set";               break;
+            case Id_get:               arity=1; s="get";               break;
+            case Id_delete:            arity=1; s="delete";            break;
+            case Id_has:               arity=1; s="has";               break;
+            case Id_clear:             arity=0; s="clear";             break;
+            case Id_keys:              arity=0; s="keys";              break;
+            case Id_values:            arity=0; s="values";            break;
+            case Id_entries:           arity=0; s="entries";           break;
+            case Id_forEach:           arity=1; s="forEach";           break;
+            default: throw new IllegalArgumentException(String.valueOf(id));
+        }
+        initPrototypeMethod(MAP_TAG, id, s, fnName, arity);
+    }
+
+    @Override
+    protected int findPrototypeId(Symbol k)
+    {
+        if (NativeSet.GETSIZE.equals(k)) {
+            return SymbolId_getSize;
+        }
+        if (SymbolKey.ITERATOR.equals(k)) {
+            // ECMA spec says that the "Symbol.iterator" property of the prototype has the
+            // "same value" as the "entries" property. We implement this by returning the
+            // ID of "entries" when the iterator symbol is accessed.
+            return Id_entries;
+        }
+        if (SymbolKey.TO_STRING_TAG.equals(k)) {
+            return SymbolId_toStringTag;
+        }
+        return 0;
+    }
+
+// #string_id_map#
+
+    @Override
+    protected int findPrototypeId(String s)
+    {
+        int id;
+// #generated# Last update: 2018-03-22 02:20:25 MDT
+        L0: { id = 0; String X = null; int c;
+            L: switch (s.length()) {
+            case 3: c=s.charAt(0);
+                if (c=='g') { if (s.charAt(2)=='t' && s.charAt(1)=='e') {id=Id_get; break L0;} }
+                else if (c=='h') { if (s.charAt(2)=='s' && s.charAt(1)=='a') {id=Id_has; break L0;} }
+                else if (c=='s') { if (s.charAt(2)=='t' && s.charAt(1)=='e') {id=Id_set; break L0;} }
+                break L;
+            case 4: X="keys";id=Id_keys; break L;
+            case 5: X="clear";id=Id_clear; break L;
+            case 6: c=s.charAt(0);
+                if (c=='d') { X="delete";id=Id_delete; }
+                else if (c=='v') { X="values";id=Id_values; }
+                break L;
+            case 7: c=s.charAt(0);
+                if (c=='e') { X="entries";id=Id_entries; }
+                else if (c=='f') { X="forEach";id=Id_forEach; }
+                break L;
+            case 11: X="constructor";id=Id_constructor; break L;
+            }
+            if (X!=null && X!=s && !X.equals(s)) id = 0;
+            break L0;
+        }
+// #/generated#
+        return id;
+    }
+
+    // Note that "SymbolId_iterator" is not present here. That's because the spec
+    // requires that it be the same value as the "entries" prototype property.
+    private static final int
+        Id_constructor = 1,
+        Id_set = 2,
+        Id_get = 3,
+        Id_delete = 4,
+        Id_has = 5,
+        Id_clear = 6,
+        Id_keys = 7,
+        Id_values = 8,
+        Id_entries = 9,
+        Id_forEach = 10,
+        SymbolId_getSize = 11,
+        SymbolId_toStringTag = 12,
+        MAX_PROTOTYPE_ID = SymbolId_toStringTag;
+
+// #/string_id_map#
+}
diff --git a/src/org/mozilla/javascript/NativeSet.java b/src/org/mozilla/javascript/NativeSet.java
new file mode 100644
index 0000000..292fcbe
--- /dev/null
+++ b/src/org/mozilla/javascript/NativeSet.java
@@ -0,0 +1,282 @@
+package org.mozilla.javascript;
+
+import java.util.Iterator;
+
+public class NativeSet
+    extends IdScriptableObject
+{
+    private static final Object SET_TAG = "Set";
+    static final String ITERATOR_TAG = "Set Iterator";
+
+    static final SymbolKey GETSIZE = new SymbolKey("[Symbol.getSize]");
+
+    private final Hashtable entries = new Hashtable();
+
+    private boolean instanceOfSet = false;
+
+    static void init(Context cx, Scriptable scope, boolean sealed)
+    {
+        NativeSet obj = new NativeSet();
+        obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, false);
+
+        ScriptableObject desc = (ScriptableObject)cx.newObject(scope);
+        desc.put("enumerable", desc, false);
+        desc.put("configurable", desc, true);
+        desc.put("get", desc, obj.get(GETSIZE, obj));
+        obj.defineOwnProperty(cx, "size", desc);
+
+        if (sealed) {
+            obj.sealObject();
+        }
+    }
+
+    @Override
+    public String getClassName() {
+        return "Set";
+    }
+
+    @Override
+    public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope,
+                             Scriptable thisObj, Object[] args)
+    {
+        if (!f.hasTag(SET_TAG)) {
+            return super.execIdCall(f, cx, scope, thisObj, args);
+        }
+        final int id = f.methodId();
+        switch (id) {
+            case Id_constructor:
+                if (thisObj == null) {
+                    NativeSet ns = new NativeSet();
+                    ns.instanceOfSet = true;
+                    if (args.length > 0) {
+                        ns.js_load(cx, scope, args[0]);
+                    }
+                    return ns;
+                } else {
+                    throw ScriptRuntime.typeError1("msg.no.new", "Set");
+                }
+            case Id_add:
+                return realThis(thisObj, f).js_add(args.length > 0 ? args[0] : Undefined.instance);
+            case Id_delete:
+                return realThis(thisObj, f).js_delete(args.length > 0 ? args[0] : Undefined.instance);
+            case Id_has:
+                return realThis(thisObj, f).js_has(args.length > 0 ? args[0] : Undefined.instance);
+            case Id_clear:
+                return realThis(thisObj, f).js_clear();
+            case Id_values:
+                return realThis(thisObj, f).js_iterator(scope, NativeCollectionIterator.Type.VALUES);
+            case Id_entries:
+                return realThis(thisObj, f).js_iterator(scope, NativeCollectionIterator.Type.BOTH);
+            case Id_forEach:
+                return realThis(thisObj, f).js_forEach(cx, scope,
+                    args.length > 0 ? args[0] : Undefined.instance,
+                    args.length > 1 ? args[1] : Undefined.instance);
+            case SymbolId_getSize:
+                return realThis(thisObj, f).js_getSize();
+        }
+        throw new IllegalArgumentException("Set.prototype has no method: " + f.getFunctionName());
+    }
+
+    private Object js_add(Object arg)
+    {
+        entries.put(arg, arg);
+        return this;
+    }
+
+    private Object js_delete(Object arg)
+    {
+        final Object ov = entries.delete(arg);
+        return (ov != null);
+    }
+
+    private Object js_has(Object arg)
+    {
+        return entries.has(arg);
+    }
+
+    private Object js_clear()
+    {
+        entries.clear();
+        return Undefined.instance;
+    }
+
+    private Object js_getSize()
+    {
+        return entries.size();
+    }
+
+    private Object js_iterator(Scriptable scope, NativeCollectionIterator.Type type)
+    {
+        return new NativeCollectionIterator(scope, ITERATOR_TAG, type, entries.iterator());
+    }
+
+    private Object js_forEach(Context cx, Scriptable scope, Object arg1, Object arg2)
+    {
+        if (!(arg1 instanceof Callable)) {
+            throw ScriptRuntime.notFunctionError(arg1);
+        }
+        final Callable f = (Callable)arg1;
+
+        Iterator<Hashtable.Entry> i = entries.iterator();
+        while (i.hasNext()) {
+            // Per spec must convert every time so that primitives are always regenerated...
+            Scriptable thisObj = ScriptRuntime.toObjectOrNull(cx, arg2, scope);
+            if (thisObj == null) {
+                thisObj = Undefined.SCRIPTABLE_UNDEFINED;
+            }
+            final Hashtable.Entry e = i.next();
+            f.call(cx, scope, thisObj,
+                new Object[] { e.value, e.value, this });
+        }
+        return Undefined.instance;
+    }
+
+    /**
+     * If an "iterable" object was passed to the constructor, there are many many things
+     * to do...
+     */
+    private void js_load(Context cx, Scriptable scope, Object arg1)
+    {
+        if ((arg1 == null) || Undefined.instance.equals(arg1)) {
+            return;
+        }
+
+        // Call the "[Symbol.iterator]" property as a function.
+        Object ito = ScriptRuntime.callIterator(arg1, cx, scope);
+        if (Undefined.instance.equals(ito)) {
+            // Per spec, ignore if the iterator is undefined
+            return;
+        }
+
+        // Find the "add" function of our own prototype, since it might have
+        // been replaced. Since we're not fully constructed yet, create a dummy instance
+        // so that we can get our own prototype.
+        ScriptableObject dummy = ensureScriptableObject(cx.newObject(scope, getClassName()));
+        final Callable add =
+            ScriptRuntime.getPropFunctionAndThis(dummy.getPrototype(), "add", cx, scope);
+        ScriptRuntime.lastStoredScriptable(cx);
+
+        // Finally, run through all the iterated values and add them!
+        try (IteratorLikeIterable it = new IteratorLikeIterable(cx, scope, ito)) {
+            for (Object val : it) {
+                final Object finalVal = val == Scriptable.NOT_FOUND ? Undefined.instance : val;
+                add.call(cx, scope, this, new Object[]{finalVal});
+            }
+        }
+    }
+
+    private NativeSet realThis(Scriptable thisObj, IdFunctionObject f)
+    {
+        if (thisObj == null) {
+            throw incompatibleCallError(f);
+        }
+        try {
+            final NativeSet ns = (NativeSet)thisObj;
+            if (!ns.instanceOfSet) {
+                // If we get here, then this object doesn't have the "Set internal data slot."
+                throw incompatibleCallError(f);
+            }
+            return ns;
+        } catch (ClassCastException cce) {
+            throw incompatibleCallError(f);
+        }
+    }
+
+    @Override
+    protected void initPrototypeId(int id)
+    {
+        switch (id) {
+            case SymbolId_getSize:
+                initPrototypeMethod(SET_TAG, id, GETSIZE, "get size", 0);
+                return;
+            case SymbolId_toStringTag:
+                initPrototypeValue(SymbolId_toStringTag, SymbolKey.TO_STRING_TAG,
+                    getClassName(), DONTENUM | READONLY);
+                return;
+            // fallthrough
+        }
+
+        String s, fnName = null;
+        int arity;
+        switch (id) {
+            case Id_constructor:       arity=0; s="constructor";       break;
+            case Id_add:               arity=1; s="add";               break;
+            case Id_delete:            arity=1; s="delete";            break;
+            case Id_has:               arity=1; s="has";               break;
+            case Id_clear:             arity=0; s="clear";             break;
+            case Id_entries:           arity=0; s="entries";           break;
+            case Id_values:            arity=0; s="values";            break;
+            case Id_forEach:           arity=1; s="forEach";           break;
+            default: throw new IllegalArgumentException(String.valueOf(id));
+        }
+        initPrototypeMethod(SET_TAG, id, s, fnName, arity);
+    }
+
+    @Override
+    protected int findPrototypeId(Symbol k)
+    {
+        if (GETSIZE.equals(k)) {
+            return SymbolId_getSize;
+        }
+        if (SymbolKey.ITERATOR.equals(k)) {
+            return Id_values;
+        }
+        if (SymbolKey.TO_STRING_TAG.equals(k)) {
+            return SymbolId_toStringTag;
+        }
+        return 0;
+    }
+
+// #string_id_map#
+
+    @Override
+    protected int findPrototypeId(String s)
+    {
+        int id;
+// #generated# Last update: 2018-03-22 00:54:31 MDT
+        L0: { id = 0; String X = null; int c;
+            L: switch (s.length()) {
+            case 3: c=s.charAt(0);
+                if (c=='a') { if (s.charAt(2)=='d' && s.charAt(1)=='d') {id=Id_add; break L0;} }
+                else if (c=='h') { if (s.charAt(2)=='s' && s.charAt(1)=='a') {id=Id_has; break L0;} }
+                break L;
+            case 4: X="keys";id=Id_keys; break L;
+            case 5: X="clear";id=Id_clear; break L;
+            case 6: c=s.charAt(0);
+                if (c=='d') { X="delete";id=Id_delete; }
+                else if (c=='v') { X="values";id=Id_values; }
+                break L;
+            case 7: c=s.charAt(0);
+                if (c=='e') { X="entries";id=Id_entries; }
+                else if (c=='f') { X="forEach";id=Id_forEach; }
+                break L;
+            case 11: X="constructor";id=Id_constructor; break L;
+            }
+            if (X!=null && X!=s && !X.equals(s)) id = 0;
+            break L0;
+        }
+// #/generated#
+        return id;
+    }
+
+    // Note that SymbolId_iterator is not present because it is required to have the
+    // same value as the "values" entry.
+    // Similarly, "keys" is supposed to have the same value as "values," which is why
+    // both have the same ID.
+    private static final int
+            Id_constructor = 1,
+            Id_add = 2,
+            Id_delete = 3,
+            Id_has = 4,
+            Id_clear = 5,
+            Id_keys = 6,
+            Id_values = 6,  // These are deliberately the same to match the spec
+            Id_entries = 7,
+            Id_forEach = 8,
+            SymbolId_getSize = 9,
+            SymbolId_toStringTag = 10,
+            MAX_PROTOTYPE_ID = SymbolId_toStringTag;
+
+// #/string_id_map#
+}
+
diff --git a/src/org/mozilla/javascript/NativeStringIterator.java b/src/org/mozilla/javascript/NativeStringIterator.java
index 065b2d2..8936c74 100644
--- a/src/org/mozilla/javascript/NativeStringIterator.java
+++ b/src/org/mozilla/javascript/NativeStringIterator.java
@@ -22,7 +22,7 @@
     }
 
     NativeStringIterator(Scriptable scope, Scriptable stringLike) {
-        super(scope);
+        super(scope, ITERATOR_TAG);
         this.index = 0;
         this.string  = ScriptRuntime.toString(stringLike);
     }
diff --git a/src/org/mozilla/javascript/ScriptRuntime.java b/src/org/mozilla/javascript/ScriptRuntime.java
index 2c2628b..72f1f48 100644
--- a/src/org/mozilla/javascript/ScriptRuntime.java
+++ b/src/org/mozilla/javascript/ScriptRuntime.java
@@ -259,6 +259,10 @@
 
         if (cx.getLanguageVersion() >= Context.VERSION_ES6) {
             NativeSymbol.init(cx, scope, sealed);
+            NativeCollectionIterator.init(scope, NativeSet.ITERATOR_TAG, sealed);
+            NativeCollectionIterator.init(scope, NativeMap.ITERATOR_TAG, sealed);
+            NativeMap.init(cx, scope, sealed);
+            NativeSet.init(cx, scope, sealed);
         }
 
         if (scope instanceof TopLevel) {
@@ -2605,6 +2609,19 @@
     }
 
     /**
+     * Given an object, get the "Symbol.iterator" element, throw a TypeError if it
+     * is not present, then call the result, (throwing a TypeError if the result is
+     * not a function), and return that result, whatever it is.
+     */
+    public static Object callIterator(Object obj, Context cx, Scriptable scope)
+    {
+        final Callable getIterator =
+                ScriptRuntime.getElemFunctionAndThis(obj, SymbolKey.ITERATOR, cx, scope);
+        final Scriptable iterable = ScriptRuntime.lastStoredScriptable(cx);
+        return getIterator.call(cx, scope, iterable, ScriptRuntime.emptyArgs);
+    }
+
+    /**
      * Perform function call in reference context. Should always
      * return value that can be passed to
      * {@link #refGet(Ref, Context)} or {@link #refSet(Ref, Object, Context)}
@@ -3209,6 +3226,30 @@
         return eq(x, y);
     }
 
+    /**
+     * Implement "SameValueZero" from ECMA 7.2.9
+     */
+    public static boolean sameZero(Object x, Object y) {
+        if (!typeof(x).equals(typeof(y))) {
+            return false;
+        }
+        if (x instanceof Number) {
+            if (isNaN(x) && isNaN(y)) {
+                return true;
+            }
+            final double dx = ((Number)x).doubleValue();
+            if (y instanceof Number) {
+                final double dy = ((Number)y).doubleValue();
+                if (((dx == negativeZero) && (dy == 0.0)) ||
+                    ((dx == 0.0) && dy == negativeZero)) {
+                        return true;
+                }
+            }
+            return eqNumber(dx, y);
+        }
+        return eq(x, y);
+    }
+
     public static boolean isNaN(Object n) {
         if (n == NaNobj) {
             return true;
diff --git a/src/org/mozilla/javascript/resources/Messages.properties b/src/org/mozilla/javascript/resources/Messages.properties
index 4b262e3..742f32d 100644
--- a/src/org/mozilla/javascript/resources/Messages.properties
+++ b/src/org/mozilla/javascript/resources/Messages.properties
@@ -885,4 +885,7 @@
   Symbol objects may not be constructed using \"new\"
 
 msg.compare.symbol =\
-  Symbol objects may not be compared
\ No newline at end of file
+  Symbol objects may not be compared
+
+msg.no.new =\
+  {0} objects may not be constructed using \"new\"
diff --git a/testsrc/jstests/es6/collection-iterator.js b/testsrc/jstests/es6/collection-iterator.js
new file mode 100644
index 0000000..f3f5294
--- /dev/null
+++ b/testsrc/jstests/es6/collection-iterator.js
@@ -0,0 +1,281 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax
+
+load("testsrc/assert.js");
+
+function test(f) {
+  f();
+  f();
+  f();
+}
+
+test(function TestSetIterator() {
+  var s = new Set;
+  var iter = s.values();
+  //assertEquals('Set Iterator', %_ClassOf(iter));
+
+  var SetIteratorPrototype = iter.__proto__;
+  assertFalse(SetIteratorPrototype.hasOwnProperty('constructor'));
+  assertEquals(SetIteratorPrototype.__proto__, Object.prototype);
+
+  var propertyNames = Object.getOwnPropertyNames(SetIteratorPrototype);
+  assertArrayEquals(['next'], propertyNames);
+
+  assertEquals(new Set().values().__proto__, SetIteratorPrototype);
+  assertEquals(new Set().entries().__proto__, SetIteratorPrototype);
+
+  assertEquals("[object Set Iterator]",
+      Object.prototype.toString.call(iter));
+  assertEquals("Set Iterator", SetIteratorPrototype[Symbol.toStringTag]);
+  var desc = Object.getOwnPropertyDescriptor(
+      SetIteratorPrototype, Symbol.toStringTag);
+  assertTrue(desc.configurable);
+  assertFalse(desc.writable);
+  assertEquals("Set Iterator", desc.value);
+});
+
+
+test(function TestSetIteratorValues() {
+  var s = new Set;
+  s.add(1);
+  s.add(2);
+  s.add(3);
+  var iter = s.values();
+
+  assertEquals({value: 1, done: false}, iter.next());
+  assertEquals({value: 2, done: false}, iter.next());
+  assertEquals({value: 3, done: false}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+});
+
+test(function TestSetIteratorKeys() {
+  assertEquals(Set.prototype.keys, Set.prototype.values);
+});
+
+test(function TestSetIteratorEntries() {
+  var s = new Set;
+  s.add(1);
+  s.add(2);
+  s.add(3);
+  var iter = s.entries();
+
+  assertEquals({value: [1, 1], done: false}, iter.next());
+  assertEquals({value: [2, 2], done: false}, iter.next());
+  assertEquals({value: [3, 3], done: false}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+});
+
+
+test(function TestSetIteratorMutations() {
+  var s = new Set;
+  s.add(1);
+  var iter = s.values();
+  assertEquals({value: 1, done: false}, iter.next());
+  s.add(2);
+  s.add(3);
+  s.add(4);
+  s.add(5);
+  assertEquals({value: 2, done: false}, iter.next());
+  s.delete(3);
+  assertEquals({value: 4, done: false}, iter.next());
+  s.delete(5);
+  assertEquals({value: undefined, done: true}, iter.next());
+  s.add(4);
+  assertEquals({value: undefined, done: true}, iter.next());
+});
+
+
+test(function TestSetIteratorMutations2() {
+  var s = new Set;
+  s.add(1);
+  s.add(2);
+  var i = s.values();
+  assertEquals({value: 1, done: false}, i.next());
+  s.delete(2);
+  s.delete(1);
+  s.add(2);
+  assertEquals({value: 2, done: false}, i.next());
+  assertEquals({value: undefined, done: true}, i.next());
+});
+
+
+test(function TestSetIteratorMutations3() {
+  var s = new Set;
+  s.add(1);
+  s.add(2);
+  var i = s.values();
+  assertEquals({value: 1, done: false}, i.next());
+  s.delete(2);
+  s.delete(1);
+  for (var x = 2; x < 500; ++x) s.add(x);
+  for (var x = 2; x < 500; ++x) s.delete(x);
+  for (var x = 2; x < 1000; ++x) s.add(x);
+  assertEquals({value: 2, done: false}, i.next());
+  for (var x = 1001; x < 2000; ++x) s.add(x);
+  s.delete(3);
+  for (var x = 6; x < 2000; ++x) s.delete(x);
+  assertEquals({value: 4, done: false}, i.next());
+  s.delete(5);
+  assertEquals({value: undefined, done: true}, i.next());
+  s.add(4);
+  assertEquals({value: undefined, done: true}, i.next());
+});
+
+
+test(function TestSetInvalidReceiver() {
+  assertThrows(function() {
+    Set.prototype.values.call({});
+  }, TypeError);
+  assertThrows(function() {
+    Set.prototype.entries.call({});
+  }, TypeError);
+});
+
+
+test(function TestSetIteratorInvalidReceiver() {
+  var iter = new Set().values();
+  assertThrows(function() {
+    iter.next.call({});
+  });
+});
+
+
+test(function TestSetIteratorSymbol() {
+  assertEquals(Set.prototype[Symbol.iterator], Set.prototype.values);
+  assertTrue(Set.prototype.hasOwnProperty(Symbol.iterator));
+  assertFalse(Set.prototype.propertyIsEnumerable(Symbol.iterator));
+
+  var iter = new Set().values();
+  assertEquals(iter, iter[Symbol.iterator]());
+  assertEquals(iter[Symbol.iterator].name, '[Symbol.iterator]');
+});
+
+
+test(function TestMapIterator() {
+  var m = new Map;
+  var iter = m.values();
+  //assertEquals('Map Iterator', %_ClassOf(iter));
+
+  var MapIteratorPrototype = iter.__proto__;
+  assertFalse(MapIteratorPrototype.hasOwnProperty('constructor'));
+  assertEquals(MapIteratorPrototype.__proto__, Object.prototype);
+
+  var propertyNames = Object.getOwnPropertyNames(MapIteratorPrototype);
+  assertArrayEquals(['next'], propertyNames);
+
+  assertEquals(new Map().values().__proto__, MapIteratorPrototype);
+  assertEquals(new Map().keys().__proto__, MapIteratorPrototype);
+  assertEquals(new Map().entries().__proto__, MapIteratorPrototype);
+
+  assertEquals("[object Map Iterator]",
+      Object.prototype.toString.call(iter));
+  assertEquals("Map Iterator", MapIteratorPrototype[Symbol.toStringTag]);
+  var desc = Object.getOwnPropertyDescriptor(
+      MapIteratorPrototype, Symbol.toStringTag);
+  assertTrue(desc.configurable);
+  assertFalse(desc.writable);
+  assertEquals("Map Iterator", desc.value);
+});
+
+
+test(function TestMapIteratorValues() {
+  var m = new Map;
+  m.set(1, 11);
+  m.set(2, 22);
+  m.set(3, 33);
+  var iter = m.values();
+
+  assertEquals({value: 11, done: false}, iter.next());
+  assertEquals({value: 22, done: false}, iter.next());
+  assertEquals({value: 33, done: false}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+});
+
+
+test(function TestMapIteratorKeys() {
+  var m = new Map;
+  m.set(1, 11);
+  m.set(2, 22);
+  m.set(3, 33);
+  var iter = m.keys();
+
+  assertEquals({value: 1, done: false}, iter.next());
+  assertEquals({value: 2, done: false}, iter.next());
+  assertEquals({value: 3, done: false}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+});
+
+
+test(function TestMapIteratorEntries() {
+  var m = new Map;
+  m.set(1, 11);
+  m.set(2, 22);
+  m.set(3, 33);
+  var iter = m.entries();
+
+  assertEquals({value: [1, 11], done: false}, iter.next());
+  assertEquals({value: [2, 22], done: false}, iter.next());
+  assertEquals({value: [3, 33], done: false}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+  assertEquals({value: undefined, done: true}, iter.next());
+});
+
+
+test(function TestMapInvalidReceiver() {
+  assertThrows(function() {
+    Map.prototype.values.call({});
+  }, TypeError);
+  assertThrows(function() {
+    Map.prototype.keys.call({});
+  }, TypeError);
+  assertThrows(function() {
+    Map.prototype.entries.call({});
+  }, TypeError);
+});
+
+
+test(function TestMapIteratorInvalidReceiver() {
+  var iter = new Map().values();
+  assertThrows(function() {
+    iter.next.call({});
+  }, TypeError);
+});
+
+
+test(function TestMapIteratorSymbol() {
+  assertEquals(Map.prototype[Symbol.iterator], Map.prototype.entries);
+  assertTrue(Map.prototype.hasOwnProperty(Symbol.iterator));
+  assertFalse(Map.prototype.propertyIsEnumerable(Symbol.iterator));
+
+  var iter = new Map().values();
+  assertEquals(iter, iter[Symbol.iterator]());
+  assertEquals(iter[Symbol.iterator].name, '[Symbol.iterator]');
+});
+
+// These were missing from the V8 tests
+test(function TestMapFromMap() {
+  var m = new Map([['1', 1], ['2', 2]]);
+  assertEquals(m.get('1'), 1);
+  assertEquals(m.get('2'), 2);
+  var n = new Map(m);
+  assertEquals(n.get('1'), 1);
+  assertEquals(n.get('2'), 2);
+});
+
+test(function TestSetFromSet() {
+  var m = new Set([1, 2]);
+  assertTrue(m.has(1));
+  assertTrue(m.has(2));
+  var n = new Set(m);
+  assertTrue(n.has(1));
+  assertTrue(n.has(2));
+});
+
+"success";
diff --git a/testsrc/jstests/es6/collections.js b/testsrc/jstests/es6/collections.js
new file mode 100644
index 0000000..393d238
--- /dev/null
+++ b/testsrc/jstests/es6/collections.js
@@ -0,0 +1,1485 @@
+// Copyright 2012 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//     * Redistributions of source code must retain the above copyright
+//       notice, this list of conditions and the following disclaimer.
+//     * Redistributions in binary form must reproduce the above
+//       copyright notice, this list of conditions and the following
+//       disclaimer in the documentation and/or other materials provided
+//       with the distribution.
+//     * Neither the name of Google Inc. nor the names of its
+//       contributors may be used to endorse or promote products derived
+//       from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --expose-gc --allow-natives-syntax
+
+load("testsrc/assert.js");
+
+function assertSize(expected, collection) {
+  if (collection instanceof Map || collection instanceof Set) {
+    assertEquals(expected, collection.size);
+  }
+}
+
+
+// Test valid getter and setter calls on Sets and WeakSets
+function TestValidSetCalls(m) {
+  assertDoesNotThrow(function () { m.add(new Object) });
+  assertDoesNotThrow(function () { m.has(new Object) });
+  assertDoesNotThrow(function () { m.delete(new Object) });
+}
+TestValidSetCalls(new Set);
+//TestValidSetCalls(new WeakSet);
+
+
+// Test valid getter and setter calls on Maps and WeakMaps
+function TestValidMapCalls(m) {
+  assertDoesNotThrow(function () { m.get(new Object) });
+  assertDoesNotThrow(function () { m.set(new Object) });
+  assertDoesNotThrow(function () { m.has(new Object) });
+  assertDoesNotThrow(function () { m.delete(new Object) });
+  assertDoesNotThrow(function () { m.get(undefined) });
+  assertDoesNotThrow(function () { m.get(null) });
+  assertDoesNotThrow(function () { m.get(0) });
+  assertDoesNotThrow(function () { m.get('a-key') });
+  assertDoesNotThrow(function () { m.get(Symbol()) });
+  assertDoesNotThrow(function () { m.has(undefined) });
+  assertDoesNotThrow(function () { m.has(null) });
+  assertDoesNotThrow(function () { m.has(0) });
+  assertDoesNotThrow(function () { m.has('a-key') });
+  assertDoesNotThrow(function () { m.has(Symbol()) });
+  assertDoesNotThrow(function () { m.delete(undefined) });
+  assertDoesNotThrow(function () { m.delete(null) });
+  assertDoesNotThrow(function () { m.delete(0) });
+  assertDoesNotThrow(function () { m.delete('a-key') });
+  assertDoesNotThrow(function () { m.delete(Symbol()) });
+}
+TestValidMapCalls(new Map);
+//TestValidMapCalls(new WeakMap);
+
+
+// Test invalid getter and setter calls for WeakMap only
+function TestInvalidCalls(m) {
+  assertThrows(function () { m.set(undefined, 0) }, TypeError);
+  assertThrows(function () { m.set(null, 0) }, TypeError);
+  assertThrows(function () { m.set(0, 0) }, TypeError);
+  assertThrows(function () { m.set('a-key', 0) }, TypeError);
+  assertThrows(function () { m.set(Symbol(), 0) }, TypeError);
+}
+//TestInvalidCalls(new WeakMap);
+
+
+// Test expected behavior for Sets and WeakSets
+function TestSet(set, key) {
+  assertFalse(set.has(key));
+  assertFalse(set.delete(key));
+  /*if (typeof key === 'object' && !(set instanceof WeakSet)) {
+    assertSame(set, set.add(key));
+    assertTrue(set.has(key));
+    assertTrue(set.delete(key));
+  }*/
+  assertFalse(set.has(key));
+  assertFalse(set.delete(key));
+  assertFalse(set.has(key));
+}
+function TestSetBehavior(set) {
+  // Fill
+  for (var i = 0; i < 20; i++) {
+    TestSet(set, new Object);
+    TestSet(set, i);
+    TestSet(set, i / 100);
+    TestSet(set, 'key-' + i);
+    TestSet(set, Symbol(i));
+  }
+
+  var keys = [
+    -0, +0, 1, 1/3, 10, +Infinity, -Infinity, NaN, true, false, null, undefined,
+    'x', Symbol(), {}, function(){}
+  ];
+  for (var i = 0; i < keys.length; i++) {
+    TestSet(set, keys[i]);
+  }
+}
+TestSetBehavior(new Set);
+//TestSetBehavior(new WeakSet);
+
+
+// Test expected mapping behavior for Maps and WeakMaps
+function TestMapping(map, key, value) {
+  assertFalse(map.has(key));
+  assertSame(undefined, map.get(key));
+  assertFalse(map.delete(key));
+  /*if (typeof key === 'object' && !(map instanceof WeakMap)) {
+    assertSame(map, map.set(key, value));
+    assertSame(value, map.get(key));
+    assertTrue(map.has(key));
+    assertTrue(map.delete(key));
+  }*/
+  assertFalse(map.has(key));
+  assertSame(undefined, map.get(key));
+  assertFalse(map.delete(key));
+  assertFalse(map.has(key));
+  assertSame(undefined, map.get(key));
+}
+function TestMapBehavior(m) {
+  // Fill
+  TestMapping(m, new Object, 23);
+  TestMapping(m, new Object, 'the-value');
+  TestMapping(m, new Object, new Object);
+  for (var i = 0; i < 20; i++) {
+    TestMapping(m, i, new Object);
+    TestMapping(m, i / 10, new Object);
+    TestMapping(m, 'key-' + i, new Object);
+    TestMapping(m, Symbol(i), new Object);
+  }
+
+  var keys = [
+    -0, +0, 1, 1/3, 10, +Infinity, -Infinity, NaN, true, false, null, undefined,
+    'x', Symbol(), {}, function(){}
+  ];
+  for (var i = 0; i < keys.length; i++) {
+    TestMapping(m, keys[i], 23);
+    TestMapping(m, keys[i], 'the-value');
+    TestMapping(m, keys[i], new Object);
+  }
+}
+TestMapBehavior(new Map);
+//TestMapBehavior(new WeakMap);
+
+
+// Test expected querying behavior of Maps and WeakMaps
+function TestQuery(m) {
+  var key = new Object;
+  var values = [ 'x', 0, +Infinity, -Infinity, true, false, null, undefined ];
+  for (var i = 0; i < values.length; i++) {
+    TestMapping(m, key, values[i]);
+  }
+}
+TestQuery(new Map);
+//TestQuery(new WeakMap);
+
+
+// Test expected deletion behavior of Maps and WeakMaps
+function TestDelete(m) {
+  var key = new Object;
+  TestMapping(m, key, 'to-be-deleted');
+  assertFalse(m.delete(key));
+  assertFalse(m.delete(new Object));
+  assertSame(m.get(key), undefined);
+}
+TestDelete(new Map);
+//TestDelete(new WeakMap);
+
+
+// Test GC of Maps and WeakMaps with entry
+function TestGC1(m) {
+  var key = new Object;
+  m.set(key, 'not-collected');
+  gc();
+  assertSame('not-collected', m.get(key));
+}
+TestGC1(new Map);
+//TestGC1(new WeakMap);
+
+
+// Test GC of Maps and WeakMaps with chained entries
+function TestGC2(m) {
+  var head = new Object;
+  for (key = head, i = 0; i < 10; i++, key = m.get(key)) {
+    m.set(key, new Object);
+  }
+  gc();
+  var count = 0;
+  for (key = head; key != undefined; key = m.get(key)) {
+    count++;
+  }
+  assertEquals(11, count);
+}
+TestGC2(new Map);
+//TestGC2(new WeakMap);
+
+
+// Test property attribute [[Enumerable]]
+function TestEnumerable(func) {
+  function props(x) {
+    var array = [];
+    for (var p in x) array.push(p);
+    return array.sort();
+  }
+  assertArrayEquals([], props(func));
+  assertArrayEquals([], props(func.prototype));
+  assertArrayEquals([], props(new func()));
+}
+TestEnumerable(Set);
+TestEnumerable(Map);
+//TestEnumerable(WeakMap);
+//TestEnumerable(WeakSet);
+
+
+// Test arbitrary properties on Maps and WeakMaps
+function TestArbitrary(m) {
+  function TestProperty(map, property, value) {
+    map[property] = value;
+    assertEquals(value, map[property]);
+  }
+  for (var i = 0; i < 20; i++) {
+    TestProperty(m, i, 'val' + i);
+    TestProperty(m, 'foo' + i, 'bar' + i);
+  }
+  TestMapping(m, new Object, 'foobar');
+}
+TestArbitrary(new Map);
+//TestArbitrary(new WeakMap);
+
+
+// Test direct constructor call
+assertThrows(function() { Set(); }, TypeError);
+assertThrows(function() { Map(); }, TypeError);
+//assertThrows(function() { WeakMap(); }, TypeError);
+//assertThrows(function() { WeakSet(); }, TypeError);
+
+
+// Test whether NaN values as keys are treated correctly.
+var s = new Set;
+assertFalse(s.has(NaN));
+assertFalse(s.has(NaN + 1));
+assertFalse(s.has(23));
+s.add(NaN);
+assertTrue(s.has(NaN));
+assertTrue(s.has(NaN + 1));
+assertFalse(s.has(23));
+var m = new Map;
+assertFalse(m.has(NaN));
+assertFalse(m.has(NaN + 1));
+assertFalse(m.has(23));
+m.set(NaN, 'a-value');
+assertTrue(m.has(NaN));
+assertTrue(m.has(NaN + 1));
+assertFalse(m.has(23));
+
+
+// Test some common JavaScript idioms for Sets
+var s = new Set;
+assertTrue(s instanceof Set);
+assertTrue(Set.prototype.add instanceof Function)
+assertTrue(Set.prototype.has instanceof Function)
+assertTrue(Set.prototype.delete instanceof Function)
+assertTrue(Set.prototype.clear instanceof Function)
+
+
+// Test some common JavaScript idioms for Maps
+var m = new Map;
+assertTrue(m instanceof Map);
+assertTrue(Map.prototype.set instanceof Function)
+assertTrue(Map.prototype.get instanceof Function)
+assertTrue(Map.prototype.has instanceof Function)
+assertTrue(Map.prototype.delete instanceof Function)
+assertTrue(Map.prototype.clear instanceof Function)
+
+
+/*
+// Test some common JavaScript idioms for WeakMaps
+var m = new WeakMap;
+assertTrue(m instanceof WeakMap);
+assertTrue(WeakMap.prototype.set instanceof Function)
+assertTrue(WeakMap.prototype.get instanceof Function)
+assertTrue(WeakMap.prototype.has instanceof Function)
+assertTrue(WeakMap.prototype.delete instanceof Function)
+
+
+// Test some common JavaScript idioms for WeakSets
+var s = new WeakSet;
+assertTrue(s instanceof WeakSet);
+assertTrue(WeakSet.prototype.add instanceof Function)
+assertTrue(WeakSet.prototype.has instanceof Function)
+assertTrue(WeakSet.prototype.delete instanceof Function)
+*/
+
+
+// Test name of constructor.
+assertEquals("Set", Set.name);
+assertEquals("Map", Map.name);
+//assertEquals("WeakMap", WeakMap.name);
+//assertEquals("WeakSet", WeakSet.name);
+
+
+// Test prototype property of Set, Map, WeakMap and WeakSet.
+function TestPrototype(C) {
+  assertTrue(C.prototype instanceof Object);
+  assertEquals({
+    value: C.prototype,
+    writable: false,
+    enumerable: false,
+    configurable: false
+  }, Object.getOwnPropertyDescriptor(C, "prototype"));
+}
+TestPrototype(Set);
+TestPrototype(Map);
+//TestPrototype(WeakMap);
+//TestPrototype(WeakSet);
+
+
+// Test constructor property of the Set, Map, WeakMap and WeakSet prototype.
+function TestConstructor(C) {
+  assertFalse(C === Object.prototype.constructor);
+  assertSame(C, C.prototype.constructor);
+  assertSame(C, (new C).__proto__.constructor);
+  assertEquals(0, C.length);
+}
+TestConstructor(Set);
+TestConstructor(Map);
+//TestConstructor(WeakMap);
+//TestConstructor(WeakSet);
+
+
+// Test the Set, Map, WeakMap and WeakSet global properties themselves.
+// TODO This doesn't work due to lack of "this" in the test environment.
+/*
+function TestDescriptor(global, C) {
+  assertEquals({
+    value: C,
+    writable: true,
+    enumerable: false,
+    configurable: true
+  }, Object.getOwnPropertyDescriptor(global, C.name));
+}
+TestDescriptor(this, Set);
+TestDescriptor(this, Map);
+//TestDescriptor(this, WeakMap);
+//TestDescriptor(this, WeakSet);
+*/
+
+// Regression test for WeakMap prototype.
+//assertTrue(WeakMap.prototype.constructor === WeakMap)
+//assertTrue(Object.getPrototypeOf(WeakMap.prototype) === Object.prototype)
+
+
+// Regression test for issue 1617: The prototype of the WeakMap constructor
+// needs to be unique (i.e. different from the one of the Object constructor).
+//assertFalse(WeakMap.prototype === Object.prototype);
+var o = Object.create({});
+assertFalse("get" in o);
+assertFalse("set" in o);
+assertEquals(undefined, o.get);
+assertEquals(undefined, o.set);
+var o = Object.create({}, { myValue: {
+  value: 10,
+  enumerable: false,
+  configurable: true,
+  writable: true
+}});
+assertEquals(10, o.myValue);
+
+
+// Regression test for issue 1884: Invoking any of the methods for Harmony
+// maps, sets, or weak maps, with a wrong type of receiver should be throwing
+// a proper TypeError.
+/*
+var alwaysBogus = [ undefined, null, true, "x", 23, {} ];
+var bogusReceiversTestSet = [
+  { proto: Set.prototype,
+    funcs: [ 'add', 'has', 'delete' ],
+    receivers: alwaysBogus.concat([ new Map, new WeakMap, new WeakSet ]),
+  },
+  { proto: Map.prototype,
+    funcs: [ 'get', 'set', 'has', 'delete' ],
+    receivers: alwaysBogus.concat([ new Set, new WeakMap, new WeakSet ]),
+  },
+  { proto: WeakMap.prototype,
+    funcs: [ 'get', 'set', 'has', 'delete' ],
+    receivers: alwaysBogus.concat([ new Set, new Map, new WeakSet ]),
+  },
+  { proto: WeakSet.prototype,
+    funcs: [ 'add', 'has', 'delete' ],
+    receivers: alwaysBogus.concat([ new Set, new Map, new WeakMap ]),
+  },
+];
+function TestBogusReceivers(testSet) {
+  for (var i = 0; i < testSet.length; i++) {
+    var proto = testSet[i].proto;
+    var funcs = testSet[i].funcs;
+    var receivers = testSet[i].receivers;
+    for (var j = 0; j < funcs.length; j++) {
+      var func = proto[funcs[j]];
+      for (var k = 0; k < receivers.length; k++) {
+        assertThrows(function () { func.call(receivers[k], {}) }, TypeError);
+      }
+    }
+  }
+}
+TestBogusReceivers(bogusReceiversTestSet);
+*/
+
+// Stress Test
+// There is a proposed stress-test available at the es-discuss mailing list
+// which cannot be reasonably automated.  Check it out by hand if you like:
+// https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html
+
+
+// Set and Map size getters
+var setSizeDescriptor = Object.getOwnPropertyDescriptor(Set.prototype, 'size');
+assertEquals(undefined, setSizeDescriptor.value);
+assertEquals(undefined, setSizeDescriptor.set);
+assertTrue(setSizeDescriptor.get instanceof Function);
+assertEquals(undefined, setSizeDescriptor.get.prototype);
+assertFalse(setSizeDescriptor.enumerable);
+assertTrue(setSizeDescriptor.configurable);
+assertEquals('get size', setSizeDescriptor.get.name);
+
+var s = new Set();
+assertFalse(s.hasOwnProperty('size'));
+for (var i = 0; i < 10; i++) {
+  assertEquals(i, s.size);
+  s.add(i);
+}
+for (var i = 9; i >= 0; i--) {
+  s.delete(i);
+  assertEquals(i, s.size);
+}
+
+var mapSizeDescriptor = Object.getOwnPropertyDescriptor(Map.prototype, 'size');
+assertEquals(undefined, mapSizeDescriptor.value);
+assertEquals(undefined, mapSizeDescriptor.set);
+assertTrue(mapSizeDescriptor.get instanceof Function);
+assertEquals(undefined, mapSizeDescriptor.get.prototype);
+assertFalse(mapSizeDescriptor.enumerable);
+assertTrue(mapSizeDescriptor.configurable);
+assertEquals('get size', mapSizeDescriptor.get.name);
+
+var m = new Map();
+assertFalse(m.hasOwnProperty('size'));
+for (var i = 0; i < 10; i++) {
+  assertEquals(i, m.size);
+  m.set(i, i);
+}
+for (var i = 9; i >= 0; i--) {
+  m.delete(i);
+  assertEquals(i, m.size);
+}
+
+
+// Test Set clear
+(function() {
+  var s = new Set();
+  s.add(42);
+  assertTrue(s.has(42));
+  assertEquals(1, s.size);
+  s.clear();
+  assertFalse(s.has(42));
+  assertEquals(0, s.size);
+})();
+
+
+// Test Map clear
+(function() {
+  var m = new Map();
+  m.set(42, true);
+  assertTrue(m.has(42));
+  assertEquals(1, m.size);
+  m.clear();
+  assertFalse(m.has(42));
+  assertEquals(0, m.size);
+})();
+
+
+(function TestMinusZeroSet() {
+  var s = new Set();
+  s.add(-0);
+  // TODO not quite the same test as V8 because of "assertSame" I think
+  assertTrue(0 === s.values().next().value);
+  s.add(0);
+  assertEquals(1, s.size);
+  assertTrue(s.has(0));
+  assertTrue(s.has(-0));
+})();
+
+
+(function TestMinusZeroMap() {
+  var m = new Map();
+  m.set(-0, 'minus');
+  // TODO not quite the same test as V8 because of "assertSame" I think
+  assertTrue(0 === m.keys().next().value);
+  m.set(0, 'plus');
+  assertEquals(1, m.size);
+  assertTrue(m.has(0));
+  assertTrue(m.has(-0));
+  assertEquals('plus', m.get(0));
+  assertEquals('plus', m.get(-0));
+})();
+
+
+(function TestSetForEachInvalidTypes() {
+  assertThrows(function() {
+    Set.prototype.set.forEach.call({});
+  }, TypeError);
+
+  var set = new Set();
+  assertThrows(function() {
+    set.forEach({});
+  }, TypeError);
+})();
+
+
+(function TestSetForEach() {
+  var set = new Set();
+  set.add('a');
+  set.add('b');
+  set.add('c');
+
+  var buffer = '';
+  var receiver = {};
+  set.forEach(function(v, k, s) {
+    assertSame(v, k);
+    assertSame(set, s);
+    assertSame(this, receiver);
+    buffer += v;
+    if (v === 'a') {
+      set.delete('b');
+      set.add('d');
+      set.add('e');
+      set.add('f');
+    } else if (v === 'c') {
+      set.add('b');
+      set.delete('e');
+    }
+  }, receiver);
+
+  assertEquals('acdfb', buffer);
+})();
+
+
+(function TestSetForEachAddAtEnd() {
+  var set = new Set();
+  set.add('a');
+  set.add('b');
+
+  var buffer = '';
+  set.forEach(function(v) {
+    buffer += v;
+    if (v === 'b') {
+      set.add('c');
+    }
+  });
+
+  assertEquals('abc', buffer);
+})();
+
+
+(function TestSetForEachDeleteNext() {
+  var set = new Set();
+  set.add('a');
+  set.add('b');
+  set.add('c');
+
+  var buffer = '';
+  set.forEach(function(v) {
+    buffer += v;
+    if (v === 'b') {
+      set.delete('c');
+    }
+  });
+
+  assertEquals('ab', buffer);
+})();
+
+
+(function TestSetForEachDeleteVisitedAndAddAgain() {
+  var set = new Set();
+  set.add('a');
+  set.add('b');
+  set.add('c');
+
+  var buffer = '';
+  set.forEach(function(v) {
+    buffer += v;
+    if (v === 'b') {
+      set.delete('a');
+    } else if (v === 'c') {
+      set.add('a');
+    }
+  });
+
+  assertEquals('abca', buffer);
+})();
+
+
+(function TestSetForEachClear() {
+  var set = new Set();
+  set.add('a');
+  set.add('b');
+  set.add('c');
+
+  var buffer = '';
+  set.forEach(function(v) {
+    buffer += v;
+    if (v === 'a') {
+      set.clear();
+      set.add('d');
+      set.add('e');
+    }
+  });
+
+  assertEquals('ade', buffer);
+})();
+
+
+(function TestSetForEachNested() {
+  var set = new Set();
+  set.add('a');
+  set.add('b');
+  set.add('c');
+
+  var buffer = '';
+  set.forEach(function(v) {
+    buffer += v;
+    set.forEach(function(v) {
+      buffer += v;
+      if (v === 'a') {
+        set.delete('b');
+      }
+    });
+  });
+
+  assertEquals('aaccac', buffer);
+})();
+
+
+(function TestSetForEachEarlyExit() {
+  var set = new Set();
+  set.add('a');
+  set.add('b');
+  set.add('c');
+
+  var buffer = '';
+  var ex = {};
+  try {
+    set.forEach(function(v) {
+      buffer += v;
+      throw ex;
+    });
+  } catch (e) {
+    assertEquals(ex, e);
+  }
+  assertEquals('a', buffer);
+})();
+
+
+(function TestSetForEachGC() {
+  var set = new Set();
+  for (var i = 0; i < 100; i++) {
+    set.add(i);
+  }
+
+  var accumulated = 0;
+  set.forEach(function(v) {
+    accumulated += v;
+    if (v % 10 === 0) {
+      gc();
+    }
+  });
+  assertEquals(4950, accumulated);
+})();
+
+
+(function TestSetForEachReceiverAsObject() {
+  var set = new Set(["1", "2"]);
+
+  // Create a new object in each function call when receiver is a
+  // primitive value. See ECMA-262, Annex C.
+  var a = [];
+  set.forEach(function() { a.push(this) }, "");
+  assertTrue(a[0] !== a[1]);
+
+  // Do not create a new object otherwise.
+  a = [];
+  set.forEach(function() { a.push(this); }, {});
+  assertEquals(a[0], a[1]);
+})();
+
+/* TODO missing some strict mode capabilities in Rhino
+(function TestSetForEachReceiverAsObjectInStrictMode() {
+  var set = new Set(["1", "2"]);
+
+  // In strict mode primitive values should not be coerced to an object.
+  var a = [];
+  set.forEach(function() { 'use strict'; a.push(this); }, "");
+  assertTrue(a[0] === "" && a[0] === a[1]);
+})();
+*/
+
+(function TestMapForEachInvalidTypes() {
+  assertThrows(function() {
+    Map.prototype.map.forEach.call({});
+  }, TypeError);
+
+  var map = new Map();
+  assertThrows(function() {
+    map.forEach({});
+  }, TypeError);
+})();
+
+
+(function TestMapForEach() {
+  var map = new Map();
+  map.set(0, 'a');
+  map.set(1, 'b');
+  map.set(2, 'c');
+
+  var buffer = [];
+  var receiver = {};
+  map.forEach(function(v, k, m) {
+    assertEquals(map, m);
+    assertEquals(this, receiver);
+    buffer.push(k, v);
+    if (k === 0) {
+      map.delete(1);
+      map.set(3, 'd');
+      map.set(4, 'e');
+      map.set(5, 'f');
+    } else if (k === 2) {
+      map.set(1, 'B');
+      map.delete(4);
+    }
+  }, receiver);
+
+  assertArrayEquals([0, 'a', 2, 'c', 3, 'd', 5, 'f', 1, 'B'], buffer);
+})();
+
+
+(function TestMapForEachAddAtEnd() {
+  var map = new Map();
+  map.set(0, 'a');
+  map.set(1, 'b');
+
+  var buffer = [];
+  map.forEach(function(v, k) {
+    buffer.push(k, v);
+    if (k === 1) {
+      map.set(2, 'c');
+    }
+  });
+
+  assertArrayEquals([0, 'a', 1, 'b', 2, 'c'], buffer);
+})();
+
+
+(function TestMapForEachDeleteNext() {
+  var map = new Map();
+  map.set(0, 'a');
+  map.set(1, 'b');
+  map.set(2, 'c');
+
+  var buffer = [];
+  map.forEach(function(v, k) {
+    buffer.push(k, v);
+    if (k === 1) {
+      map.delete(2);
+    }
+  });
+
+  assertArrayEquals([0, 'a', 1, 'b'], buffer);
+})();
+
+
+(function TestSetForEachDeleteVisitedAndAddAgain() {
+  var map = new Map();
+  map.set(0, 'a');
+  map.set(1, 'b');
+  map.set(2, 'c');
+
+  var buffer = [];
+  map.forEach(function(v, k) {
+    buffer.push(k, v);
+    if (k === 1) {
+      map.delete(0);
+    } else if (k === 2) {
+      map.set(0, 'a');
+    }
+  });
+
+  assertArrayEquals([0, 'a', 1, 'b', 2, 'c', 0, 'a'], buffer);
+})();
+
+
+(function TestMapForEachClear() {
+  var map = new Map();
+  map.set(0, 'a');
+  map.set(1, 'b');
+  map.set(2, 'c');
+
+  var buffer = [];
+  map.forEach(function(v, k) {
+    buffer.push(k, v);
+    if (k === 0) {
+      map.clear();
+      map.set(3, 'd');
+      map.set(4, 'e');
+    }
+  });
+
+  assertArrayEquals([0, 'a', 3, 'd', 4, 'e'], buffer);
+})();
+
+
+(function TestMapForEachNested() {
+  var map = new Map();
+  map.set(0, 'a');
+  map.set(1, 'b');
+  map.set(2, 'c');
+
+  var buffer = [];
+  map.forEach(function(v, k) {
+    buffer.push(k, v);
+    map.forEach(function(v, k) {
+      buffer.push(k, v);
+      if (k === 0) {
+        map.delete(1);
+      }
+    });
+  });
+
+  assertArrayEquals([0, 'a', 0, 'a', 2, 'c', 2, 'c', 0, 'a', 2, 'c'], buffer);
+})();
+
+
+(function TestMapForEachEarlyExit() {
+  var map = new Map();
+  map.set(0, 'a');
+  map.set(1, 'b');
+  map.set(2, 'c');
+
+  var buffer = [];
+  var ex = {};
+  try {
+    map.forEach(function(v, k) {
+      buffer.push(k, v);
+      throw ex;
+    });
+  } catch (e) {
+    assertEquals(ex, e);
+  }
+  assertArrayEquals([0, 'a'], buffer);
+})();
+
+
+(function TestMapForEachGC() {
+  var map = new Map();
+  for (var i = 0; i < 100; i++) {
+    map.set(i, i);
+  }
+
+  var accumulated = 0;
+  map.forEach(function(v) {
+    accumulated += v;
+    if (v % 10 === 0) {
+      gc();
+    }
+  });
+  assertEquals(4950, accumulated);
+})();
+
+
+(function TestMapForEachAllRemovedTransition() {
+  var map = new Map;
+  map.set(0, 0);
+
+  var buffer = [];
+  map.forEach(function(v) {
+    buffer.push(v);
+    if (v === 0) {
+      for (var i = 1; i < 4; i++) {
+        map.set(i, i);
+      }
+    }
+
+    if (v === 3) {
+      for (var i = 0; i < 4; i++) {
+        map.delete(i);
+      }
+      for (var i = 4; i < 8; i++) {
+        map.set(i, i);
+      }
+    }
+  });
+
+  assertArrayEquals([0, 1, 2, 3, 4, 5, 6, 7], buffer);
+})();
+
+
+(function TestMapForEachClearTransition() {
+  var map = new Map;
+  map.set(0, 0);
+
+  var i = 0;
+  var buffer = [];
+  map.forEach(function(v) {
+    buffer.push(v);
+    if (++i < 5) {
+      for (var j = 0; j < 5; j++) {
+        map.clear();
+        map.set(i, i);
+      }
+    }
+  });
+
+  assertArrayEquals([0, 1, 2, 3, 4], buffer);
+})();
+
+
+(function TestMapForEachNestedNonTrivialTransition() {
+  var map = new Map;
+  map.set(0, 0);
+  map.set(1, 1);
+  map.set(2, 2);
+  map.set(3, 3);
+  map.delete(0);
+
+  var i = 0;
+  var buffer = [];
+  map.forEach(function(v) {
+    if (++i > 10) return;
+
+    buffer.push(v);
+
+    if (v == 3) {
+      map.delete(1);
+      for (var j = 4; j < 10; j++) {
+        map.set(j, j);
+      }
+      for (var j = 4; j < 10; j += 2) {
+        map.delete(j);
+      }
+      map.delete(2);
+
+      for (var j = 10; j < 20; j++) {
+        map.set(j, j);
+      }
+      for (var j = 10; j < 20; j += 2) {
+        map.delete(j);
+      }
+
+      map.delete(3);
+    }
+  });
+
+  assertArrayEquals([1, 2, 3, 5, 7, 9, 11, 13, 15, 17], buffer);
+})();
+
+
+(function TestMapForEachAllRemovedTransitionNoClear() {
+  var map = new Map;
+  map.set(0, 0);
+
+  var buffer = [];
+  map.forEach(function(v) {
+    buffer.push(v);
+    if (v === 0) {
+      for (var i = 1; i < 8; i++) {
+        map.set(i, i);
+      }
+    }
+
+    if (v === 4) {
+      for (var i = 0; i < 8; i++) {
+        map.delete(i);
+      }
+    }
+  });
+
+  assertArrayEquals([0, 1, 2, 3, 4], buffer);
+})();
+
+
+(function TestMapForEachNoMoreElementsAfterTransition() {
+  var map = new Map;
+  map.set(0, 0);
+
+  var buffer = [];
+  map.forEach(function(v) {
+    buffer.push(v);
+    if (v === 0) {
+      for (var i = 1; i < 16; i++) {
+        map.set(i, i);
+      }
+    }
+
+    if (v === 4) {
+      for (var i = 5; i < 16; i++) {
+        map.delete(i);
+      }
+    }
+  });
+
+  assertArrayEquals([0, 1, 2, 3, 4], buffer);
+})();
+
+
+(function TestMapForEachReceiverAsObject() {
+  var map = new Map();
+  map.set("key1", "value1");
+  map.set("key2", "value2");
+
+  // Create a new object in each function call when receiver is a
+  // primitive value. See ECMA-262, Annex C.
+  var a = [];
+  map.forEach(function() { a.push(this) }, "");
+  assertTrue(a[0] !== a[1]);
+
+  // Do not create a new object otherwise.
+  a = [];
+  map.forEach(function() { a.push(this); }, {});
+  assertEquals(a[0], a[1]);
+})();
+
+
+/* TODO strict mode
+(function TestMapForEachReceiverAsObjectInStrictMode() {
+  var map = new Map();
+  map.set("key1", "value1");
+  map.set("key2", "value2");
+
+  // In strict mode primitive values should not be coerced to an object.
+  var a = [];
+  map.forEach(function() { 'use strict'; a.push(this); }, "");
+  assertTrue(a[0] === "" && a[0] === a[1]);
+})();
+*/
+
+// Allows testing iterator-based constructors easily.
+var oneAndTwo = new Map();
+var k0 = {key: 0};
+var k1 = {key: 1};
+var k2 = {key: 2};
+oneAndTwo.set(k1, 1);
+oneAndTwo.set(k2, 2);
+
+
+function TestSetConstructor(ctor) {
+  var s = new ctor(null);
+  assertSize(0, s);
+
+  s = new ctor(undefined);
+  assertSize(0, s);
+
+  // No @@iterator
+  assertThrows(function() {
+    new ctor({});
+  }, TypeError);
+  assertThrows(function() {
+    new ctor(true);
+  }, TypeError);
+
+  // @@iterator not callable
+  assertThrows(function() {
+    var object = {};
+    object[Symbol.iterator] = 42;
+    new ctor(object);
+  }, TypeError);
+
+  // @@iterator result not object
+  assertThrows(function() {
+    var object = {};
+    object[Symbol.iterator] = function() {
+      return 42;
+    };
+    new ctor(object);
+  }, TypeError);
+
+  var s2 = new Set();
+  s2.add(k0);
+  s2.add(k1);
+  s2.add(k2);
+  s = new ctor(s2.values());
+  assertSize(3, s);
+  assertTrue(s.has(k0));
+  assertTrue(s.has(k1));
+  assertTrue(s.has(k2));
+}
+TestSetConstructor(Set);
+//TestSetConstructor(WeakSet);
+
+
+function TestSetConstructorAddNotCallable(ctor) {
+  var originalPrototypeAdd = ctor.prototype.add;
+  assertThrows(function() {
+    ctor.prototype.add = 42;
+    new ctor(oneAndTwo.values());
+  }, TypeError);
+  ctor.prototype.add = originalPrototypeAdd;
+}
+TestSetConstructorAddNotCallable(Set);
+//TestSetConstructorAddNotCallable(WeakSet);
+
+function TestSetConstructorGetAddOnce(ctor) {
+  var originalPrototypeAdd = ctor.prototype.add;
+  var getAddCount = 0;
+  Object.defineProperty(ctor.prototype, 'add', {
+    get: function() {
+      getAddCount++;
+      return function() {};
+    },
+    // Rhino: had to add this
+    configurable: true
+  });
+  var s = new ctor(oneAndTwo.values());
+  assertEquals(1, getAddCount);
+  assertSize(0, s);
+  Object.defineProperty(ctor.prototype, 'add', {
+    value: originalPrototypeAdd,
+    writable: true
+  });
+}
+TestSetConstructorGetAddOnce(Set);
+//TestSetConstructorGetAddOnce(WeakSet);
+
+
+function TestSetConstructorAddReplaced(ctor) {
+  var originalPrototypeAdd = ctor.prototype.add;
+  var addCount = 0;
+  ctor.prototype.add = function(value) {
+    addCount++;
+    originalPrototypeAdd.call(this, value);
+    ctor.prototype.add = null;
+  };
+  var s = new ctor(oneAndTwo.keys());
+  assertEquals(2, addCount);
+  assertSize(2, s);
+  ctor.prototype.add = originalPrototypeAdd;
+}
+TestSetConstructorAddReplaced(Set);
+//TestSetConstructorAddReplaced(WeakSet);
+
+
+function TestSetConstructorOrderOfDoneValue(ctor) {
+  var valueCount = 0, doneCount = 0;
+  var iterator = {
+    next: function() {
+      return {
+        get value() {
+          valueCount++;
+        },
+        get done() {
+          doneCount++;
+          throw new Error();
+        }
+      };
+    }
+  };
+  iterator[Symbol.iterator] = function() {
+    return this;
+  };
+  assertThrows(function() {
+    new ctor(iterator);
+  });
+  assertEquals(1, doneCount);
+  assertEquals(0, valueCount);
+}
+TestSetConstructorOrderOfDoneValue(Set);
+//TestSetConstructorOrderOfDoneValue(WeakSet);
+
+function TestSetConstructorNextNotAnObject(ctor) {
+  var iterator = {
+    next: function() {
+      return 'abc';
+    }
+  };
+  iterator[Symbol.iterator] = function() {
+    return this;
+  };
+  assertThrows(function() {
+    new ctor(iterator);
+  }, TypeError);
+}
+TestSetConstructorNextNotAnObject(Set);
+//TestSetConstructorNextNotAnObject(WeakSet);
+
+/*
+(function TestWeakSetConstructorNonObjectKeys() {
+  assertThrows(function() {
+    new WeakSet([1]);
+  }, TypeError);
+})();
+*/
+
+/*
+ * TODO missing stuff around strict mode
+function TestSetConstructorIterableValue(ctor) {
+  'use strict';
+  // Strict mode is required to prevent implicit wrapping in the getter.
+  Object.defineProperty(Number.prototype, Symbol.iterator, {
+    get: function() {
+      assertEquals('number', typeof this);
+      return function() {
+        assertEquals('number', typeof this);
+        return oneAndTwo.keys();
+      };
+    },
+    configurable: true
+  });
+
+  var set = new ctor(42);
+  assertSize(2, set);
+  assertTrue(set.has(k1));
+  assertTrue(set.has(k2));
+
+  delete Number.prototype[Symbol.iterator];
+}
+TestSetConstructorIterableValue(Set);
+//TestSetConstructorIterableValue(WeakSet);
+*/
+
+(function TestSetConstructorStringValue() {
+  var s = new Set('abc');
+  assertSize(3, s);
+  assertTrue(s.has('a'));
+  assertTrue(s.has('b'));
+  assertTrue(s.has('c'));
+})();
+
+
+function TestMapConstructor(ctor) {
+  var m = new ctor(null);
+  assertSize(0, m);
+
+  m = new ctor(undefined);
+  assertSize(0, m);
+
+  // No @@iterator
+  assertThrows(function() {
+    new ctor({});
+  }, TypeError);
+  assertThrows(function() {
+    new ctor(true);
+  }, TypeError);
+
+  // @@iterator not callable
+  assertThrows(function() {
+    var object = {};
+    object[Symbol.iterator] = 42;
+    new ctor(object);
+  }, TypeError);
+
+  // @@iterator result not object
+  assertThrows(function() {
+    var object = {};
+    object[Symbol.iterator] = function() {
+      return 42;
+    };
+    new ctor(object);
+  }, TypeError);
+
+  var m2 = new Map();
+  m2.set(k0, 'a');
+  m2.set(k1, 'b');
+  m2.set(k2, 'c');
+  m = new ctor(m2.entries());
+  assertSize(3, m);
+  assertEquals('a', m.get(k0));
+  assertEquals('b', m.get(k1));
+  assertEquals('c', m.get(k2));
+}
+TestMapConstructor(Map);
+//TestMapConstructor(WeakMap);
+
+
+function TestMapConstructorSetNotCallable(ctor) {
+  var originalPrototypeSet = ctor.prototype.set;
+  assertThrows(function() {
+    ctor.prototype.set = 42;
+    new ctor(oneAndTwo.entries());
+  }, TypeError);
+  ctor.prototype.set = originalPrototypeSet;
+}
+TestMapConstructorSetNotCallable(Map);
+//TestMapConstructorSetNotCallable(WeakMap);
+
+function TestMapConstructorGetAddOnce(ctor) {
+  var originalPrototypeSet = ctor.prototype.set;
+  var getSetCount = 0;
+  Object.defineProperty(ctor.prototype, 'set', {
+    get: function() {
+      getSetCount++;
+      return function() {};
+    },
+    // Rhino: Had to add this
+    configurable: true
+  });
+  var m = new ctor(oneAndTwo.entries());
+  assertEquals(1, getSetCount);
+  assertSize(0, m);
+  Object.defineProperty(ctor.prototype, 'set', {
+    value: originalPrototypeSet,
+    writable: true
+  });
+}
+TestMapConstructorGetAddOnce(Map);
+//TestMapConstructorGetAddOnce(WeakMap);
+
+function TestMapConstructorSetReplaced(ctor) {
+  var originalPrototypeSet = ctor.prototype.set;
+  var setCount = 0;
+  ctor.prototype.set = function(key, value) {
+    setCount++;
+    originalPrototypeSet.call(this, key, value);
+    ctor.prototype.set = null;
+  };
+  var m = new ctor(oneAndTwo.entries());
+  assertEquals(2, setCount);
+  assertSize(2, m);
+  ctor.prototype.set = originalPrototypeSet;
+}
+TestMapConstructorSetReplaced(Map);
+//TestMapConstructorSetReplaced(WeakMap);
+
+
+function TestMapConstructorOrderOfDoneValue(ctor) {
+  var valueCount = 0, doneCount = 0;
+  function FakeError() {}
+  var iterator = {
+    next: function() {
+      return {
+        get value() {
+          valueCount++;
+        },
+        get done() {
+          doneCount++;
+          throw new FakeError();
+        }
+      };
+    }
+  };
+  iterator[Symbol.iterator] = function() {
+    return this;
+  };
+  assertThrows(function() {
+    new ctor(iterator);
+  }, FakeError);
+  assertEquals(1, doneCount);
+  assertEquals(0, valueCount);
+}
+TestMapConstructorOrderOfDoneValue(Map);
+//TestMapConstructorOrderOfDoneValue(WeakMap);
+
+
+function TestMapConstructorNextNotAnObject(ctor) {
+  var iterator = {
+    next: function() {
+      return 'abc';
+    }
+  };
+  iterator[Symbol.iterator] = function() {
+    return this;
+  };
+  assertThrows(function() {
+    new ctor(iterator);
+  }, TypeError);
+}
+TestMapConstructorNextNotAnObject(Map);
+//TestMapConstructorNextNotAnObject(WeakMap);
+
+
+function TestMapConstructorIteratorNotObjectValues(ctor) {
+  assertThrows(function() {
+    new ctor(oneAndTwo.values());
+  }, TypeError);
+}
+TestMapConstructorIteratorNotObjectValues(Map);
+//TestMapConstructorIteratorNotObjectValues(WeakMap);
+
+/*
+(function TestWeakMapConstructorNonObjectKeys() {
+  assertThrows(function() {
+    new WeakMap([[1, 2]])
+  }, TypeError);
+})();
+*/
+
+/*
+ * TODO Rhino this kind of overriding of the iterator just isnt' available yet.
+function TestMapConstructorIterableValue(ctor) {
+  'use strict';
+  // Strict mode is required to prevent implicit wrapping in the getter.
+  Object.defineProperty(Number.prototype, Symbol.iterator, {
+    get: function() {
+      assertEquals('number', typeof this);
+      return function() {
+        assertEquals('number', typeof this);
+        return oneAndTwo.entries();
+      };
+    },
+    configurable: true
+  });
+
+  var map = new ctor(42);
+  assertSize(2, map);
+  assertEquals(1, map.get(k1));
+  assertEquals(2, map.get(k2));
+
+  delete Number.prototype[Symbol.iterator];
+}
+TestMapConstructorIterableValue(Map);
+//TestMapConstructorIterableValue(WeakMap);
+*/
+
+function TestCollectionToString(C) {
+  assertEquals("[object " + C.name + "]",
+      Object.prototype.toString.call(new C()));
+}
+TestCollectionToString(Map);
+TestCollectionToString(Set);
+//TestCollectionToString(WeakMap);
+//TestCollectionToString(WeakSet);
+
+
+/*
+ * TODO Rhino this kind of overriding of the iterator just isnt' available yet.
+function TestConstructorOrderOfAdderIterator(ctor, adderName) {
+  var iterable = new Map();
+  iterable.set({}, {});
+  iterable.set({}, {});
+  var iterableFunction = iterable[Symbol.iterator];
+  Object.defineProperty(iterable, Symbol.iterator, {
+    get: function() {
+      log += 'iterator';
+      return iterableFunction;
+    }
+  });
+
+  var log = '';
+  var adderFunction = ctor.prototype[adderName];
+
+  Object.defineProperty(ctor.prototype, adderName, {
+    get: function() {
+      log += adderName;
+      return adderFunction;
+    }
+  });
+
+  new ctor(iterable);
+  assertEquals(adderName + 'iterator', log);
+
+  Object.defineProperty(ctor.prototype, adderName, {
+    value: adderFunction
+  });
+}
+TestConstructorOrderOfAdderIterator(Map, 'set');
+TestConstructorOrderOfAdderIterator(Set, 'add');
+//TestConstructorOrderOfAdderIterator(WeakMap, 'set');
+//TestConstructorOrderOfAdderIterator(WeakSet, 'add');
+*/
+
+"success";
diff --git a/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java b/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java
index 08b3b7c..0a675c5 100644
--- a/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java
+++ b/testsrc/org/mozilla/javascript/tests/Test262SuiteTest.java
@@ -44,14 +44,12 @@
             "Atomics",
             "BigInt",
             "IsHTMLDDA",
-            "Map",
             "Promise.prototype.finally",
             "Proxy",
             "Reflect",
             "Reflect.construct",
             "Reflect.set",
             "Reflect.setPrototypeOf",
-            "Set",
             "SharedArrayBuffer",
             "WeakMap",
             "WeakSet",
diff --git a/testsrc/org/mozilla/javascript/tests/es6/CollectionHashtableTest.java b/testsrc/org/mozilla/javascript/tests/es6/CollectionHashtableTest.java
new file mode 100644
index 0000000..87c0220
--- /dev/null
+++ b/testsrc/org/mozilla/javascript/tests/es6/CollectionHashtableTest.java
@@ -0,0 +1,315 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package org.mozilla.javascript.tests.es6;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Iterator;
+import org.junit.Before;
+import org.junit.Test;
+import org.mozilla.javascript.Hashtable;
+import org.mozilla.javascript.Hashtable.Entry;
+import org.mozilla.javascript.Undefined;
+
+import static org.junit.Assert.*;
+
+/**
+ * These are some tests for the Hashtable implementation that's used by the collection
+ * classes in Rhino.
+ */
+public class CollectionHashtableTest
+{
+  private Hashtable ht;
+
+  @Before
+  public void init() {
+    ht = new Hashtable();
+  }
+
+  /**
+   * Sanity test on empty table.
+   */
+  @Test
+  public void testEmpty() {
+    assertEquals(0, ht.size());
+    assertNull(null, ht.get("one"));
+    assertFalse(ht.has("one"));
+    assertNull(ht.delete("one"));
+    ht.clear();
+    assertEquals(0, ht.size());
+    for (Hashtable.Entry e : ht) {
+      fail("Should be no entries in the hash table");
+    }
+  }
+
+  /**
+   * Just a sanity test for the basic functionality.
+   */
+  @Test
+  public void testCRUD() {
+    ht.put("one", 1);
+    assertEquals(1, ht.size());
+    assertEquals(1, ht.get("one"));
+    assertTrue(ht.has("one"));
+    ht.put("two", 2);
+    assertEquals(2, ht.size());
+    assertEquals(2, ht.get("two"));
+    assertTrue(ht.has("two"));
+    ht.clear();
+    assertEquals(0, ht.size());
+    assertNull(ht.get("one"));
+    assertFalse(ht.has("one"));
+  }
+
+
+  /**
+   * Basic iteration test
+   */
+  @Test
+  public void testBasicIteration() {
+    ht.put("one", 1);
+    ht.put("two", 2);
+
+    Iterator<Entry> i = ht.iterator();
+    assertTrue(i.hasNext());
+    Hashtable.Entry e = i.next();
+    assertEquals("one", e.key());
+    assertEquals(1, e.value());
+
+    assertTrue(i.hasNext());
+    e = i.next();
+    assertEquals("two", e.key());
+    assertEquals(2, e.value());
+
+    assertFalse(i.hasNext());
+  }
+
+  /**
+   * Test that elements appear in insertion order.
+   */
+  @Test
+  public void testInsertionOrder() {
+    ht.put("a", 1);
+    ht.put("e", 2);
+    ht.put("b", 3);
+
+    Iterator<Entry> i = ht.iterator();
+    Hashtable.Entry e = i.next();
+    assertEquals("a", e.key());
+    e = i.next();
+    assertEquals("e", e.key());
+    e = i.next();
+    assertEquals("b", e.key());
+    assertFalse(i.hasNext());
+  }
+
+  /**
+   * Test that they appear in insertion order even if they are modified.
+   */
+  @Test
+  public void testInsertionOrderModified() {
+    ht.put("a", 1);
+    ht.put("e", 2);
+    ht.put("b", 3);
+    ht.put("e", 4);
+
+    Iterator<Entry> i = ht.iterator();
+    Hashtable.Entry e = i.next();
+    assertEquals("a", e.key());
+    e = i.next();
+    assertEquals("e", e.key());
+    e = i.next();
+    assertEquals("b", e.key());
+    assertFalse(i.hasNext());
+  }
+
+  /**
+   * Test that they appear in insertion order when deleted and recreated.
+   */
+  @Test
+  public void testInsertionOrderDeleted() {
+    ht.put("a", 1);
+    ht.put("e", 2);
+    ht.put("b", 3);
+    ht.delete("e");
+    ht.put("e", 5);
+
+    Iterator<Entry> i = ht.iterator();
+    Hashtable.Entry e = i.next();
+    assertEquals("a", e.key());
+    e = i.next();
+    assertEquals("b", e.key());
+    e = i.next();
+    assertEquals("e", e.key());
+    assertFalse(i.hasNext());
+  }
+
+  /**
+   * Test that we can add elements while an iterator exists and see the newer elements.
+   */
+  @Test
+  public void testInsertionOrderAfterIterating() {
+    ht.put("a", 1);
+    ht.put("e", 2);
+
+    Iterator<Entry> i = ht.iterator();
+    Hashtable.Entry e = i.next();
+    assertEquals("a", e.key());
+    e = i.next();
+    assertEquals("e", e.key());
+
+    ht.put("b", 3);
+    e = i.next();
+    assertEquals("b", e.key());
+    assertFalse(i.hasNext());
+  }
+
+  /**
+   * Test "clear" operation and iteration.
+   */
+  @Test
+  public void testInsertionOrderAfterClear() {
+    ht.put("a", 1);
+    ht.put("e", 2);
+    ht.put("b", 3);
+
+
+    Iterator<Entry> i = ht.iterator();
+    Hashtable.Entry e = i.next();
+    assertEquals("a", e.key());
+    e = i.next();
+    assertEquals("e", e.key());
+    e = i.next();
+    assertEquals("b", e.key());
+
+    ht.clear();
+    ht.put("b", 4);
+
+    e = i.next();
+    assertEquals("b", e.key());
+    assertFalse(i.hasNext());
+  }
+
+  /**
+   * Test that we can delete elements while iterating.
+   */
+  @Test
+  public void testInsertionOrderWithDelete() {
+    ht.put("a", 1);
+    ht.put("e", 2);
+    ht.put("b", 3);
+
+    Iterator<Entry> i = ht.iterator();
+    Hashtable.Entry e = i.next();
+    assertEquals("a", e.key());
+
+    ht.delete("e");
+
+    e = i.next();
+    assertEquals("b", e.key());
+    assertFalse(i.hasNext());
+  }
+
+  /**
+   * Worst-case scenario -- delete everything the "hard way" and re-create while iterator
+   * exists.
+   */
+  @Test
+  public void testDeleteAllWhileIterating() {
+    ht.put("a", 1);
+    ht.put("e", 2);
+    ht.put("b", 3);
+
+    Iterator<Entry> i = ht.iterator();
+
+    ht.delete("a");
+    ht.delete("e");
+    ht.delete("b");
+
+    ht.put("aa", 10);
+    ht.put("ee", 20);
+    ht.put("bb", 30);
+
+    Hashtable.Entry e = i.next();
+    assertEquals("aa", e.key());
+    e = i.next();
+    assertEquals("ee", e.key());
+    e = i.next();
+    assertEquals("bb", e.key());
+    assertFalse(i.hasNext());
+  }
+
+  /**
+   * Test serialization of an empty object.
+   */
+  @Test
+  public void testEmptySerialization()
+      throws IOException, ClassNotFoundException {
+
+    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    ObjectOutputStream oout = new ObjectOutputStream(bos);
+    oout.writeObject(ht);
+    oout.close();
+
+    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+    ObjectInputStream oin = new ObjectInputStream(bis);
+    Hashtable sht = (Hashtable)oin.readObject();
+    assertEquals(0, sht.size());
+  }
+
+  /**
+   * Test serialization of a non-empty object with a bunch of different data types,
+   * including the iteration order.
+   */
+  @Test
+  public void testSerialization()
+      throws IOException, ClassNotFoundException {
+
+    ht.put("one", 1);
+    ht.put("two", 2);
+    ht.put("three", 3);
+    ht.put(Undefined.instance, "undefined");
+    ht.put("undefined", Undefined.instance);
+    ht.put(null, "null");
+    ht.put("null", null);
+
+    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    ObjectOutputStream oout = new ObjectOutputStream(bos);
+    oout.writeObject(ht);
+    oout.close();
+
+    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+    ObjectInputStream oin = new ObjectInputStream(bis);
+    Hashtable sht = (Hashtable)oin.readObject();
+
+    assertEquals(1, sht.get("one"));
+    assertEquals(2, sht.get("two"));
+    assertEquals(3, sht.get("three"));
+    assertEquals(Undefined.instance, sht.get("undefined"));
+    assertEquals("undefined", sht.get(Undefined.instance));
+    assertNull(sht.get("null"));
+    assertEquals("null", sht.get(null));
+
+    Iterator<Entry> i = ht.iterator();
+    Hashtable.Entry e = i.next();
+    assertEquals("one", e.key());
+    e = i.next();
+    assertEquals("two", e.key());
+    e = i.next();
+    assertEquals("three", e.key());
+    e = i.next();
+    assertEquals(Undefined.instance, e.key());
+    e = i.next();
+    assertEquals("undefined", e.key());
+    e = i.next();
+    assertNull(e.key());
+    e = i.next();
+    assertEquals("null", e.key());
+    assertFalse(i.hasNext());
+  }
+}
diff --git a/testsrc/org/mozilla/javascript/tests/es6/CollectionsIteratorTest.java b/testsrc/org/mozilla/javascript/tests/es6/CollectionsIteratorTest.java
new file mode 100644
index 0000000..34b33a7
--- /dev/null
+++ b/testsrc/org/mozilla/javascript/tests/es6/CollectionsIteratorTest.java
@@ -0,0 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package org.mozilla.javascript.tests.es6;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.drivers.LanguageVersion;
+import org.mozilla.javascript.drivers.RhinoTest;
+import org.mozilla.javascript.drivers.ScriptTestsBase;
+
+@RhinoTest("testsrc/jstests/es6/collection-iterator.js")
+@LanguageVersion(Context.VERSION_ES6)
+public class CollectionsIteratorTest extends ScriptTestsBase
+{
+}
diff --git a/testsrc/org/mozilla/javascript/tests/es6/CollectionsTest.java b/testsrc/org/mozilla/javascript/tests/es6/CollectionsTest.java
new file mode 100644
index 0000000..f1d457c
--- /dev/null
+++ b/testsrc/org/mozilla/javascript/tests/es6/CollectionsTest.java
@@ -0,0 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package org.mozilla.javascript.tests.es6;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.drivers.LanguageVersion;
+import org.mozilla.javascript.drivers.RhinoTest;
+import org.mozilla.javascript.drivers.ScriptTestsBase;
+
+@RhinoTest("testsrc/jstests/es6/collections.js")
+@LanguageVersion(Context.VERSION_ES6)
+public class CollectionsTest extends ScriptTestsBase
+{
+}
diff --git a/testsrc/test262.properties b/testsrc/test262.properties
index dc4f47c..4d3cee6 100644
--- a/testsrc/test262.properties
+++ b/testsrc/test262.properties
@@ -392,6 +392,11 @@
     ! parse/S15.12.2_A1.js
     ! Symbol.toStringTag.js
 
+built-ins/Map
+    ! Symbol.species
+    # Lots of work to do on strict mode
+    ! prototype/forEach/callback-this-non-strict.js
+
 built-ins/Math
     # calculation is not exact
     ! log2/log2-basicTests.js
@@ -567,6 +572,20 @@
     ! values/tamper-with-global-object.js
     ! values/tamper-with-object-keys.js
 
+built-ins/Set
+    ! Symbol.species
+    # Lots of work to do on strict mode
+    ! prototype/forEach/callback-this-non-strict.js
+    ! prototype/forEach/this-non-strict.js
+    # We don't have WeakSet yet
+    ! prototype/add/does-not-have-setdata-internal-slot-weakset.js
+    ! prototype/clear/does-not-have-setdata-internal-slot-weakset.js
+    ! prototype/delete/does-not-have-setdata-internal-slot-weakset.js
+    ! prototype/entries/does-not-have-setdata-internal-slot-weakset.js
+    ! prototype/forEach/does-not-have-setdata-internal-slot-weakset.js
+    ! prototype/has/does-not-have-setdata-internal-slot-weakset.js
+    ! prototype/values/does-not-have-setdata-internal-slot-weakset.js
+
 built-ins/String
     ! numeric-properties.js
     ! prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js