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

Unified Diff: test/mjsunit/stack-traces.js

Issue 2201823002: Make CallSite constructor inaccessible from JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@get-stack-trace-line
Patch Set: Revert "CHECK invalid arguments to CallSite constructor" Created 4 years, 4 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
« no previous file with comments | « src/messages.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/stack-traces.js
diff --git a/test/mjsunit/stack-traces.js b/test/mjsunit/stack-traces.js
index bd7909383fc29a63e77f67f8e1a942476a765718..b0d93dbdfeebcc1b0628468079078d3fab97ec6e 100644
--- a/test/mjsunit/stack-traces.js
+++ b/test/mjsunit/stack-traces.js
@@ -398,8 +398,10 @@ assertThrows(() => Error.captureStackTrace(x));
// Check that we don't crash when CaptureSimpleStackTrace returns undefined.
var o = {};
+var oldStackTraceLimit = Error.stackTraceLimit;
Error.stackTraceLimit = "not a number";
Error.captureStackTrace(o);
+Error.stackTraceLimit = oldStackTraceLimit;
// Check that we don't crash when a callsite's function's script is empty.
Error.prepareStackTrace = function(e, frames) {
@@ -412,14 +414,27 @@ try {
assertEquals(undefined, e.stack);
}
-// Check that a tight recursion in prepareStackTrace fails gracefully, i.e.
-// a range error is thrown and printed (but without showing the actual stack).
-
+// Check that a tight recursion in prepareStackTrace throws when accessing
+// stack. Trying again without a custom formatting function formats correctly.
+var err = new Error("abc");
Error.prepareStackTrace = () => Error.prepareStackTrace();
try {
- new Error().stack;
+ err.stack;
+ assertUnreachable();
} catch (e) {
- assertTrue(
- e.stack.indexOf("RangeError: Maximum call stack size exceeded") != -1);
- assertTrue(e.stack.indexOf("prepareStackTrace") == -1);
+ err = e;
}
+
+Error.prepareStackTrace = undefined;
+assertTrue(
+ err.stack.indexOf("RangeError: Maximum call stack size exceeded") != -1);
+assertTrue(err.stack.indexOf("prepareStackTrace") != -1);
+
+// Check that the callsite constructor throws.
+
+Error.prepareStackTrace = (e,s) => s;
+var constructor = new Error().stack[0].constructor;
+
+assertThrows(() => constructor.call());
+assertThrows(() => constructor.call(
+ null, {}, () => undefined, {valueOf() { return 0 }}, false));
« no previous file with comments | « src/messages.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698