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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/inspector/console/console-log-side-effects.html
diff --git a/LayoutTests/inspector/console/console-log-side-effects.html b/LayoutTests/inspector/console/console-log-side-effects.html
new file mode 100644
index 0000000000000000000000000000000000000000..fcbd86fb5f4352dadc4acf94cd3ef574925c942e
--- /dev/null
+++ b/LayoutTests/inspector/console/console-log-side-effects.html
@@ -0,0 +1,114 @@
+<html>
+<head>
+<script>
+
+function overrideToString()
+{
+ console.error("FAIL: side effects, should not be called.");
+ return "FAIL";
+}
+
+function test()
+{
+ [Object, Array, Number, Boolean, String, Uint32Array, Node, Element].forEach(function(type) {
+ type.prototype.toString = overrideToString;
+ });
+
+ console.log("string");
+ console.log(42);
+ console.log(false);
+ console.log(undefined);
+ console.log(null);
+ console.log(NaN);
+ console.log(-Infinity);
+ console.log(-0);
+ console.log(new Number(42));
+ console.log(new Number(-42.42e-12));
+ console.log(new Boolean(true));
+ console.log(new String("foo"));
+ console.log({ __proto__: null });
+ console.log(window);
+
+ // Test DOMWrapper object.
+ var node = document.getElementById("node");
+ node.toString = overrideToString;
+ node.__proto__.toString = overrideToString;
+ console.log(node);
+
+ var obj = { foo: 1, bar: 2 };
+ var arr = [1, 2, 3];
+ console.log(obj);
+ console.log(arr);
+
+ console.log(new Uint32Array([1, 2, 3]));
+
+ arr.push(obj);
+ console.log(arr);
+
+ var overridden = { toString: overrideToString };
+ console.log(overridden);
+
+ arr.push(overridden);
+ console.log(arr);
+
+ // Test recursive arrays.
+ var a1 = [[1, [[2], 3], [[[[4]]], 5]]];
+ var a2 = []; a2[3] = null; a2[5] = NaN;
+ a1.push(a2);
+ a2.push(a1);
+ var a3 = [[a1], [[a2]]];
+ a3.push(a3);
+ console.log(a3);
+
+ // This used to timeout.
+ var timeout = { toString: function() { while (true) {} } };
+ console.log(timeout);
+
+ arr.push(timeout);
+ console.log(arr);
+
+ // This used to crash out of memory.
+ const maxArrayLength = 4294967295;
+ for (var i = 100000; i < maxArrayLength; i *= 10) {
+ arr[i] = i;
+ console.log(arr);
+ }
+ arr[maxArrayLength - 1] = a3;
+ console.log(arr);
+
+ // Test array length limit.
+ const arrayLengthLimit = 10000;
+ var arr = [];
+ for (var i = 0; i < arrayLengthLimit + 1; ++i)
+ arr[i] = i;
+ console.log(arr);
+
+ // Test array stack depth limit.
+ var arr = [];
+ for (var i = 0; i < arrayLengthLimit; ++i)
+ arr = [arr];
+ console.log(arr);
+}
+
+function runTest()
+{
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+ try {
+ test();
+ } finally {
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }
+}
+
+</script>
+</head>
+<body onload="runTest()">
+<p id ="node">
+Tests various extreme usages of console.log()
+</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698