5 function overrideToString()
7 console
.error("FAIL: side effects, should not be called.");
13 [Object
, Array
, Number
, Boolean
, String
, Uint32Array
, Node
, Element
].forEach(function(type
) {
14 type
.prototype.toString
= overrideToString
;
17 console
.log("string");
20 console
.log(undefined);
23 console
.log(-Infinity
);
25 console
.log(new Number(42));
26 console
.log(new Number(-42.42e-12));
27 console
.log(new Boolean(true));
28 console
.log(new String("foo"));
29 console
.log({ __proto__
: null });
32 // Test DOMWrapper object.
33 var node
= document
.getElementById("node");
34 node
.toString
= overrideToString
;
35 node
.__proto__
.toString
= overrideToString
;
38 var obj
= { foo
: 1, bar
: 2 };
43 console
.log(new Uint32Array([1, 2, 3]));
48 var overridden
= { toString
: overrideToString
};
49 console
.log(overridden
);
54 // Test recursive arrays.
55 var a1
= [[1, [[2], 3], [[[[4]]], 5]]];
56 var a2
= []; a2
[3] = null; a2
[5] = NaN
;
59 var a3
= [[a1
], [[a2
]]];
63 // This used to timeout.
64 var timeout
= { toString: function() { while (true) {} } };
70 // This used to crash out of memory.
71 const maxArrayLength
= 4294967295;
72 for (var i
= 100000; i
< maxArrayLength
; i
*= 10) {
76 arr
[maxArrayLength
- 1] = a3
;
79 // Test array length limit.
80 const arrayLengthLimit
= 10000;
82 for (var i
= 0; i
< arrayLengthLimit
+ 1; ++i
)
86 // Test array stack depth limit.
88 for (var i
= 0; i
< arrayLengthLimit
; ++i
)
95 if (window
.testRunner
) {
96 testRunner
.dumpAsText();
97 testRunner
.waitUntilDone();
102 if (window
.testRunner
)
103 testRunner
.notifyDone();
109 <body onload=
"runTest()">
111 Tests various extreme usages of console.log()