Bug 1300380 - Move deep clone test into separated file and mark it slow in cgc. r=terrence
authorTooru Fujisawa <arai_a@mac.com>
Tue, 27 Sep 2016 10:42:13 +0900
changeset 315312 aeab17249ad8c722544490d1afb54bb0630e24ba
parent 315311 869626f3bac2ce6eec3e4ca657bbd3c056199d12
child 315313 2a5b15755b6e4c61b584c0dc5949481713f297ef
push id30747
push usercbook@mozilla.com
push dateTue, 27 Sep 2016 09:22:00 +0000
treeherdermozilla-central@66a77b9bfe5d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1300380
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1300380 - Move deep clone test into separated file and mark it slow in cgc. r=terrence
js/src/devtools/automation/cgc-jstests-slow.txt
js/src/tests/js1_8_5/extensions/clone-object-deep.js
js/src/tests/js1_8_5/extensions/clone-object.js
js/src/tests/js1_8_5/extensions/shell.js
--- a/js/src/devtools/automation/cgc-jstests-slow.txt
+++ b/js/src/devtools/automation/cgc-jstests-slow.txt
@@ -54,8 +54,9 @@ js1_5/Regress/regress-312588.js
 js1_5/Regress/regress-321971.js
 js1_5/Regress/regress-360969-01.js
 js1_5/Regress/regress-360969-02.js
 js1_5/Regress/regress-360969-03.js
 js1_5/Regress/regress-360969-04.js
 js1_5/Regress/regress-360969-05.js
 js1_5/Regress/regress-360969-06.js
 js1_8_5/extensions/clone-complex-object.js
+js1_8_5/extensions/clone-object-deep.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/js1_8_5/extensions/clone-object-deep.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!xulRuntime.shell)
+// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function test() {
+    var check = clone_object_check;
+
+    // Invoke with the simple parameter to compile the function before doing
+    // deep clone, on --ion-eager case, to avoid timeout.
+    check({x: null, y: undefined});
+
+    // Try cloning a deep object. Don't fail with "too much recursion".
+    var b = {};
+    var current = b;
+    for (var i = 0; i < 10000; i++) {
+        var next = {};
+        current['x' + i] = next;
+        current = next;
+    }
+    check(b, "deepObject");  // takes 2 seconds :-\
+}
+
+test();
+reportCompare(0, 0, 'ok');
--- a/js/src/tests/js1_8_5/extensions/clone-object.js
+++ b/js/src/tests/js1_8_5/extensions/clone-object.js
@@ -1,111 +1,16 @@
 // |reftest| skip-if(!xulRuntime.shell)
 // -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 // Any copyright is dedicated to the Public Domain.
 // http://creativecommons.org/licenses/publicdomain/
 
