Bug 1098412 - Remove and update tests that use the legacy Iterator constructor. r?luke draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Thu, 24 Aug 2017 22:45:53 +0900
changeset 655310 bfba5ae2c7b74157ebaecfecd241bb473a0fc494
parent 655309 93c97025e0b6a68214b0e2c72f3feb582d55e6d5
child 655311 6b631a79464b7f713de5580c71f1a879bfd6fdd6
push id76825
push userVYV03354@nifty.ne.jp
push dateTue, 29 Aug 2017 20:26:22 +0000
reviewersluke
bugs1098412
milestone57.0a1
Bug 1098412 - Remove and update tests that use the legacy Iterator constructor. r?luke MozReview-Commit-ID: G7q3ARzOYFf
dom/tests/mochitest/general/test_interfaces.js
dom/workers/test/serviceworkers/test_serviceworker_interfaces.js
dom/workers/test/test_worker_interfaces.js
js/src/builtin/TestingFunctions.cpp
js/src/jit-test/tests/auto-regress/bug511836.js
js/src/jit-test/tests/auto-regress/bug561278.js
js/src/jit-test/tests/auto-regress/bug617485.js
js/src/jit-test/tests/auto-regress/bug637010.js
js/src/jit-test/tests/auto-regress/bug778557.js
js/src/jit-test/tests/baseline/bug1153458.js
js/src/jit-test/tests/basic/bug649939.js
js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js
js/src/jit-test/tests/collections/iterator-1.js
js/src/jit-test/tests/for-of/next-1.js
js/src/jit-test/tests/for-of/next-2.js
js/src/jit-test/tests/for-of/next-surfaces.js
js/src/jit-test/tests/ion/bug735869.js
js/src/jit-test/tests/ion/bug852174.js
js/src/jit-test/tests/jaeger/bug554580-1.js
js/src/jit-test/tests/jaeger/recompile/bug671943-1.js
js/src/jsiter.cpp
js/src/jsiter.h
js/src/tests/js1_5/Regress/regress-407957.js
js/src/tests/js1_7/GC/regress-381374.js
js/src/tests/js1_7/extensions/basic-Iterator.js
js/src/tests/js1_7/extensions/iterator-ctor.js
js/src/tests/js1_7/extensions/regress-354499-01.js
js/src/tests/js1_7/extensions/regress-354499-02.js
js/src/tests/js1_7/extensions/regress-589112.js
js/src/tests/js1_7/extensions/regress-590813.js
js/src/tests/js1_7/geniter/builtin-Iterator-function.js
js/src/tests/js1_7/iterable/regress-341496.js
js/src/tests/js1_7/iterable/regress-354750-01.js
js/src/tests/js1_7/iterable/regress-355025.js
js/src/tests/js1_7/iterable/regress-355090.js
js/src/tests/js1_7/iterable/regress-568056.js
js/src/tests/js1_7/regress/regress-385393-05.js
js/src/tests/js1_7/regress/regress-407957.js
js/xpconnect/tests/chrome/test_bug571849.xul
--- a/dom/tests/mochitest/general/test_interfaces.js
+++ b/dom/tests/mochitest/general/test_interfaces.js
@@ -42,17 +42,16 @@ var ecmaGlobals =
     // Xrayed windows (which are seen from the XBL scope). We could support
     // this if needed with some refactoring.
     {name: "Infinity", xbl: false},
     "Int16Array",
     "Int32Array",
     "Int8Array",
     "InternalError",
     "Intl",
-    "Iterator",
     "JSON",
     "Map",
     "Math",
     {name: "NaN", xbl: false},
     "Number",
     "Object",
     "Promise",
     "Proxy",
--- a/dom/workers/test/serviceworkers/test_serviceworker_interfaces.js
+++ b/dom/workers/test/serviceworkers/test_serviceworker_interfaces.js
@@ -37,17 +37,16 @@ var ecmaGlobals =
     "Float64Array",
     "Function",
     "Infinity",
     "Int16Array",
     "Int32Array",
     "Int8Array",
     "InternalError",
     "Intl",
-    "Iterator",
     "JSON",
     "Map",
     "Math",
     "NaN",
     "Number",
     "Object",
     "Promise",
     "Proxy",
--- a/dom/workers/test/test_worker_interfaces.js
+++ b/dom/workers/test/test_worker_interfaces.js
@@ -37,17 +37,16 @@ var ecmaGlobals =
     "Float64Array",
     "Function",
     "Infinity",
     "Int16Array",
     "Int32Array",
     "Int8Array",
     "InternalError",
     "Intl",
