Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Side by Side Diff: LayoutTests/inspector/console/console-log-side-effects.html

Issue 388093002: DevTools: Do not crash or hang on console.log() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script>
4
5 function overrideToString()
6 {
7 console.error("FAIL: side effects, should not be called.");
8 return "FAIL";
9 }
10
11 function test()
12 {
13 [Object, Array, Number, Boolean, String, Uint32Array, Node, Element].forEach (function(type) {
14 type.prototype.toString = overrideToString;
15 });
16
17 console.log("string");
18 console.log(42);
19 console.log(false);
20 console.log(undefined);
21 console.log(null);
22 console.log(NaN);
23 console.log(-Infinity);
24 console.log(-0);
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 });
30
31 // Test DOMWrapper object.
32 var node = document.getElementById("node");
33 node.toString = overrideToString;
34 node.__proto__.toString = overrideToString;
35 console.log(node);
36
37 var obj = { foo: 1, bar: 2 };
38 var arr = [1, 2, 3];
39 console.log(obj);
40 console.log(arr);
41
42 console.log(new Uint32Array([1, 2, 3]));
43
44 arr.push(obj);
45 console.log(arr);
46
47 var overridden = { toString: overrideToString };
48 console.log(overridden);
49
50 arr.push(overridden);
51 console.log(arr);
52
53 // Test recursive arrays.
54 var a1 = [[1, [[2], 3], [[[[4]]], 5]]];
55 var a2 = []; a2[3] = null; a2[5] = NaN;
56 a1.push(a2);
57 a2.push(a1);
58 var a3 = [[a1], [[a2]]];
59 a3.push(a3);
60 console.log(a3);
61
62 // This used to timeout.
63 var timeout = { toString: function() { while (true) {} } };
64 console.log(timeout);
65
66 arr.push(timeout);
67 console.log(arr);
68
69 // This used to crash out of memory.
70 const maxArrayLength = 4294967295;
71 for (var i = 100000; i < maxArrayLength; i *= 10) {
72 arr[i] = i;
73 console.log(arr);
74 }
75 arr[maxArrayLength - 1] = a3;
76 console.log(arr);
77
78 // Test array length limit.
79 const arrayLengthLimit = 10000;
80 var arr = [];
81 for (var i = 0; i < arrayLengthLimit + 1; ++i)
82 arr[i] = i;
83 console.log(arr);
84
85 // Test array stack depth limit.
86 var arr = [];
87 for (var i = 0; i < arrayLengthLimit; ++i)
88 arr = [arr];
89 console.log(arr);
90 }
91
92 function runTest()
93 {
94 if (window.testRunner) {
95 testRunner.dumpAsText();
96 testRunner.waitUntilDone();
97 }
98 try {
99 test();
100 } finally {
101 if (window.testRunner)
102 testRunner.notifyDone();
103 }
104 }
105
106 </script>
107 </head>
108 <body onload="runTest()">
109 <p id ="node">
110 Tests various extreme usages of console.log()
111 </p>
112 </body>
113 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698