-// Assert that cloning b does the right thing as far as we can tell.
-// Caveat: getters in b must produce the same value each time they're
-// called. We may call them several times.
-//
-// If desc is provided, then the very first thing we do to b is clone it.
-// (The self-modifying object test counts on this.)
-//
-function check(b, desc) {
-    function classOf(obj) {
-        return Object.prototype.toString.call(obj);
-    }
-
-    function ownProperties(obj) {
-        return Object.getOwnPropertyNames(obj).
-            map(function (p) { return [p, Object.getOwnPropertyDescriptor(obj, p)]; });
-    }
-
-    function isCloneable(pair) {
-        return typeof pair[0] === 'string' && pair[1].enumerable;
-    }
-
-    function notIndex(p) {
-        var u = p >>> 0;
-        return !("" + u == p && u != 0xffffffff);
-    }
-
-    function assertIsCloneOf(a, b, path) {
-        assertEq(a === b, false);
-
-        var ca = classOf(a);
-        assertEq(ca, classOf(b), path);
-
-        assertEq(Object.getPrototypeOf(a),
-                 ca == "[object Object]" ? Object.prototype : Array.prototype,
-                 path);
+function test() {
+    var check = clone_object_check;
 
-        // 'b', the original object, may have non-enumerable or XMLName
-        // properties; ignore them.  'a', the clone, should not have any
-        // non-enumerable properties (except .length, if it's an Array) or
-        // XMLName properties.
-        var pb = ownProperties(b).filter(isCloneable);
-        var pa = ownProperties(a);
-        for (var i = 0; i < pa.length; i++) {
-            assertEq(typeof pa[i][0], "string", "clone should not have E4X properties " + path);
-            if (!pa[i][1].enumerable) {
-                if (Array.isArray(a) && pa[i][0] == "length") {
-                    // remove it so that the comparisons below will work
-                    pa.splice(i, 1);
-                    i--;
-                } else {
-                    throw new Error("non-enumerable clone property " + uneval(pa[i][0]) + " " + path);
-                }
-            }
-        }
-
-        // Check that, apart from properties whose names are array indexes, 
-        // the enumerable properties appear in the same order.
-        var aNames = pa.map(function (pair) { return pair[1]; }).filter(notIndex);
-        var bNames = pa.map(function (pair) { return pair[1]; }).filter(notIndex);
-        assertEq(aNames.join(","), bNames.join(","), path);
-
-        // Check that the lists are the same when including array indexes.
-        function byName(a, b) { a = a[0]; b = b[0]; return a < b ? -1 : a === b ? 0 : 1; }
-        pa.sort(byName);
-        pb.sort(byName);
-        assertEq(pa.length, pb.length, "should see the same number of properties " + path);
-        for (var i = 0; i < pa.length; i++) {
-            var aName = pa[i][0];
-            var bName = pb[i][0];
-            assertEq(aName, bName, path);
-
-            var path2 = path + "." + aName;
-            var da = pa[i][1];
-            var db = pb[i][1];
-            assertEq(da.configurable, true, path2);
-            assertEq(da.writable, true, path2);
-            assertEq("value" in da, true, path2);
-            var va = da.value;
-            var vb = b[pb[i][0]];
-            if (typeof va === "object" && va !== null)
-                queue.push([va, vb, path2]);
-            else
-                assertEq(va, vb, path2);
-        }
-    }
-
-    var banner = "while testing clone of " + (desc || uneval(b));
-    var a = deserialize(serialize(b));
-    var queue = [[a, b, banner]];
-    while (queue.length) {
-        var triple = queue.shift();
-        assertIsCloneOf(triple[0], triple[1], triple[2]);
-    }
-
-    return a; // for further testing
-}
-
-function test() {
     check({});
     check([]);
     check({x: 0});
     check({x: 0.7, p: "forty-two", y: null, z: undefined});
     check(Array.prototype);
     check(Object.prototype);
 
     // before and after
@@ -170,26 +75,16 @@ function test() {
     b = {one: same, two: same};
     a = check(b);
     assertEq(a.one === a.two, true);
 
     b = [same, same];
     a = check(b);
     assertEq(a[0] === a[1], true);
 
-    // Try cloning a deep object. Don't fail with "too much recursion".
-    b = {};
-    var current = b;
-    for (var i = 0; i < 10000; i++) {
-        var next = {};
-        current['x' + i] = next;
-        current = next;
-    }
-    check(b, "deepObject");  // takes 2 seconds :-\
-
     /*
       XXX TODO spin this out into its own test
     // This fails quickly with an OOM error. An exception would be nicer.
     function Infinitree() {
         return { get left() { return new Infinitree; },
                  get right() { return new Infinitree; }};
     }
     var threw = false;
--- a/js/src/tests/js1_8_5/extensions/shell.js
+++ b/js/src/tests/js1_8_5/extensions/shell.js
@@ -11,8 +11,105 @@
 var workerDir = '';
 
 // explicitly turn on js185
 // XXX: The browser currently only supports up to version 1.8
 if (typeof version != 'undefined')
 {
   version(185);
 }
+
+// Assert that cloning b does the right thing as far as we can tell.
+// Caveat: getters in b must produce the same value each time they're
+// called. We may call them several times.
+//
+// If desc is provided, then the very first thing we do to b is clone it.
+// (The self-modifying object test counts on this.)
+//
+function clone_object_check(b, desc) {
+    function classOf(obj) {
+        return Object.prototype.toString.call(obj);
+    }
+
+    function ownProperties(obj) {
+        return Object.getOwnPropertyNames(obj).
+            map(function (p) { return [p, Object.getOwnPropertyDescriptor(obj, p)]; });
+    }
+
+    function isCloneable(pair) {
+        return typeof pair[0] === 'string' && pair[1].enumerable;
+    }
+
+    function notIndex(p) {
+        var u = p >>> 0;
+        return !("" + u == p && u != 0xffffffff);
+    }
+
+    function assertIsCloneOf(a, b, path) {
+        assertEq(a === b, false);
+
+        var ca = classOf(a);
+        assertEq(ca, classOf(b), path);
+
+        assertEq(Object.getPrototypeOf(a),
+                 ca == "[object Object]" ? Object.prototype : Array.prototype,
+                 path);
+
+        // 'b', the original object, may have non-enumerable or XMLName
+        // properties; ignore them.  'a', the clone, should not have any
+        // non-enumerable properties (except .length, if it's an Array) or
+        // XMLName properties.
+        var pb = ownProperties(b).filter(isCloneable);
+        var pa = ownProperties(a);
+        for (var i = 0; i < pa.length; i++) {
+            assertEq(typeof pa[i][0], "string", "clone should not have E4X properties " + path);
+            if (!pa[i][1].enumerable) {
+                if (Array.isArray(a) && pa[i][0] == "length") {
+                    // remove it so that the comparisons below will work
+                    pa.splice(i, 1);
+                    i--;
+                } else {
+                    throw new Error("non-enumerable clone property " + uneval(pa[i][0]) + " " + path);
+                }
+            }
+        }
+
+        // Check that, apart from properties whose names are array indexes, 
+        // the enumerable properties appear in the same order.
+        var aNames = pa.map(function (pair) { return pair[1]; }).filter(notIndex);
+        var bNames = pa.map(function (pair) { return pair[1]; }).filter(notIndex);
+        assertEq(aNames.join(","), bNames.join(","), path);
+
+        // Check that the lists are the same when including array indexes.
+        function byName(a, b) { a = a[0]; b = b[0]; return a < b ? -1 : a === b ? 0 : 1; }
+        pa.sort(byName);
+        pb.sort(byName);
+        assertEq(pa.length, pb.length, "should see the same number of properties " + path);
+        for (var i = 0; i < pa.length; i++) {
+            var aName = pa[i][0];
+            var bName = pb[i][0];
+            assertEq(aName, bName, path);
+
+            var path2 = path + "." + aName;
+            var da = pa[i][1];
+            var db = pb[i][1];
+            assertEq(da.configurable, true, path2);
+            assertEq(da.writable, true, path2);
+            assertEq("value" in da, true, path2);
+            var va = da.value;
+            var vb = b[pb[i][0]];
+            if (typeof va === "object" && va !== null)
+                queue.push([va, vb, path2]);
+            else
+                assertEq(va, vb, path2);
+        }
+    }
+
+    var banner = "while testing clone of " + (desc || uneval(b));
+    var a = deserialize(serialize(b));
+    var queue = [[a, b, banner]];
+    while (queue.length) {
+        var triple = queue.shift();
+        assertIsCloneOf(triple[0], triple[1], triple[2]);
+    }
+
+    return a; // for further testing
+}