-    "Iterator",
     "JSON",
     "Map",
     "Math",
     "NaN",
     "Number",
     "Object",
     "Promise",
     "Proxy",
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -13,16 +13,17 @@
 #include "mozilla/Unused.h"
 
 #include <cmath>
 
 #include "jsapi.h"
 #include "jscntxt.h"
 #include "jsfriendapi.h"
 #include "jsgc.h"
+#include "jsiter.h"
 #include "jsobj.h"
 #include "jsprf.h"
 #include "jswrapper.h"
 
 #include "builtin/Promise.h"
 #include "builtin/SelfHostingDefines.h"
 #ifdef DEBUG
 #include "frontend/TokenStream.h"
@@ -4423,16 +4424,27 @@ IsConstructor(JSContext* cx, unsigned ar
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() < 1)
         args.rval().setBoolean(false);
     else
         args.rval().setBoolean(IsConstructor(args[0]));
     return true;
 }
 
+static bool
+IsLegacyIterator(JSContext* cx, unsigned argc, Value* vp)
+{
+    CallArgs args = CallArgsFromVp(argc, vp);
+    if (args.length() < 1)
+        args.rval().setBoolean(false);
+    else
+        args.rval().setBoolean(IsLegacyIterator(args[0]));
+    return true;
+}
+
 static const JSFunctionSpecWithHelp TestingFunctions[] = {
     JS_FN_HELP("gc", ::GC, 0, 0,
 "gc([obj] | 'zone' [, 'shrinking'])",
 "  Run the garbage collector. When obj is given, GC only its zone.\n"
 "  If 'zone' is given, GC any zones that were scheduled for\n"
 "  GC via schedulegc.\n"
 "  If 'shrinking' is passed as the optional second argument, perform a\n"
 "  shrinking GC rather than a normal GC."),
@@ -5014,16 +5026,20 @@ gc::ZealModeHelpText),
 "TimeSinceCreation()",
 "  Returns the time in milliseconds since process creation.\n"
 "  This uses a clock compatible with the profiler.\n"),
 
     JS_FN_HELP("isConstructor", IsConstructor, 1, 0,
 "isConstructor(value)",
 "  Returns whether the value is considered IsConstructor.\n"),
 
