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

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: compile fix 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 console.log(window);
31
32 // Test DOMWrapper object.
33 var node = document.getElementById("node");
34 node.toString = overrideToString;
35 node.__proto__.toString = overrideToString;
36 console.log(node);
37
38 var obj = { foo: 1, bar: 2 };
39 var arr = [1, 2, 3];
40 console.log(obj);
41 console.log(arr);
42
43 console.log(new Uint32Array([1, 2, 3]));
44
45 arr.push(obj);
46 console.log(arr);
47
48 var overridden = { toString: overrideToString };
49 console.log(overridden);
50
51 arr.push(overridden);
52 console.log(arr);
53
54 // Test recursive arrays.
55 var a1 = [[1, [[2], 3], [[[[4]]], 5]]];
56 var a2 = []; a2[3] = null; a2[5] = NaN;
57 a1.push(a2);
58 a2.push(a1);
59 var a3 = [[a1], [[a2]]];
60 a3.push(a3);
61 console.log(a3);
62
63 // This used to timeout.
64 var timeout = { toString: function() { while (true) {} } };
65 console.log(timeout);
66
67 arr.push(timeout);
68 console.log(arr);
69
70 // This used to crash out of memory.
71 const maxArrayLength = 4294967295;
72 for (var i = 100000; i < maxArrayLength; i *= 10) {
73 arr[i] = i;
74 console.log(arr);
75 }
76 arr[maxArrayLength - 1] = a3;
77 console.log(arr);
78
79 // Test array length limit.
80 const arrayLengthLimit = 10000;
81 var arr = [];
82 for (var i = 0; i < arrayLengthLimit + 1; ++i)
83 arr[i] = i;
84 console.log(arr);
85
86 // Test array stack depth limit.
87 var arr = [];
88 for (var i = 0; i < arrayLengthLimit; ++i)
89 arr = [arr];
90 console.log(arr);
91 }
92
93 function runTest()
94 {
95 if (window.testRunner) {
96 testRunner.dumpAsText();
97 testRunner.waitUntilDone();
98 }
99 try {
100 test();
101 } finally {
102 if (window.testRunner)
103 testRunner.notifyDone();
104 }
105 }
106
107 </script>
108 </head>
109 <body onload="runTest()">
110 <p id ="node">
111 Tests various extreme usages of console.log()
112 </p>
113 </body>
114 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698