// |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/
// Check that array's .length property is cloned.
b = Array(5);
assertEq(b.length, 5);
a = check(b);
assertEq(a.length, 5);
b = Array(0);
b[1] = "ok";
a = check(b);
assertEq(a.length, 2);
// Check that prototypes are not cloned, per spec.
b = Object.create({x:1});
b.y = 2;
b.z = 3;
check(b);
// Check that cloning does not separate merge points in the tree. var same = {};
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);
/* 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; try { serialize(new Infinitree); } catch (exc) { threw = true; } assertEq(threw, true);
*/
// Clone an array with holes.
check([0, 1, 2, , 4, 5, 6]);
// Array holes should not take up space.
b = [];
b[255] = 1;
check(b);
assertEq(serialize(b).clonebuffer.length < 255, true);
// Check that trailing holes in an array are preserved.
b = [1,2,3,,];
assertEq(b.length, 4);
a = check(b);
assertEq(a.length, 4);
assertEq(a.toString(), "1,2,3,");
b = [1,2,3,,,];
assertEq(b.length, 5);
a = check(b);
assertEq(a.length, 5);
assertEq(a.toString(), "1,2,3,,");
// Self-modifying object. // This should never read through to b's prototype.
b = Object.create({y: 2},
{x: {enumerable: true,
configurable: true,
get: function() { if (this.hasOwnProperty("y")) deletethis.y; return 1; }},
y: {enumerable: true,
configurable: true,
writable: true,
value: 3}});
check(b, "selfModifyingObject");
// Ignore properties with object-ids. var uri = "http://example.net";
b = {x: 1, y: 2};
Object.defineProperty(b, Array(uri, "x"), {enumerable: true, value: 3});
Object.defineProperty(b, Array(uri, "y"), {enumerable: true, value: 5});
check(b);
}
test();
reportCompare(0, 0, 'ok');
Messung V0.5
¤ Dauer der Verarbeitung: 0.29 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.