+    JS_FN_HELP("isLegacyIterator", IsLegacyIterator, 1, 0,
+"isLegacyIterator(value)",
+"  Returns whether the value is considered is a legacy iterator.\n"),
+
     JS_FS_HELP_END
 };
 
 static const JSFunctionSpecWithHelp FuzzingUnsafeTestingFunctions[] = {
 #ifdef DEBUG
     JS_FN_HELP("parseRegExp", ParseRegExp, 3, 0,
 "parseRegExp(pattern[, flags[, match_only])",
 "  Parses a RegExp pattern and returns a tree, potentially throwing."),
deleted file mode 100644
--- a/js/src/jit-test/tests/auto-regress/bug511836.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// Binary: cache/js-dbg-32-16baceea5fe2-linux
-// Flags:
-//
-for (a in (function () {
-    return Iterator(function () {}).__proto__
-})()) {
-    ++b
-}
deleted file mode 100644
--- a/js/src/jit-test/tests/auto-regress/bug561278.js
+++ /dev/null
@@ -1,9 +0,0 @@
-// Binary: cache/js-dbg-32-fe937d72a9ce-linux
-// Flags:
-//
-x = Iterator([])
-for (z in x) {}
-(function() {
-    for (l in function() {}) {}
-} ())
-for (z in x) {}
deleted file mode 100644
--- a/js/src/jit-test/tests/auto-regress/bug617485.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// |jit-test| error:SyntaxError
-
-// Binary: cache/js-dbg-64-4c1fbfcf1d0d-linux
-// Flags:
-//
-Iterator(evalcx('#2=*'))
deleted file mode 100644
--- a/js/src/jit-test/tests/auto-regress/bug637010.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// Binary: cache/js-dbg-64-d708c2fa7fea-linux
-// Flags:
-//
-var o0 = Iterator.prototype;
-function f0(o) {}
-try {
-  for(var i=0; i<7; i++) {
-    try { o0.prototype(); } catch(e) {
-      if (o0.next() != 7)
-        throw "7 not yielded";
-    };
-  }
-} catch(exc1) {}
deleted file mode 100644
--- a/js/src/jit-test/tests/auto-regress/bug778557.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// Binary: cache/js-dbg-64-90828ac18dcf-linux
-// Flags:
-//
-x = Set;
-eval("function y() { return Iterator; }", this);
-x.__iterator__ = y;
-new Iterator(x)
deleted file mode 100644
--- a/js/src/jit-test/tests/baseline/bug1153458.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// |jit-test| --baseline-eager; error: TypeError
-try {
-    this.__defineGetter__("x", Iterator)()
-} catch (e) {}
-f = function() {
-    return (function() {
-        this.x
-    })
-}()
-try {
-    f()
-} catch (e) {}
-f()
deleted file mode 100644
--- a/js/src/jit-test/tests/basic/bug649939.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// This was the actual bug
-assertRaises(StopIteration, function() {
-    Iterator.prototype.next();
-    Iterator.prototype.next();
-});
-
-// The error should have triggered here, but was masked by a latent bug
-assertRaises(StopIteration, function() {
-    Iterator.prototype.next();
-});
-
-// Found by fuzzing
-assertRaises(StopIteration, function() {
-    (new Iterator({})).__proto__.next();
-});
-
-
-function assertRaises(exc, callback) {
-    var caught = false;
-    try {
-        callback();
-    } catch (e) {
-        assertEq(e instanceof StopIteration, true);
-        caught = true;
-    }
-    assertEq(caught, true);
-}
--- a/js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js
+++ b/js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js
@@ -60,17 +60,16 @@ test("new Boolean(true)", b => Boolean.p
 test("new Boolean(true)", b => Boolean.prototype.toString.call(b));
 test("new Boolean(true)", b => Boolean.prototype.valueOf.call(b));
 test("new Number(1)", n => Number.prototype.toSource.call(n));
 test("new Number(1)", n => Number.prototype.toString.call(n));
 test("new Number(1)", n => Number.prototype.valueOf.call(n));
 test("new Number(1)", n => Number.prototype.toFixed.call(n));
 test("new Number(1)", n => Number.prototype.toExponential.call(n));
 test("new Number(1)", n => Number.prototype.toPrecision.call(n));
-test("new Iterator({x:1})", i => Iterator.prototype.next.call(i).toString());
 test("(function(){yield 1})()", i => (function(){yield})().next.call(i).toString());
 test("new String('one')", s => String.prototype.toSource.call(s));
 test("new String('one')", s => String.prototype.toString.call(s));
 test("new RegExp('1')", r => RegExp.prototype.exec.call(r, '1').toString());
 test("new RegExp('1')", r => RegExp.prototype.test.call(r, '1'));
 test("new RegExp('1')", r => RegExp.prototype.compile.call(r, '1').toString());
 test("new RegExp('1')", r => assertEq("a1".search(r), 1));
 test("new RegExp('1')", r => assertEq("a1".match(r)[0], '1'));
--- a/js/src/jit-test/tests/collections/iterator-1.js
+++ b/js/src/jit-test/tests/collections/iterator-1.js
@@ -1,14 +1,13 @@
 // collection.iterator() returns an iterator object.
 
 load(libdir + "iteration.js");
 
 function test(obj, name) {
     var iter = obj[Symbol.iterator]();
     assertEq(typeof iter, "object");
-    assertEq(iter instanceof Iterator, false); // Not a legacy Iterator.
     assertEq(iter.toString(), "[object " + obj.constructor.name + " Iterator]");
 }
 
 test([]);
 test(new Map);
 test(new Set);
deleted file mode 100644
--- a/js/src/jit-test/tests/for-of/next-1.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// Iterator.prototype.next throws if applied to a value that isn't an iterator.
-
-load(libdir + "asserts.js");
-for (var v of [null, undefined, false, 0, "ponies", {}, [], this])
-    assertThrowsInstanceOf(function () { Iterator.prototype.next.call(v); }, TypeError);
deleted file mode 100644
--- a/js/src/jit-test/tests/for-of/next-2.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// Iterator.prototype.next throws if applied to a non-iterator that inherits from an iterator.
-
-load(libdir + "asserts.js");
-load(libdir + "iteration.js");
-
-var it = [1, 2][Symbol.iterator]();
-var v = Object.create(it);
-assertThrowsInstanceOf(function () { Iterator.prototype.next.call(v); }, TypeError);
deleted file mode 100644
--- a/js/src/jit-test/tests/for-of/next-surfaces.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// Test superficial features of the Iterator.prototype.next builtin function.
-
-assertEq(Iterator.prototype.next.length, 0);
-var desc = Object.getOwnPropertyDescriptor(Iterator.prototype, "next");
-assertEq(desc.configurable, true);
-assertEq(desc.enumerable, false);
-assertEq(desc.writable, true);
deleted file mode 100644
--- a/js/src/jit-test/tests/ion/bug735869.js
+++ /dev/null
@@ -1,11 +0,0 @@
-o = {}
-for (let i = 0; i < 70; i++) {
-    try {
-        p
-    } catch (e) {}
-    (function() {
-        for (x in Iterator.prototype) {}
-    })()
-    o.__proto__ = null
-    delete o.__proto__
-}
deleted file mode 100644
--- a/js/src/jit-test/tests/ion/bug852174.js
+++ /dev/null
@@ -1,12 +0,0 @@
-
-function eval() {
-  return isPrototypeOf[Iterator.length];
-}
-function DoWhile_3() {
-  return eval();
-}
-DoWhile_3();
-function f() {
-  return DoWhile_3(f - 0);
-}
-for (var i in f());
deleted file mode 100644
--- a/js/src/jit-test/tests/jaeger/bug554580-1.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// |jit-test| error: TypeError
-for (var a = 0; a < 7; ++a) {
-    if (a == 1) {
-        Iterator()
-    }
-}
-
deleted file mode 100644
--- a/js/src/jit-test/tests/jaeger/recompile/bug671943-1.js
+++ /dev/null
@@ -1,12 +0,0 @@
-gczeal(2);
-o1 = Iterator;
-var o2 = (function() { return arguments; })();
-function f(o) {
-    for(var j=0; j<20; j++) {
-        Object.seal(o2);
-        (function() { return eval(o); })() == o1;
-        (function() { return {x: arguments}.x; })();
-        if (false) {};
-    }
-}
-f({});
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -1128,26 +1128,26 @@ NativeIteratorNext(JSContext* cx, Native
         return false;
 
     // JS 1.7 only: for each (let [k, v] in obj)
     if (ni->flags & JSITER_KEYVALUE)
         return NewKeyValuePair(cx, id, rval, rval);
     return true;
 }
 
-MOZ_ALWAYS_INLINE bool
-IsIterator(HandleValue v)
+bool
+js::IsLegacyIterator(HandleValue v)
 {
     return v.isObject() && v.toObject().hasClass(&PropertyIteratorObject::class_);
 }
 
 MOZ_ALWAYS_INLINE bool
 legacy_iterator_next_impl(JSContext* cx, const CallArgs& args)
 {
-    MOZ_ASSERT(IsIterator(args.thisv()));
+    MOZ_ASSERT(IsLegacyIterator(args.thisv()));
 
     RootedObject thisObj(cx, &args.thisv().toObject());
 
     NativeIterator* ni = thisObj.as<PropertyIteratorObject>()->getNativeIterator();
     RootedValue value(cx);
     bool done;
     if (!NativeIteratorNext(cx, ni, &value, &done))
          return false;
@@ -1161,17 +1161,17 @@ legacy_iterator_next_impl(JSContext* cx,
     args.rval().set(value);
     return true;
 }
 
 static bool
 legacy_iterator_next(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
-    return CallNonGenericMethod<IsIterator, legacy_iterator_next_impl>(cx, args);
+    return CallNonGenericMethod<IsLegacyIterator, legacy_iterator_next_impl>(cx, args);
 }
 
 static const JSFunctionSpec legacy_iterator_methods[] = {
     JS_SELF_HOSTED_SYM_FN(iterator, "LegacyIteratorShim", 0, 0),
     JS_FN("next",      legacy_iterator_next,       0, 0),
     JS_FS_END
 };
 
--- a/js/src/jsiter.h
+++ b/js/src/jsiter.h
@@ -218,16 +218,19 @@ ThrowStopIteration(JSContext* cx);
  * ES 2017 draft 7.4.7.
  */
 extern JSObject*
 CreateIterResultObject(JSContext* cx, HandleValue value, bool done);
 
 extern JSObject*
 InitLegacyIteratorClass(JSContext* cx, HandleObject obj);
 
+bool
+IsLegacyIterator(HandleValue v);
+
 extern JSObject*
 InitStopIterationClass(JSContext* cx, HandleObject obj);
 
 enum class IteratorKind { Sync, Async };
 
 } /* namespace js */
 
 #endif /* jsiter_h */
deleted file mode 100644
--- a/js/src/tests/js1_5/Regress/regress-407957.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 407957;
-var summary = 'Iterator is mutable.';
-var actual = '';
-var expect = '';
-
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
- 
-  var obj           = {};
-  var saveIterator  = Iterator;
-
-  Iterator = obj;
-  reportCompare(obj, Iterator, summary);
-
-  exitFunc ('test');
-}
deleted file mode 100644
--- a/js/src/tests/js1_7/GC/regress-381374.js
+++ /dev/null
@@ -1,60 +0,0 @@
-// |reftest| skip-if(Android)
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 381374;
-var summary = 'js_AddScopeProperty - overwrite property with watchpoint';
-var actual = '';
-var expect = '';
-
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
- 
-  function huh()
-  {
-    var f;
-
-    Iterator; // ???
-
-    if (0 && 0) {
-      eval(""); // ???
-    }
-
-    f = new Function("x = 1");
-
-    try {
-      f();
-    } catch(e) {}
-  }
-
-  this.watch('x', function(){});
-  this.__defineGetter__('x', new Function());
-  huh();
-  if (typeof gczeal == 'function')
-  {
-    gczeal(2); 
-  }
-
-  for (y in [0,1]) { this.__defineSetter__('x', function(){}); }
-
-  if (typeof gczeal == 'function')
-  {
-    gczeal(0);
-  }
-
-  reportCompare(expect, actual, summary);
-
-  exitFunc ('test');
-}
deleted file mode 100644
--- a/js/src/tests/js1_7/extensions/basic-Iterator.js
+++ /dev/null
@@ -1,165 +0,0 @@
-/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER     = "(none)";
-var summary = "Basic support for accessing iterable objects using Iterator";
-var actual, expect;
-
-printBugNumber(BUGNUMBER);
-printStatus(summary);
-
-/**************
- * BEGIN TEST *
- **************/
-
-var failed = false;
-
-function Array_equals(a, b)
-{
-  if (!(a instanceof Array) || !(b instanceof Array))
-    throw new Error("Arguments not both of type Array");
-  if (a.length != b.length)
-    return false;
-  for (var i = 0, sz = a.length; i < sz; i++)
-    if (a[i] !== b[i])
-      return false;
-  return true;
-}
-
-var iterable = { persistedProp: 17 };
-
-try
-{
-  // nothing unusual so far -- verify basic properties
-  for (var i in iterable)
-  {
-    if (i != "persistedProp")
-      throw "no persistedProp!";
-    if (iterable[i] != 17)
-      throw "iterable[\"persistedProp\"] == 17";
-  }
-
-  var keys = ["foo", "bar", "baz"];
-  var vals = [6, 5, 14];
-
-  iterable.__iterator__ =
-    function(keysOnly)
-    {
-      var gen =
-      function()
-      {
-	for (var i = 0; i < keys.length; i++)
-	{
-	  if (keysOnly)
-	    yield keys[i];
-	  else
-	    yield [keys[i], vals[i]];
-	}
-      };
-      return gen();
-    };
-
-  /* Test [key, value] Iterator */
-  var index = 0;
-  var lastSeen = "INITIALVALUE";
-  var it = Iterator(iterable);
-  try
-  {
-    while (true)
-    {
-      var nextVal = it.next();
-      if (!Array_equals(nextVal, [keys[index], vals[index]]))
-        throw "Iterator(iterable): wrong next result\n" +
-	  "  expected: " + [keys[index], vals[index]] + "\n" +
-	  "  actual:   " + nextVal;
-      lastSeen = keys[index];
-      index++;
-    }
-  }
-  catch (e)
-  {
-    if (lastSeen !== keys[keys.length - 1])
-      throw "Iterator(iterable): not everything was iterated!\n" +
-	"  last iterated was: " + lastSeen + "\n" +
-	"  error: " + e;
-    if (e !== StopIteration)
-      throw "Iterator(iterable): missing or invalid StopIteration";
-  }
-
-  if (iterable.persistedProp != 17)
-    throw "iterable.persistedProp not persisted!";
-
-  /* Test [key, value] Iterator, called with an explicit |false| parameter */
-  var index = 0;
-  lastSeen = "INITIALVALUE";
-  it = Iterator(iterable, false);
-  try
-  {
-    while (true)
-    {
-      var nextVal = it.next();
-      if (!Array_equals(nextVal, [keys[index], vals[index]]))
-        throw "Iterator(iterable, false): wrong next result\n" +
-	  "  expected: " + [keys[index], vals[index]] + "\n" +
-	  "  actual:   " + nextVal;
-      lastSeen = keys[index];
-      index++;
-    }
-  }
-  catch (e)
-  {
-    if (lastSeen !== keys[keys.length - 1])
-      throw "Iterator(iterable, false): not everything was iterated!\n" +
-	"  last iterated was: " + lastSeen + "\n" +
-	"  error: " + e;
-    if (e !== StopIteration)
-      throw "Iterator(iterable, false): missing or invalid StopIteration";
-  }
-
-  if (iterable.persistedProp != 17)
-    throw "iterable.persistedProp not persisted!";
-
-  /* Test key-only Iterator */
-  index = 0;
-  lastSeen = undefined;
-  it = Iterator(iterable, true);
-  try
-  {
-    while (true)
-    {
-      var nextVal = it.next();
-      if (nextVal !== keys[index])
-        throw "Iterator(iterable, true): wrong next result\n" +
-	  "  expected: " + keys[index] + "\n" +
-	  "  actual:   " + nextVal;
-      lastSeen = keys[index];
-      index++;
-    }
-  }
-  catch (e)
-  {
-    if (lastSeen !== keys[keys.length - 1])
-      throw "Iterator(iterable, true): not everything was iterated!\n" +
-	"  last iterated was: " + lastSeen + "\n" +
-	"  error: " + e;
-    if (e !== StopIteration)
-      throw "Iterator(iterable, true): missing or invalid StopIteration";
-  }
-
-  if (iterable.persistedProp != 17)
-    throw "iterable.persistedProp not persisted!";
-}
-catch (e)
-{
-  failed = e;
-}
-
-
-
-expect = false;
-actual = failed;
-
-reportCompare(expect, actual, summary);
deleted file mode 100644
--- a/js/src/tests/js1_7/extensions/iterator-ctor.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-// See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Iterators_and_Generators
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER  = "410725";
-var summary = "Test of the global Iterator constructor";
-var actual, expect;
-
-printBugNumber(BUGNUMBER);
-printStatus(summary);
-
-/**************
- * BEGIN TEST *
- **************/
-
-function iteratorToArray(iterator) {
-  var result = [];
-  for (var i in iterator) {
-    result[result.length] = i;
-  }
-  return result.sort();
-}
-
-var obj = {a:1, b:2};
-
-reportCompare('["a", "b"]',
-              uneval(iteratorToArray(obj)),
-              'uneval(iteratorToArray(obj))');
-
-reportCompare('[["a", 1], ["b", 2]]',
-              uneval(iteratorToArray(Iterator(obj))),
-              'uneval(iteratorToArray(Iterator(obj)))');
-
-reportCompare('[["a", 1], ["b", 2]]',
-              uneval(iteratorToArray(new Iterator(obj))),
-              'uneval(iteratorToArray(new Iterator(obj)))');
-
-reportCompare('[["a", 1], ["b", 2]]',
-              uneval(iteratorToArray(Iterator(obj,false))),
-              'uneval(iteratorToArray(Iterator(obj,false)))');
-
-reportCompare('[["a", 1], ["b", 2]]',
-              uneval(iteratorToArray(new Iterator(obj,false))),
-              'uneval(iteratorToArray(new Iterator(obj,false)))');
-
-reportCompare('["a", "b"]',
-              uneval(iteratorToArray(Iterator(obj,true))),
-              'uneval(iteratorToArray(Iterator(obj,true)))');
-
-reportCompare('["a", "b"]',
-              uneval(iteratorToArray(new Iterator(obj,true))),
-              'uneval(iteratorToArray(new Iterator(obj,true)))');
-
-var flag;
-var obji = {a:1, b:2};
-obji.__iterator__ = function (b) { flag = b; yield -1; yield -2; }
-
-flag = -1;
-reportCompare('[-1, -2]',
-              uneval(iteratorToArray(obji)),
-              'uneval(iteratorToArray(obji))');
-reportCompare(true, flag, 'uneval(iteratorToArray(obji)) flag');
-
-flag = -1;
-reportCompare('[-1, -2]',
-              uneval(iteratorToArray(Iterator(obji))),
-              'uneval(iteratorToArray(Iterator(obji)))');
-reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji))) flag');
-
-flag = -1;
-reportCompare('[-1, -2]',
-              uneval(iteratorToArray(new Iterator(obji))),
-              'uneval(iteratorToArray(new Iterator(obji)))');
-reportCompare(false, flag, 'uneval(iteratorToArray(new Iterator(obji))) flag');
-
-flag = -1;
-reportCompare('[-1, -2]',
-              uneval(iteratorToArray(Iterator(obji,false))),
-              'uneval(iteratorToArray(Iterator(obji,false)))');
-reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji,false))) flag');
-
-flag = -1;
-reportCompare('[-1, -2]',
-              uneval(iteratorToArray(new Iterator(obji,false))),
-              'uneval(iteratorToArray(new Iterator(obji,false)))');
-reportCompare(false, flag, 'uneval(iteratorToArray(new Iterator(obji,false))) flag');
-
-flag = -1;
-reportCompare('[-1, -2]',
-              uneval(iteratorToArray(Iterator(obji,true))),
-              'uneval(iteratorToArray(Iterator(obji,true)))');
-reportCompare(true, flag, 'uneval(iteratorToArray(Iterator(obji,true))) flag');
-
-flag = -1;
-reportCompare('[-1, -2]',
-              uneval(iteratorToArray(new Iterator(obji,true))),
-              'uneval(iteratorToArray(new Iterator(obji,true)))');
-reportCompare(true, flag, 'uneval(iteratorToArray(new Iterator(obji,true))) flag');
deleted file mode 100644
--- a/js/src/tests/js1_7/extensions/regress-354499-01.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 354499;
-var summary = 'Iterating over Array elements';
-var actual = '';
-var expect = '';
-
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
-
-  expect = actual = 'No Crash';
-
-  var obj = {get a(){ return new Object(); }};
-
-  function setter(v)
-  {
-    // Push out obj.a from all temp roots
-    var tmp = { get toString() { return new Object(); }};
-    try { String(tmp); } catch (e) {  }
-    gc();
-  }
-
-  Array.prototype.__defineGetter__(0, function() { });
-  Array.prototype.__defineSetter__(0, setter);
-
-  for (var i in Iterator(obj))
-    print(uneval(i));
-
-  delete Array.prototype[0];
-
-  reportCompare(expect, actual, summary);
-
-  exitFunc ('test');
-}
deleted file mode 100644
--- a/js/src/tests/js1_7/extensions/regress-354499-02.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 354499;
-var summary = 'Iterating over Array elements';
-var actual = '';
-var expect = '';
-
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
-
-  expect = actual = 'No Crash';
-
-  function get_value()
-  {
-    // Unroot the first element
-    this[0] = 0;
-
-    // Call gc to collect atom corresponding to Math.sqrt(2)
-    gc();
-  }
-
-  var counter = 2;
-  Iterator.prototype.next = function()
-    {
-      if (counter-- <= 0) throw StopIteration;
-      var a = [Math.sqrt(2), 1];
-      a.__defineGetter__(1, get_value);
-      return a;
-    };
-
-  for (i in [1])
-    ;
-
-  reportCompare(expect, actual, summary);
-
-  exitFunc ('test');
-}
deleted file mode 100644
--- a/js/src/tests/js1_7/extensions/regress-589112.js
+++ /dev/null
@@ -1,6 +0,0 @@
-
-f = eval("(function(){return x=Iterator(/x/)})")
-for (a in f()) {}
-for (d in x) {}
-
-reportCompare(0, 0, "");
deleted file mode 100644
--- a/js/src/tests/js1_7/extensions/regress-590813.js
+++ /dev/null
@@ -1,23 +0,0 @@
-
-var actual = '';
-var expected = 'A0B1B2C0C1C2';
-
-var x = Iterator([1,2,3], true);
-
-for (var a in x) {
-  actual += 'A' + a;
-  for (var b in x) {
-    actual += 'B' + b;
-  }
-}
-
-var y = Iterator([1,2,3], true);
-
-for (var c in y) {
-  actual += 'C' + c;
-}
-for (var d in y) {
-  actual += 'D' + d;
-}
-
-reportCompare(expected, actual, "Handle nested Iterator iteration right");
deleted file mode 100644
--- a/js/src/tests/js1_7/geniter/builtin-Iterator-function.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER     = "(none)";
-var summary = "Iterator() test";
-var actual, expect;
-
-printBugNumber(BUGNUMBER);
-printStatus(summary);
-
-/**************
- * BEGIN TEST *
- **************/
-
-var failed = false;
-
-function Array_equals(a, b)
-{
-  if (!(a instanceof Array) || !(b instanceof Array))
-    throw new Error("Arguments not both of type Array");
-  if (a.length != b.length)
-    return false;
-  for (var i = 0, sz = a.length; i < sz; i++)
-    if (a[i] !== b[i])
-      return false;
-  return true;
-}
-
-var meow = "meow", oink = "oink", baa = "baa";
-
-var it = Iterator([meow, oink, baa]);
-var it2 = Iterator([meow, oink, baa], true);
-
-try
-{
-  if (!Array_equals(it.next(), [0, meow]))
-    throw [0, meow];
-  if (!Array_equals(it.next(), [1, oink]))
-    throw [1, oink];
-  if (!Array_equals(it.next(), [2, baa]))
-    throw [2, baa];
-
-  var stopPassed = false;
-  try
-  {
-    it.next();
-  }
-  catch (e)
-  {
-    if (e === StopIteration)
-      stopPassed = true;
-  }
-
-  if (!stopPassed)
-    throw "it: missing or incorrect StopIteration";
-
-  if (it2.next() != 0)
-    throw "wanted key=0";
-  if (it2.next() != 1)
-    throw "wanted key=1";
-  if (it2.next() != 2)
-    throw "wanted key=2";
-
-  var stopPassed = false;
-  try
-  {
-    it2.next();
-  }
-  catch (e)
-  {
-    if (e === StopIteration)
-      stopPassed = true;
-  }
-
-  if (!stopPassed)
-    throw "it2: missing or incorrect StopIteration";
-}
-catch (e)
-{
-  failed = e;
-}
-
-expect = false;
-actual = failed;
-
-reportCompare(expect, actual, summary);
deleted file mode 100644
--- a/js/src/tests/js1_7/iterable/regress-341496.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 341496;
-var summary = 'Iterators: check that adding properties does not crash';
-var actual = 'No Crash';
-var expect = 'No Crash';
-
-printBugNumber(BUGNUMBER);
-printStatus (summary);
-
-var iter = Iterator({});
-for (var i = 0; i != 10*1000; ++i)
-  iter[i] = i;
- 
-reportCompare(expect, actual, summary);
deleted file mode 100644
--- a/js/src/tests/js1_7/iterable/regress-354750-01.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 354750;
-var summary = 'Changing Iterator.prototype.next should not affect default iterator';
-var actual = '';
-var expect = '';
-
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
- 
-  Iterator.prototype.next = function() {
-    throw "This should not be thrown";
-  }
-
-  expect = 'No exception';
-  actual = 'No exception';
-  try
-  {
-    for (var i in [])
-    {
-    }
-  }
-  catch(ex)
-  {
-    actual = ex;
-  }
-  reportCompare(expect, actual, summary);
-
-  exitFunc ('test');
-}
deleted file mode 100644
--- a/js/src/tests/js1_7/iterable/regress-355025.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 355025;
-var summary = 'Test regression from bug 354750 - Iterable()';
-var actual = 'No Error';
-var expect = 'No Error';
-
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
- 
-  Iterator([]);
-
-  reportCompare(expect, actual, summary);
-
-  exitFunc ('test');
-}
deleted file mode 100644
--- a/js/src/tests/js1_7/iterable/regress-355090.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 355090;
-var summary = 'Iterator(8) is a function';
-var actual = '';
-var expect = '';
-
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
- 
-  expect = 'No Error';
-  actual = 'No Error';
-  try
-  {
-    Iterator(8);
-  }
-  catch(ex)
-  {
-    actual = ex + '';
-  }
-
-  reportCompare(expect, actual, summary);
-
-  exitFunc ('test');
-}
deleted file mode 100644
--- a/js/src/tests/js1_7/iterable/regress-568056.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// Any copyright is dedicated to the Public Domain.
-// http://creativecommons.org/licenses/publicdomain/
-
-var BUGNUMBER = 568056;
-var summary = "Iterator(obj) must not go up obj's prototype chain";
-
-var foo = {
-    z: 9,
-};
-
-var bar = {
-    __proto__: foo,
-    a: 1,
-    b: 2,
-};
-
-var results = [];
-for each (let [key, value] in Iterator(bar))
-    results.push(key + ":" + value);
-
-var actual = results.join(';')
-var expect = "a:1;b:2";
-
-reportCompare(expect, actual, summary);
deleted file mode 100644
--- a/js/src/tests/js1_7/regress/regress-385393-05.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 385393;
-var summary = 'Regression test for bug 385393';
-var actual = 'No Crash';
-var expect = 'No Crash';
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
- 
-  function c(gen)
-  {
-    Iterator;    
-
-    "" + gen;
-
-    for (var i in gen())
-      ;
-  }
-
-  function gen()
-  {
-    ({}).hasOwnProperty();
-    yield;
-  }
-
-  c(gen);
-
-  reportCompare(expect, actual, summary);
-
-  exitFunc ('test');
-}
deleted file mode 100644
--- a/js/src/tests/js1_7/regress/regress-407957.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* 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/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 407957;
-var summary = 'Iterator is mutable.';
-var actual = '';
-var expect = '';
-
-
-//-----------------------------------------------------------------------------
-test();
-//-----------------------------------------------------------------------------
-
-function test()
-{
-  enterFunc ('test');
-  printBugNumber(BUGNUMBER);
-  printStatus (summary);
- 
-  var obj           = {};
-  var saveIterator  = Iterator;
-
-  Iterator = obj;
-  reportCompare(obj, Iterator, summary);
-
-  exitFunc ('test');
-}
--- a/js/xpconnect/tests/chrome/test_bug571849.xul
+++ b/js/xpconnect/tests/chrome/test_bug571849.xul
@@ -19,20 +19,20 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script type="application/javascript"><![CDATA[
 
   /** Test for Bug 500931 **/
 
   function go() {
     var ifr = document.getElementById('ifr');
     var docnodes = ifr.contentDocument.body.childNodes;
     var index, value;
-    for (let i in Iterator(docnodes)) {
+    for (let i of Object.entries(docnodes)) {
       index = i[0], value = i[1];
     }
-    is(index, 0, "enumerated the 0th element");
+    is(index, "0", "enumerated the 0th element");
     ok(value instanceof Text, "the 0th element was a text node");
     SimpleTest.finish();
   }
 
   SimpleTest.waitForExplicitFinish();
 
   ]]></script>
   <iframe type="content"